Commit 8692ee55 authored by Medicean's avatar Medicean

(Enhancement:Module:FileManager) 新增「复制文件名」和「复制文件路径」功能 #109

parent 8524d06d
......@@ -11,6 +11,7 @@
### 文件管理
* 编辑文件窗口将「编码」按钮替换为「用此编码打开」, 若打开文件之后乱码,不妨试试切换编码
* 新增「复制文件名」和「复制文件路径」功能,目标复制文件名或路径到剪贴板
### Other
......
# AntSword [![release](https://img.shields.io/badge/release-v2.0.3.2-blue.svg?style=flat-square)][url-release]
# AntSword [![release](https://img.shields.io/badge/release-v2.0.3.3-blue.svg?style=flat-square)][url-release]
> AntSword in your hands, no worries in your mind!
......
# 中国蚁剑 [![release](https://img.shields.io/badge/release-v2.0.3.2-blue.svg?style=flat-square)][url-release]
# 中国蚁剑 [![release](https://img.shields.io/badge/release-v2.0.3.3-blue.svg?style=flat-square)][url-release]
> 一剑在手,纵横无忧!
......
{
"name": "antsword",
"version": "2.0.3.2",
"version": "2.0.3.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "antsword",
"version": "2.0.3.2",
"version": "2.0.3.3",
"description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js",
"dependencies": {
......
......@@ -317,6 +317,10 @@ module.exports = {
chmod: 'Chmod',
copy: {
title: 'Copy',
copyname: 'Copy FileName',
copypath: 'Copy FilePath',
copysuccess: 'Copy to clipboard successfully!',
copyfail: 'Copy to clipboard failed!',
warning: (id) => antSword.noxss(`Already add to clipboard!\n${id}`),
info: (id) => antSword.noxss(`Add file to the clipboard.\n${id}`)
},
......
......@@ -318,6 +318,10 @@ module.exports = {
chmod: '更改权限',
copy: {
title: '复制文件',
copyname: '复制文件名',
copypath: '复制文件路径',
copysuccess: '复制到剪贴板成功!',
copyfail: '复制到剪贴板失败!',
warning: (id) => antSword.noxss(`已经添加到剪贴板!\n${id}`),
info: (id) => antSword.noxss(`添加文件到剪贴板\n${id}`)
},
......
......@@ -4,6 +4,7 @@
const LANG_T = antSword['language']['toastr'];
const LANG = antSword['language']['filemanager']['files'];
const clipboard = require('electron').clipboard;
class Files {
......@@ -293,6 +294,7 @@ class Files {
manager.downloadFile(id, this.getRowAttribute(_ids[0], 'fsize'));
} },
{ divider: true },
{ text: LANG['grid']['contextmenu']['copy']['title'], icon: 'fa fa-copy', subMenu: [
{ text: LANG['grid']['contextmenu']['copy']['title'], icon: 'fa fa-copy', disabled: !id, action: () => {
// 如果只有一个id,则显示id名称,否则显示ids数量
ids.map( (id) => {
......@@ -305,6 +307,28 @@ class Files {
toastr.info(LANG['grid']['contextmenu']['copy']['info'](id), LANG_T['info']);
} );
} },
{ text: LANG['grid']['contextmenu']['copy']['copyname'], icon: 'fa fa-file-word-o', disabled: !id || ids.length > 1, action: ()=>{
clipboard.writeText(id);
// 检测是否复制成功
let txt = clipboard.readText();
if(txt == id){
toastr.success(LANG['grid']['contextmenu']['copy']['copysuccess'], LANG_T['success']);
}else{
toastr.error(LANG['grid']['contextmenu']['copy']['copyfail'], LANG_T['error']);
}
}},
{ text: LANG['grid']['contextmenu']['copy']['copypath'], icon: 'fa fa-file-powerpoint-o', disabled: !id || ids.length > 1, action:()=>{
let txt = `${self.manager.path}${id}`;
clipboard.writeText(txt);
// 检测是否复制成功
let cptxt = clipboard.readText();
if(cptxt == txt){
toastr.success(LANG['grid']['contextmenu']['copy']['copysuccess'], LANG_T['success']);
}else{
toastr.error(LANG['grid']['contextmenu']['copy']['copyfail'], LANG_T['error']);
}
}}
]},
{ text: LANG['grid']['contextmenu']['paste']['title'], icon: 'fa fa-paste', disabled: _Clipboard_num === 0, subMenu: _Clipboard },
{ text: LANG['grid']['contextmenu']['preview'], icon: 'fa fa-eye', disabled: !id || ids.length > 1 || !self.checkPreview(id), action: () => {
manager.previewFile(id, this.getRowAttribute(_ids[0], 'fsize'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment