Commit 2fc8967b authored by Medicean's avatar Medicean

(Enhance:FileManager) 编辑文件新增「刷新」按钮

parent c5caa683
......@@ -4,6 +4,12 @@
## `v(2.1.8)`
### 核心
* 修复全局过滤 xss 时 text 和 buff 过滤规则不一致问题
### 数据管理
* 新增「自定义数据分割符」配置
> 你可以将任何你喜欢的字符组合定义成数据的「起始符」或「结束符」
......@@ -12,6 +18,11 @@
![data_separtor_2.png](https://i.loli.net/2019/11/05/QECmJprI5FldB9b.png)
### 文件管理
* 编辑文件新增「刷新」按钮
> 如果服务器上的文件内容发生改变, 再也不需要关掉重打开了
## 2019/10/30 `v(2.1.7)`
......
......@@ -420,6 +420,7 @@ Hot Keys:
editor: {
title: (path) => antSword.noxss(`Edit: ${path}`),
toolbar: {
refresh: 'Refresh',
save: 'Save',
mode: 'Mode',
encode: 'Open with Encoding'
......
......@@ -420,6 +420,7 @@ module.exports = {
editor: {
title: (path) => `编辑: ${path}`,
toolbar: {
refresh: '刷新',
save: '保存',
mode: '高亮',
encode: '用此编码打开'
......
......@@ -419,6 +419,7 @@ module.exports = {
editor: {
title: (path) => `編輯: ${path}`,
toolbar: {
refresh: '刷新',
save: '保存',
mode: '高亮',
encode: '用此編碼打開'
......
......@@ -419,6 +419,7 @@ module.exports = {
editor: {
title: (path) => `編輯: ${path}`,
toolbar: {
refresh: '刷新',
save: '保存',
mode: '高亮',
encode: '用此編碼打開'
......
......@@ -440,7 +440,7 @@ class FileManager {
this.core.request(
this.core.filemanager.create_file({
path: this.path + value,
content: '#Halo ANT!'
content: '#Halo AntWord!'
})
).then((res) => {
let ret = res['text'];
......@@ -958,6 +958,12 @@ class FileManager {
{
type: 'spacer'
},
{
id: 'refresh',
type: 'button',
icon: 'refresh',
text: LANG['editor']['toolbar']['refresh']
},
{
id: 'save',
type: 'button',
......@@ -1004,7 +1010,7 @@ class FileManager {
self.core.request(
self.core.filemanager.create_file({
path: path,
content: editor.session.getValue() || 'Halo ANT!'
content: editor.session.getValue() || '#Halo AntWord!'
})
).then((res) => {
let ret = res['text'];
......@@ -1025,6 +1031,27 @@ class FileManager {
} else if (id.startsWith('encode_')) {
let encode = id.split('_')[1];
editor.session.setValue(iconv.decode(Buffer.from(codes), encode).toString());
} else if (id === 'refresh') {
// 获取文件代码
win.progressOn()
this.core.request(
this.core.filemanager.read_file({
path: path
})
).then((res) => {
win.progressOff();
let ret = antSword.unxss(res['text'], false);
codes = Buffer.from(antSword.unxss(res['buff'].toString(), false));
let encoding = res['encoding'] || this.opts['encode'];
if (encoding.toUpperCase() == "UTF-8") {
encoding = "UTF8";
}
toolbar.setListOptionSelected('encode', `encode_${encoding}`);
editor.session.setValue(ret);
}).catch((err) => {
toastr.error(LANG['editor']['loadErr'](err), LANG_T['error']);
win.progressOff()
})
} else {
console.info('toolbar.onClick', id);
}
......
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