Commit 51fb80ed authored by Medicean's avatar Medicean

(Enhance: FileManager) 编辑文件文件路径改为输入框, 现在可以手动输入文件路径后, 按 Enter 键快速打开文件了

parent 17d2ee41
......@@ -38,6 +38,10 @@ key2=val2
* 新建文件默认内容更改为 `#Halo AntSword!`
* 编辑文件文件路径改为输入框, 现在可以手动输入文件路径后, 按 Enter 键快速打开文件了
![file_manager_filepath.png](https://i.loli.net/2019/12/04/rtpJCafoDLSBsAi.png)
### 虚拟终端
* 新增 `asenv` 本地指令, 用于手动设置当前终端下的环境变量
......
......@@ -871,7 +871,7 @@ class FileManager {
let codes = '';
let win;
let hinttext = '';
let tooltip = `IP:${this.opts['ip']} File:${antSword.noxss(path)}`;
let tooltip = `IP:${this.opts['ip']} File:`;
if (openfileintab == false) {
win = this.createWin({
title: LANG['editor']['title'](antSword.noxss(path)),
......@@ -894,7 +894,7 @@ class FileManager {
tmpbuf.write(name, 100 - name.length);
hitpath = tmpbuf.toString();
}
hinttext = `IP:${this.opts['ip']} File:${antSword.noxss(hitpath)}`;
hinttext = `IP:${this.opts['ip']} File:`;
}
win.progressOn();
......@@ -952,6 +952,12 @@ class FileManager {
type: 'text',
text: hinttext
},
{
id: 'filepath',
type: 'buttonInput',
width: 500,
value: antSword.noxss(path),
},
{
type: 'separator'
},
......@@ -1040,6 +1046,18 @@ class FileManager {
})
).then((res) => {
win.progressOff();
name = path.substr(path.lastIndexOf('/') + 1);
if (openfileintab == false) {
win.setText(LANG['editor']['title'](antSword.noxss(path)));
} else {
win.setText(`<i class="fa fa-file-o"></i> ${antSword.noxss(name)}`);
}
ext = name.substr(name.lastIndexOf('.') + 1);
if (!(ext in ext_dict)) {
ext = 'txt'
};
toolbar.callEvent('onClick', [`mode_${ext_dict[ext]}`]);
let ret = antSword.unxss(res['text'], false);
codes = Buffer.from(antSword.unxss(res['buff'].toString(), false));
let encoding = res['encoding'] || this.opts['encode'];
......@@ -1056,6 +1074,14 @@ class FileManager {
console.info('toolbar.onClick', id);
}
});
toolbar.attachEvent('onEnter', (id, value) => {
switch (id) {
case 'filepath':
path = toolbar.getInput('filepath').value;
toolbar.callEvent('onClick', ['refresh']);
break;
}
});
// 获取文件代码
this.core.request(
......
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