Commit 6c6e0a9f authored by Medicean's avatar Medicean Committed by Medicean

(Enhance: Modules/ShellManager): 优化插件快捷设置,修正过多快捷设置后对UI影响(Fix #303)

parent fae7b691
...@@ -18,10 +18,11 @@ ...@@ -18,10 +18,11 @@
### 数据管理 ### 数据管理
* 优化了编辑 Shell 信息时,URL后缀发生改变后连动修改「连接类型」功能 * 优化了编辑 Shell 信息时,URL后缀发生改变后连动修改「连接类型」功能
* 优化插件快捷设置,修正过多快捷设置后对UI影响(Fix #303)
### 后端模块 ### 后端模块
* 支持自定义 Content-Type, 默认是 `form` * 支持自定义 Content-Type, 默认是 `form`
* Fix #307
### 设置模块 ### 设置模块
......
...@@ -205,10 +205,14 @@ module.exports = { ...@@ -205,10 +205,14 @@ module.exports = {
} }
}, },
toolbar: { toolbar: {
select: 'Please select at least one shell', select: 'Please select the WebShell to execute first',
setting: { setting: {
text: 'Setting', text: 'Setting',
title: 'Setting pligins which you want to show' pluginlist: 'Plugin List(Select up to 8)',
title: 'Set the plugins you want to add to the toolbar',
save: 'Save',
clear: 'Clear',
error_max: 'Up to 8 popular plugins can be added',
} }
} }
}, },
......
...@@ -205,10 +205,14 @@ module.exports = { ...@@ -205,10 +205,14 @@ module.exports = {
} }
}, },
toolbar: { toolbar: {
select: '至少选择一个 webshell 吧', select: '请先选中要执行的WebShell',
setting: { setting: {
text: '设置', text: '设置',
title: '设置你要添加到工具栏的插件' pluginlist: '插件列表(最多选8个)',
title: '设置你要添加到工具栏的插件',
save: '保存',
clear: '清空',
error_max: '最多可添加8个常用插件'
} }
} }
}, },
......
...@@ -204,10 +204,14 @@ module.exports = { ...@@ -204,10 +204,14 @@ module.exports = {
} }
}, },
toolbar: { toolbar: {
select: '至少選擇壹個 webshell 吧', select: '請先選中要執行的WebShell',
setting: { setting: {
text: '設置', text: '設置',
title: '設置妳要添加到工具欄的插件' pluginlist: '插件列表(最多選8個)',
title: '設置妳要添加到工具欄的插件',
save: '保存',
clear: '清空',
error_max: '最多可添加8個常用插件'
} }
} }
}, },
......
...@@ -204,10 +204,14 @@ module.exports = { ...@@ -204,10 +204,14 @@ module.exports = {
} }
}, },
toolbar: { toolbar: {
select: '至少選擇壹個 webshell 吧', select: '請先選中要執行的WebShell',
setting: { setting: {
text: '設置', text: '設置',
title: '設置妳要添加到工具欄的插件' pluginlist: '插件列表(最多選8個)',
title: '設置妳要添加到工具欄的插件',
save: '保存',
clear: '清空',
error_max: '最多可添加8個常用插件'
} }
} }
}, },
......
...@@ -13,13 +13,13 @@ class ShellManager { ...@@ -13,13 +13,13 @@ class ShellManager {
const tabbar = antSword['tabbar']; const tabbar = antSword['tabbar'];
tabbar.addTab('tab_shellmanager', '<i class="fa fa-th-large"></i>', null, null, true, false); tabbar.addTab('tab_shellmanager', '<i class="fa fa-th-large"></i>', null, null, true, false);
const cell = tabbar.cells('tab_shellmanager'); const cell = tabbar.cells('tab_shellmanager');
const layout = cell.attachLayout('3T'); const layout = cell.attachLayout('2U');
// 初始化顶侧栏:工具栏 - 插件 // 初始化顶侧栏:工具栏 - 插件
this.toolbar = new Toolbar(layout.cells('a'), this); this.toolbar = new Toolbar(layout, this);
// 初始化左侧栏:数据 // 初始化左侧栏:数据
this.list = new List(layout.cells('b'), this); this.list = new List(layout.cells('a'), this);
// 初始化右侧栏:目录 // 初始化右侧栏:目录
this.category = new Category(layout.cells('c'), this); this.category = new Category(layout.cells('b'), this);
this.searchPop = null; this.searchPop = null;
this.searchForm = null; this.searchForm = null;
...@@ -57,7 +57,7 @@ class ShellManager { ...@@ -57,7 +57,7 @@ class ShellManager {
try { try {
RegExp(sdata['searchtext']); RegExp(sdata['searchtext']);
} catch (e) { } catch (e) {
var tmpstr = sdata['searchtext'].replace(/([\$\(\)\*\+\.\[\?\\\^\{\|])/g, function ($, $1) { var tmpstr = sdata['searchtext'].replace(/([\$\(\)\*\+\.\[\?\\\^\{\|])/g, function($, $1) {
return `\\${$1}`; return `\\${$1}`;
}); });
sdata['searchtext'] = tmpstr; sdata['searchtext'] = tmpstr;
...@@ -170,7 +170,7 @@ class ShellManager { ...@@ -170,7 +170,7 @@ class ShellManager {
type: "input", type: "input",
name: "searchtext" name: "searchtext"
}]; }];
searchPop.attachEvent("onShow", function () { searchPop.attachEvent("onShow", function() {
if (that.searchForm == null) { if (that.searchForm == null) {
that.searchForm = searchPop.attachForm(formData); that.searchForm = searchPop.attachForm(formData);
// that.searchForm.attachEvent("onButtonClick", function(){ searchPop.hide(); // that.searchForm.attachEvent("onButtonClick", function(){ searchPop.hide();
......
...@@ -15,15 +15,18 @@ class Toolbar { ...@@ -15,15 +15,18 @@ class Toolbar {
constructor(cell, manager) { constructor(cell, manager) {
var self = this; var self = this;
cell.hideHeader(); self.max_shotcut_plugin = 8;
cell.setHeight(43);
// cell.hideHeader();
// cell.setHeight(43);
// cell.fixSize(1, 0);
let lang = antSword.storage('language', false, navigator.language.substr(0, 2)); let lang = antSword.storage('language', false, navigator.language.substr(0, 2));
this.lang = (lang == 'en') ? '_en' : ''; this.lang = (lang == 'en') ? '_en' : '';
// Create toolbar // Create toolbar
let toolbar = cell.attachToolbar(); let toolbar = cell.attachToolbar();
toolbar.setIconSize(32); // toolbar.setIconSize(24);
toolbar.attachEvent("onClick", function (id) { toolbar.attachEvent("onClick", function(id) {
console.log(id); console.log(id);
if (id == 'setting') { if (id == 'setting') {
self.settingPane(); self.settingPane();
...@@ -66,6 +69,7 @@ class Toolbar { ...@@ -66,6 +69,7 @@ class Toolbar {
var plugsData = []; var plugsData = [];
try { try {
var plugsList = JSON.parse(antSword.storage('toolbar', false, '[]')); var plugsList = JSON.parse(antSword.storage('toolbar', false, '[]'));
plugsList = plugsList.slice(0, this.max_shotcut_plugin);
plugsList.forEach((plug) => { plugsList.forEach((plug) => {
if (plug in antSword["plugins"]) { if (plug in antSword["plugins"]) {
p = antSword["plugins"][plug]["info"]; p = antSword["plugins"][plug]["info"];
...@@ -104,7 +108,7 @@ class Toolbar { ...@@ -104,7 +108,7 @@ class Toolbar {
let win = new WIN({ let win = new WIN({
title: LANG['setting']['text'], title: LANG['setting']['text'],
height: 450, height: 450,
width: 400 width: 300
}); });
let layout = win.win.attachLayout('1C'); let layout = win.win.attachLayout('1C');
let cell = layout.cells('a'); let cell = layout.cells('a');
...@@ -112,52 +116,73 @@ class Toolbar { ...@@ -112,52 +116,73 @@ class Toolbar {
let plugsForm = cell.attachForm(); let plugsForm = cell.attachForm();
var plugsData = []; var plugsData = [];
try { try {
var i = 1; var i = 0;
var plugs = JSON.parse(antSword.storage('toolbar', false, '[]')); var plugs = JSON.parse(antSword.storage('toolbar', false, '[]'));
for (let plug in antSword["plugins"]) { for (let plug in antSword["plugins"]) {
p = antSword["plugins"][plug]["info"]; p = antSword["plugins"][plug]["info"];
plugsData.push({ plugsData.push({
type: "checkbox", type: "checkbox",
label: antSword.noxss(p["name" + this.lang] || p["name"]), label: `<i class="fa fa-${antSword.noxss(p['icon'])}"></i> ${antSword.noxss(p["name" + this.lang] || p["name"])}`,
name: plug, name: plug,
checked: plugs.indexOf(plug) != -1 checked: plugs.indexOf(plug) != -1
}); });
plugsData.push({ // if (i % 2 == 1) {
type: 'newcolumn', // plugsData.push({
}); // type: 'newcolumn',
// });
// }
// i++;
} }
} catch (e) { } catch (e) {
toastr.error(e, LANG_T['error']); toastr.error(e, LANG_T['error']);
} }
plugsForm.loadStruct([{ plugsForm.loadStruct([{
type: "settings", type: "settings",
position: "label-right" position: "label-right",
labelLeft: 25,
inputLeft: 25
}, { }, {
type: "fieldset", type: "fieldset",
name: "Setting", name: "Setting",
label: LANG['setting']['text'], offsetLeft: 20,
label: LANG['setting']['pluginlist'],
list: plugsData list: plugsData
}, {
type: "button",
name: "toolbar_setting_save",
value: "Save",
width: 378
}]) }])
var eventId = plugsForm.attachEvent("onButtonClick", (name) => { const toolbar = cell.attachToolbar();
if (name == 'toolbar_setting_save') { toolbar.loadStruct([{
var save_data = [] type: "button",
id: "toolbar_setting_save",
text: LANG['setting']['save'],
icon: "save",
}, {
type: 'button',
id: 'toolbar_setting_clear',
text: LANG['setting']['clear'],
icon: 'remove'
}])
toolbar.attachEvent("onClick", (id) => {
switch (id) {
case 'toolbar_setting_save':
var save_data = [];
var _formvals = plugsForm.getValues(); var _formvals = plugsForm.getValues();
for (let v in _formvals) { for (let v in _formvals) {
if (_formvals[v]) if (_formvals[v])
save_data.push(v) save_data.push(v)
} }
if (save_data.length > this.max_shotcut_plugin) {
toastr.error(LANG['setting']['error_max'], LANG_T['error']);
return;
}
// Save and Reload Toolbar // Save and Reload Toolbar
antSword.storage('toolbar', save_data); antSword.storage('toolbar', save_data);
antSword.modules.shellmanager.toolbar.reloadToolbar() antSword.modules.shellmanager.toolbar.reloadToolbar()
win.close();
break;
case 'toolbar_setting_clear':
plugsForm.clear();
break;
} }
plugsForm.detachEvent(eventId);
win.close()
}); });
} }
......
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