Commit 80e82185 authored by Medicean's avatar Medicean Committed by Medicean

(Enhance: Settings/Encoder) 优化了新增 Core 类型时,编码设置模块解析的逻辑

parent 38ac1b04
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
* 支持自定义 Content-Type, 默认是 `form` * 支持自定义 Content-Type, 默认是 `form`
### 设置模块
* 优化了新增Core类型时,编码设置解析逻辑, 现在不需要再改该模块的源代码了
## 2021/07/25 `v(2.1.14)` ## 2021/07/25 `v(2.1.14)`
### 核心 ### 核心
......
...@@ -45,85 +45,44 @@ class Encoders { ...@@ -45,85 +45,44 @@ class Encoders {
icon: 'plus-circle', icon: 'plus-circle',
id: 'new', id: 'new',
openAll: true, openAll: true,
options: [{ options: ((items)=>{
id: 'new_asp', let ret = [];
items.map((_) => {
ret.push({
id: `new_${antSword.noxss(_.toLocaleLowerCase())}`,
icon: 'file-code-o', icon: 'file-code-o',
type: 'button', type: 'button',
text: "ASP" text: antSword.noxss(_.toUpperCase())
}, { });
id: 'new_aspx', });
icon: 'file-code-o', ret = ret.concat([{
type: 'button',
text: "ASPX"
}, {
id: 'new_php',
icon: 'file-code-o',
type: 'button',
text: "PHP"
}, {
id: 'new_jsp',
icon: 'file-code-o',
type: 'button',
text: "JSP"
}, {
id: 'new_jspjs',
icon: 'file-code-o',
type: 'button',
text: "JSPJS"
}, {
id: 'new_cmdlinux',
icon: 'file-code-o',
type: 'button',
text: "CMDLINUX"
}, {
type: 'separator'
}, {
id: 'new_custom',
icon: 'file-code-o',
type: 'button',
text: "Custom"
}, {
type: 'separator' type: 'separator'
}, { }, {
id: 'new_php_rsa', id: 'new_php_rsa',
icon: 'file-code-o', icon: 'file-code-o',
type: 'button', type: 'button',
text: "PHP RSA" text: "PHP RSA"
}] }]);
return ret;
})(antSword["core_types"]),
}, { }, {
type: 'buttonSelect', type: 'buttonSelect',
text: LANG['toolbar']['new_decoder'], text: LANG['toolbar']['new_decoder'],
icon: 'plus-circle', icon: 'plus-circle',
id: 'new_decoder', id: 'new_decoder',
openAll: true, openAll: true,
options: [{ options: ((items)=>{
id: 'new_php_decoder', let ret = [];
icon: 'file-code-o', items.map((_) => {
type: 'button', ret.push({
text: "PHP" id: `new_${antSword.noxss(_.toLocaleLowerCase())}_decoder`,
}, {
id: 'new_jsp_decoder',
icon: 'file-code-o', icon: 'file-code-o',
type: 'button', type: 'button',
text: "JSP" text: antSword.noxss(_.toUpperCase())
}, { });
id: 'new_jspjs_decoder', });
icon: 'file-code-o', return ret;
type: 'button', })(antSword["core_types"]),
text: "JSPJS"
}, {
id: 'new_cmdlinux_decoder',
icon: 'file-code-o',
type: 'button',
text: "CMDLINUX"
}, {
type: 'separator'
}, {
id: 'new_custom_decoder',
icon: 'file-code-o',
type: 'button',
text: "Custom"
}]
}, { }, {
type: 'separator' type: 'separator'
}, { }, {
...@@ -154,43 +113,6 @@ class Encoders { ...@@ -154,43 +113,6 @@ class Encoders {
toolbar.attachEvent("onClick", (id) => { toolbar.attachEvent("onClick", (id) => {
switch (id) { switch (id) {
case "new_asp":
that.createEncoder(id);
break;
case "new_aspx":
that.createEncoder(id);
break;
case "new_jsp":
that.createEncoder(id);
break;
case "new_jspjs":
that.createEncoder(id);
break;
case "new_cmdlinux":
that.createEncoder(id);
break;
case "new_php":
case "new_php_rsa":
that.createEncoder(id);
break;
case "new_custom":
that.createEncoder(id);
break;
case "new_php_decoder":
that.createEncoder(id, 'decoder');
break;
case "new_jsp_decoder":
that.createEncoder(id, 'decoder');
break;
case "new_jspjs_decoder":
that.createEncoder(id, 'decoder');
break;
case "new_cmdlinux_decoder":
that.createEncoder(id, 'decoder');
break;
case "new_custom_decoder":
that.createEncoder(id, 'decoder');
break;
case "edit": case "edit":
that.editEncoder(); that.editEncoder();
break; break;
...@@ -205,6 +127,13 @@ class Encoders { ...@@ -205,6 +127,13 @@ class Encoders {
.shell .shell
.openExternal("https://github.com/AntSwordProject/AwesomeEncoder"); .openExternal("https://github.com/AntSwordProject/AwesomeEncoder");
break; break;
default:
if(id.indexOf("decoder")>-1) {
that.createEncoder(id, 'decoder');
} else {
that.createEncoder(id);
}
break;
} }
}); });
...@@ -256,7 +185,7 @@ class Encoders { ...@@ -256,7 +185,7 @@ class Encoders {
break break
case 2: case 2:
// type // type
if (nValue != "asp" && nValue != "aspx" && nValue != "php" && nValue != "jsp"&& nValue != "jspjs"&& nValue != "cmdlinux"&&nValue != "custom") { if (antSword['core_types'].indexOf(nValue) == -1) {
toastr.error(LANG['message']["etype_error"], LANG_T['error']); toastr.error(LANG['message']["etype_error"], LANG_T['error']);
return return
} }
...@@ -264,10 +193,10 @@ class Encoders { ...@@ -264,10 +193,10 @@ class Encoders {
toastr.error(LANG['message']['ename_duplicate'], LANG_T['error']); toastr.error(LANG['message']['ename_duplicate'], LANG_T['error']);
return; return;
} }
if (oedtype === "decoder" && nValue != "php" && nValue != "custom") { // if (oedtype === "decoder" && nValue != "php" && nValue != "custom") {
toastr.error("Not Support", LANG_T["error"]); // toastr.error("Not Support", LANG_T["error"]);
return; // return;
} // }
fs.renameSync(oepath, path.join(remote.process.env.AS_WORKDIR, `antData/encoders/${nValue}/${oedtype}/${oename}.js`)); fs.renameSync(oepath, path.join(remote.process.env.AS_WORKDIR, `antData/encoders/${nValue}/${oedtype}/${oename}.js`));
toastr.success(LANG['message']["retype_success"], LANG_T["success"]); toastr.success(LANG['message']["retype_success"], LANG_T["success"]);
break break
......
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