Commit 8692ee55 authored by Medicean's avatar Medicean

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

parent 8524d06d
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
### 文件管理 ### 文件管理
* 编辑文件窗口将「编码」按钮替换为「用此编码打开」, 若打开文件之后乱码,不妨试试切换编码 * 编辑文件窗口将「编码」按钮替换为「用此编码打开」, 若打开文件之后乱码,不妨试试切换编码
* 新增「复制文件名」和「复制文件路径」功能,目标复制文件名或路径到剪贴板
### Other ### 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! > 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", "name": "antsword",
"version": "2.0.3.2", "version": "2.0.3.3",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
......
{ {
"name": "antsword", "name": "antsword",
"version": "2.0.3.2", "version": "2.0.3.3",
"description": "中国蚁剑是一款跨平台的开源网站管理工具", "description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js", "main": "app.js",
"dependencies": { "dependencies": {
......
...@@ -317,6 +317,10 @@ module.exports = { ...@@ -317,6 +317,10 @@ module.exports = {
chmod: 'Chmod', chmod: 'Chmod',
copy: { copy: {
title: '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}`), warning: (id) => antSword.noxss(`Already add to clipboard!\n${id}`),
info: (id) => antSword.noxss(`Add file to the clipboard.\n${id}`) info: (id) => antSword.noxss(`Add file to the clipboard.\n${id}`)
}, },
......
...@@ -318,6 +318,10 @@ module.exports = { ...@@ -318,6 +318,10 @@ module.exports = {
chmod: '更改权限', chmod: '更改权限',
copy: { copy: {
title: '复制文件', title: '复制文件',
copyname: '复制文件名',
copypath: '复制文件路径',
copysuccess: '复制到剪贴板成功!',
copyfail: '复制到剪贴板失败!',
warning: (id) => antSword.noxss(`已经添加到剪贴板!\n${id}`), warning: (id) => antSword.noxss(`已经添加到剪贴板!\n${id}`),
info: (id) => antSword.noxss(`添加文件到剪贴板\n${id}`) info: (id) => antSword.noxss(`添加文件到剪贴板\n${id}`)
}, },
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const LANG_T = antSword['language']['toastr']; const LANG_T = antSword['language']['toastr'];
const LANG = antSword['language']['filemanager']['files']; const LANG = antSword['language']['filemanager']['files'];
const clipboard = require('electron').clipboard;
class Files { class Files {
...@@ -293,18 +294,41 @@ class Files { ...@@ -293,18 +294,41 @@ class Files {
manager.downloadFile(id, this.getRowAttribute(_ids[0], 'fsize')); manager.downloadFile(id, this.getRowAttribute(_ids[0], 'fsize'));
} }, } },
{ divider: true }, { divider: true },
{ text: LANG['grid']['contextmenu']['copy']['title'], icon: 'fa fa-copy', disabled: !id, action: () => { { text: LANG['grid']['contextmenu']['copy']['title'], icon: 'fa fa-copy', subMenu: [
// 如果只有一个id,则显示id名称,否则显示ids数量 { text: LANG['grid']['contextmenu']['copy']['title'], icon: 'fa fa-copy', disabled: !id, action: () => {
ids.map( (id) => { // 如果只有一个id,则显示id名称,否则显示ids数量
let path = manager.path + id; ids.map( (id) => {
// 判断是否已经复制 let path = manager.path + id;
if (id in self.Clipboard) { // 判断是否已经复制
return toastr.warning(LANG['grid']['contextmenu']['copy']['warning'](id), LANG_T['warning']); if (id in self.Clipboard) {
}; return toastr.warning(LANG['grid']['contextmenu']['copy']['warning'](id), LANG_T['warning']);
self.Clipboard[id] = path; };
toastr.info(LANG['grid']['contextmenu']['copy']['info'](id), LANG_T['info']); self.Clipboard[id] = path;
} ); 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']['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: () => { { 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')); 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