Commit f0873342 authored by Antoor's avatar Antoor Committed by GitHub

Merge pull request #72 from antoor/v2.0-beta-terminal-setp

v2.0-beta::terminal custom execPath
parents 79e2e989 b6f1cb42
......@@ -155,7 +155,9 @@ module.exports = {
},
otherConf: {
nohttps: 'Ignore HTTPS certificate',
terminalCache: "Use the terminal's cache"
terminalCache: "Use the terminal's cache",
requestTimeout: 'Request timeout',
commandPath: 'Custom terminal-execPath'
}
}
},
......
......@@ -156,7 +156,9 @@ module.exports = {
},
otherConf: {
nohttps: '忽略HTTPS证书',
terminalCache: "虚拟终端使用缓存"
terminalCache: '虚拟终端使用缓存',
requestTimeout: '请求超时',
commandPath: '自定义终端执行路径'
}
}
},
......
......@@ -271,7 +271,8 @@ class Form {
const opt = Object.assign({}, {
'ignore-https': 0,
'terminal-cache': 0,
'request-timeout': '10000'
'request-timeout': '10000',
'command-path': ''
}, arg.otherConf);
const form = this.accordion.cells('other').attachForm([{
type: 'settings', position: 'label-right', inputWidth: 400
......@@ -284,19 +285,48 @@ class Form {
type: "checkbox", name: 'terminal-cache', label: LANG['list']['otherConf']['terminalCache'],
checked: opt['terminal-cache'] === 1
}, {
type: "label", label: '请求超时'
type: "label", label: LANG['list']['otherConf']['requestTimeout']
}, {
type: "combo", label: '/ms', inputWidth: 100, name: "request-timeout", readonly: true, options: [
{
text: "5000", value: "5000", selected: opt['request-timeout'] === '5000'
}, {
text: "10000", value: "10000", selected: opt['request-timeout'] === '10000'
}, {
text: "30000", value: "30000", selected: opt['request-timeout'] === '30000'
}, {
text: "60000", value: "60000", selected: opt['request-timeout'] === '60000'
}
]},
type: "combo", label: '/ms', inputWidth: 100, name: "request-timeout",
options: ((items) => {
let ret = [];
// 如果自定义的路径不在items里,则++
if (items.indexOf(opt['request-timeout']) === -1) {
items.unshift(opt['request-timeout']);
}
items.map((_) => {
ret.push({
text: _,
value: _,
selected: opt['command-path'] === _
})
});
return ret;
})([
'5000', '10000', '30000', '60000'
])
}, {
type: 'label', label: LANG['list']['otherConf']['commandPath']
}, {
type: 'combo', name: 'command-path', inputWidth: 200, options: ((items) => {
let ret = [];
// 如果自定义的路径不在items里,则++
if (items.indexOf(opt['command-path']) === -1) {
items.unshift(opt['command-path']);
}
items.map((_) => {
ret.push({
text: _,
value: _,
selected: opt['command-path'] === _
})
});
return ret;
})([
'/bin/sh',
'cmd'
])
}
]}], true);
return form;
}
......
......@@ -134,7 +134,7 @@ class Terminal {
if (!cmd) { return false };
// 如果为exit||quit则关闭窗口
if (cmd === 'exit' || cmd === 'quit') { return this.cell.close() };
term.pause();
// term.pause();
// 是否有缓存
let cacheTag = 'command-' + new Buffer(this.path + cmd).toString('base64');
let cacheCmd = this.cache.get(cacheTag);
......@@ -146,11 +146,15 @@ class Terminal {
);
return term.resume();
};
// 获取自定义执行路径
let _bin = this.isWin ? 'cmd' : '/bin/sh';
let _confBin = (this.opts['otherConf'] || {})['command-path'];
_bin = _confBin || _bin;
// 开始执行命令
this.core.request(
this.core.command.exec({
cmd: this.parseCmd(cmd, this.path),
bin: this.isWin ? 'cmd' : '/bin/sh'
bin: _bin
})
).then((ret) => {
let _ = ret['text'];
......
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