Commit 900d18fd authored by Medicean's avatar Medicean

(Enhance:Modules:ShellManager)添加 Shell 时根据文件后缀选择 Shell 类型并赋予默认编码(asp 默认 GBK, 其它默认 UTF8)

parent ab6a1f51
......@@ -4,6 +4,13 @@
## `v(2.0.3-dev)`
### 模块增强
#### Shell 管理
* 添加 Shell 时 URL 默认前缀 `http://`
* 添加 Shell 时根据文件后缀选择 Shell 类型并赋予默认编码(asp 默认 GBK, 其它默认 UTF8) #109
### Core
#### 后端模块
......
......@@ -168,6 +168,47 @@ class Form {
}
] }
], true);
form.attachEvent('onChange', (_, id) => {
// 根据后缀自动修改 shell 类型
if(_ == "url") {
let file_match = {
"php": /.+\.ph(p[345]?|s|t|tml)/,
"aspx": /.+\.as(px|mx)/,
"asp": /.+\.(as(p|a|hx)|c(dx|er))/,
"custom": /.+\.((jsp[x]?)|cgi)/,
}
let typecombo = form.getCombo('type');
if(file_match.php.test(id) == true) {
typecombo.selectOption(typecombo.getOption('php').index);
}else if(file_match.aspx.test(id) == true){
typecombo.selectOption(typecombo.getOption('aspx').index);
}else if(file_match.asp.test(id) == true){
typecombo.selectOption(typecombo.getOption('asp').index);
}else if(file_match.custom.test(id) == true){
typecombo.selectOption(typecombo.getOption('custom').index);
}
}
// 默认编码设置
if(_ == "type") {
let encodecombo = form.getCombo('encode');
switch(id) {
case 'php':
encodecombo.selectOption(encodecombo.getOption('UTF8').index);
break;
case 'asp':
encodecombo.selectOption(encodecombo.getOption('GBK').index);
break;
case 'aspx':
encodecombo.selectOption(encodecombo.getOption('UTF8').index);
break;
case 'custom':
encodecombo.selectOption(encodecombo.getOption('UTF8').index);
break;
}
}
});
return form;
}
......
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