Commit b0256f69 authored by Medicean's avatar Medicean

(Enhance:FileManager)新增「在此处打开终端」功能, 打开终端后快速跳到当前目录下

parent 733136c4
......@@ -32,6 +32,7 @@
### 文件管理
* 新增「在此处打开终端」功能, 打开终端后快速跳到当前目录下
* 新增「全局书签」功能, 可在「系统设置-默认设置」单击鼠标右键添加
![](https://i.loli.net/2019/03/13/5c891b279c26a.png)
......
......@@ -348,7 +348,8 @@ module.exports = {
title: 'Create',
folder: 'Folder',
file: 'File'
}
},
terminal: 'Open Terminal Here'
}
}
},
......
......@@ -349,7 +349,8 @@ module.exports = {
title: '新建',
folder: '目录',
file: '文件'
}
},
terminal: '在此处打开终端'
}
}
},
......
......@@ -5,6 +5,7 @@
const LANG_T = antSword['language']['toastr'];
const LANG = antSword['language']['filemanager']['files'];
const clipboard = require('electron').clipboard;
const Terminal = require('../terminal/');
class Files {
......@@ -372,7 +373,10 @@ class Files {
{ text: LANG['grid']['contextmenu']['create']['title'], icon: 'fa fa-plus-circle', subMenu: [
{ text: LANG['grid']['contextmenu']['create']['folder'], icon: 'fa fa-folder-o', action: manager.createFolder.bind(manager) },
{ text: LANG['grid']['contextmenu']['create']['file'], icon: 'fa fa-file-o', action: manager.createFile.bind(manager) }
] }
] },
{ text: LANG['grid']['contextmenu']['terminal'], icon: 'fa fa-terminal', action: () => {
new Terminal(self.manager.opts, {'path': self.manager.path});
}}
];
bmenu(menu, event);
......
......@@ -9,7 +9,7 @@ const LANG_T = antSword['language']['toastr'];
class Terminal {
constructor(opts) {
constructor(opts, options={}) {
// 生存一个随机ID,用于标识多个窗口dom
const hash = String(Math.random()).substr(2, 10);
......@@ -35,6 +35,7 @@ class Terminal {
this.path = '';
this.opts = opts;
this.options = options || {};
this.hash = hash;
this.term = null;
this.cell = cell;
......@@ -47,6 +48,12 @@ class Terminal {
.getInformation()
.then((ret) => {
this.initTerminal(ret['info'], ret['dom']);
if(this.options.hasOwnProperty("path")) {
if(this.isWin && this.path.substr(0,1).toUpperCase() != this.options.path.substr(0,1).toUpperCase()) {
this.term.exec(`${this.options.path.substr(0,1).toUpperCase()}:`);
}
this.term.exec(`cd ${this.options.path}`);
}
})
.catch((err) => {
toastr.error((typeof(err) === 'object') ? JSON.stringify(err) : String(err), LANG_T['error']);
......
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