Commit 30f365a1 authored by Medicean's avatar Medicean

(Enhance: Settings) 默认设置新增「虚拟终端」缩放设置

parent 391433d3
......@@ -8,6 +8,19 @@
* 修复 PHP4 命令执行语法错误 #199 (thx @ier005)
### 系统设置
* 「默认设置」新增「虚拟终端」配置块, 可设置默认字体缩放比例, 最小0.5倍, 最大2倍 (通过快捷键最大可到5倍)
> 拖动 slider bar 之后, 下方可实时预览效果, 点击保存后即可生效(无需重启)
![adefault_terminal.png](https://i.loli.net/2019/08/05/fbKlUpodTuFMVC3.png)
### 虚拟终端
* 新增 `options['tsize']` 可覆盖全局缩放设置
* 支持全局缩放配置 #203
## 2019/07/16 `v(2.1.4)`
### 核心模块
......
{
"name": "antsword",
"version": "2.1.4.1",
"version": "2.1.4.2",
"description": "中国蚁剑是一款跨平台的开源网站管理工具",
"main": "app.js",
"dependencies": {
......
......@@ -938,6 +938,10 @@ Hot Keys:
nohttps: 'Ignore HTTPS certificate',
requestTimeout: 'Request timeout'
}
},
terminal: {
title: 'Terminal',
size: 'Scale'
}
}
},
......
......@@ -938,6 +938,10 @@ module.exports = {
nohttps: '忽略HTTPS证书',
requestTimeout: '请求超时'
}
},
terminal: {
title: '虚拟终端',
size: '缩放'
}
}
},
......
......@@ -936,6 +936,10 @@ module.exports = {
nohttps: '忽略HTTPS證書',
requestTimeout: '請求超時'
}
},
terminal: {
title: '虛擬終端',
size: '縮放'
}
}
},
......
......@@ -937,6 +937,10 @@ module.exports = {
nohttps: '忽略HTTPS證書',
requestTimeout: '請求超時'
}
},
terminal: {
title: '虛擬終端',
size: '縮放'
}
}
},
......
......@@ -29,6 +29,9 @@ class ADefault {
"ignore-https": 0,
"request-timeout": '10000'
}
},
terminal: {
tsize: 1,
}
};
// 读取配置
......@@ -55,6 +58,10 @@ class ADefault {
if (!this.shellmanager_settings.others) {
this.shellmanager_settings.others = default_config.shellmanager.others;
}
const terminal_settings = JSON.parse(antSword['storage']("adefault_terminal", false, JSON.stringify(default_config.terminal)));
this.terminal_settings = terminal_settings;
const toolbar = cell.attachToolbar();
toolbar.loadStruct([{
id: 'save',
......@@ -181,6 +188,31 @@ class ADefault {
}]
}]
},
{
type: 'fieldset',
label: `<i class="fa fa-terminal"></i> ${LANG['terminal']['title']}`,
list: [{
type: 'block',
list: [{
type: 'label',
name: 'terminal_size_label',
label: `${LANG['terminal']['size']} x${parseFloat(this.terminal_settings.tsize).toFixed(2)}`
}, {
type: 'newcolumn',
offset: 20
}, {
type: 'container',
name: 'terminal_size',
inputWidth: 300,
inputHeight: 30
}, {
type: 'container',
name: 'terminal_size_preview',
inputWidth: 600,
inputHeight: 200
}, ]
}]
},
// 后续其它模块
]
}], true);
......@@ -360,10 +392,13 @@ class ADefault {
config.shellmanager.bodys = self.shellmanager_settings.bodys;
config.shellmanager.others["ignore-https"] = _formvals['shellmanager_ignore-https'];
config.shellmanager.others["request-timeout"] = _formvals['shellmanager_request-timeout'];
config.terminal.tsize = self.terminal_settings.tsize;
// save save 文件管理设置
antSword['storage']('adefault_filemanager', config.filemanager);
antSword['storage']('adefault_database', config.database);
antSword['storage']('adefault_shellmanager', config.shellmanager);
antSword['storage']('adefault_terminal', config.terminal);
toastr.success(LANG['success'], LANG_T['success']);
// 重启应用
layer.confirm(LANG['confirm']['content'], {
......@@ -536,6 +571,37 @@ class ADefault {
shellmanager_bodys_grid.init();
this.shellmanager_bodys_grid = shellmanager_bodys_grid;
// Terminal 部分
// preview
form.getContainer('terminal_size_preview').innerHTML = `<div id="div_terminal_preview" style="height:100%;margin:0;padding:0 5px 1px 5px;overflow:scroll;--size:${this.terminal_settings.tsize};"></div>`;
let banner = `[[b;cyan;](*) Information]`;
banner += `\n[[b;#99A50D;]Path ]: [[;#C3C3C3;]/var/www/html]`;
banner += `\n[[b;#99A50D;]Driver]: [[;#C3C3C3;]/]`;
banner += `\n[[b;#99A50D;]System]: [[;#C3C3C3;]Linux 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64]`;
banner += `\n[[b;#99A50D;]User ]: [[;#C3C3C3;]www-data]`;
let terminal_size_preview = $("#div_terminal_preview");
let term = terminal_size_preview.terminal((cmd, ter) => {
ter.reset();
}, {
prompt: '([[b;#E80000;]www-data]:[[;#0F93D2;]/var/www/html]) $ ',
greetings: banner,
history: false,
});
// size slider
let terminal_size_slider = new dhtmlXSlider({
parent: form.getContainer('terminal_size'),
size: 300,
value: this.terminal_settings.tsize,
step: 0.05,
min: 0.5,
max: 2,
});
terminal_size_slider.attachEvent("onSlideEnd", (value) => {
this.terminal_settings.tsize = value;
form.setItemLabel('terminal_size_label', `${LANG['terminal']['size']} x${parseFloat(value).toFixed(2)}`);
term[0].style.setProperty('--size', value);
});
// grid右键
[bookmark_grid, db_bookmark_grid, shellmanager_headers_grid, shellmanager_bodys_grid].forEach((g) => {
// 空白数据右键fix
......
......@@ -25,15 +25,19 @@ class Terminal {
.focus() :
0;
});
let config = {
tsize: 1,
};
this.config = JSON.parse(antSword['storage']("adefault_terminal", false, JSON.stringify(config)));
// 初始化UI::cell
const cell = tabbar.cells(`tab_terminal_${hash}`);
cell.attachHTMLString(`
<div
id="div_terminal_${hash}"
style="height:100%;margin:0;padding:0 5px 1px 5px;overflow:scroll;--size:1;"
style="height:100%;margin:0;padding:0 5px 1px 5px;overflow:scroll;--size:${parseFloat(this.config.tsize)};"
></div>
`);
this.path = '';
this.opts = opts;
this.options = options || {};
......@@ -64,6 +68,9 @@ class Terminal {
if (this.options.hasOwnProperty("exec")) {
this.core.command.exec = this.options.exec;
}
if (this.options.hasOwnProperty("tsize")) {
this.term[0].style.setProperty("--size", parseFloat(this.options.size));
}
})
.catch((err) => {
toastr.error((typeof (err) === 'object') ?
......
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