修正macOS助手有时无法保存配置的问题;暂时移除telnet的支持。

pull/130/head
Apex Liu 2018-11-14 00:45:25 +08:00
parent 93a1b8259c
commit 1d35922f7a
10 changed files with 133 additions and 122 deletions

View File

@ -6,16 +6,16 @@
{
"name":"terminal",
"display": "终端(系统自带)",
"app": "Terminal.app",
"app": "",
"cmdline": "Basic",
"desc": []
"desc": ["命令参数为终端偏好设置中描述文件的名称"]
},
{
"name": "iterm2",
"display": "iTerm2",
"app": "iTerm2.app",
"app": "",
"cmdline": "Default",
"desc": []
"desc": ["命令参数为iTerm偏好设置中描述文件的名称"]
},
{
"name": "securecrt",
@ -62,20 +62,20 @@
"display": "终端(系统自带)",
"app": "Terminal.app",
"cmdline": "Basic",
"desc": []
"desc": ["命令参数为终端偏好设置中描述文件的名称"]
},
{
"name": "iterm2",
"display": "iTerm2",
"app": "iTerm2.app",
"cmdline": "Default",
"desc": []
"desc": ["命令参数为iTerm偏好设置中描述文件的名称"]
},
{
"name": "securecrt",
"display": "SecureCRT",
"app": "SecureCRT.app",
"cmdline": "/T /N \"TP#ssh://{real_ip}\" /SSH2 /P {host_port} /PASSWORD **** {user_name}@{host_ip}",
"cmdline": "/T /N \"TP#telnet://{real_ip}\" /TELNET {user_name}@{host_ip} {host_port}",
"desc": []
},
{

View File

@ -1 +1 @@
@charset "utf-8";body{font-family:"Microsoft YaHei","微软雅黑",Helvetica,Arial,sans-serif;font-size:13px;background-color:#fff;color:#333}html,body{height:100%}.header{width:100%;height:48px;position:fixed;top:0;line-height:48px;background-color:#3b3b3b;color:#fff;z-index:999}.header .title{font-size:16px}.header .sub-title{margin-left:30px;color:#acacac}.header-fix{height:48px}.footer{width:100%;height:24px;position:fixed;bottom:0;text-align:center;line-height:24px;background-color:#d5d5d5;border-top:1px solid #a2a2a2;z-index:999}.content{margin:20px 0 50px 0}.content .cfg-title{font-size:16px;font-weight:bold}.content .form-group{margin-bottom:5px}.content .col-sm-1,.content .col-sm-2,.content .col-sm-3,.content .col-sm-4,.content .col-sm-5,.content .col-sm-6,.content .col-sm-7,.content .col-sm-8,.content .col-sm-9,.content .col-sm-10,.content .col-sm-11{padding-left:3px;padding-right:3px}.content .arg-detail ol,.content .arg-detail ul{margin-bottom:0}.content .arg-detail-common{background-color:#dbffbe;border-radius:5px;padding:15px}.content .input-args{font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace}.arg-varb{color:#0a6aa1;font-weight:bold;font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace;display:inline-block;width:164px}#gritter-notice-wrapper{z-index:9999}.gritter-bottom,.gritter-item,.gritter-top{background:rgba(0,0,0,0.8) !important}.gritter-top{border-top-left-radius:3px;border-top-right-radius:3px}.gritter-bottom{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.gritter-close,.gritter-light .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%}.gritter-close:before,.gritter-light .gritter-close:before{content:'\f00d' !important;font-family:FontAwesome !important;font-size:9px !important;width:16px !important;height:16px !important;line-height:16px !important;color:#fff !important;text-indent:0 !important;position:absolute !important;text-align:center !important;right:0 !important;top:0 !important}.gritter-title{font-size:13px !important;line-height:16px !important;padding-bottom:5px !important;font-weight:400 !important;color:#fff !important;text-shadow:none !important}.gritter-item{color:#aaa !important;font-size:13px !important;padding:2px 15px 5px !important}.gritter-error .gritter-bottom,.gritter-error .gritter-item,.gritter-error .gritter-top{background:rgba(123,32,32,0.9) !important}.gritter-error .gritter-title{color:#fff !important}.gritter-error .gritter-item{color:#ddd !important}.gritter-error .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%;background:#e33b3b !important}.gritter-success .gritter-bottom,.gritter-success .gritter-item,.gritter-success .gritter-top{background:rgba(1,65,16,0.9) !important}.gritter-success .gritter-title{color:#ddd !important}.gritter-success .gritter-item{color:#ccc !important}.gritter-success .gritter-close{background:#0eb320 !important}#gritter-notice-wrapper{width:320px;max-width:480px}/*# sourceMappingURL=style.css.map */
@charset "utf-8";body{font-family:"Microsoft YaHei","微软雅黑",Helvetica,Arial,sans-serif;font-size:13px;background-color:#fff;color:#333}html,body{height:100%}.header{width:100%;height:48px;position:fixed;top:0;line-height:48px;background-color:#3b3b3b;color:#fff;z-index:999}.header .title{font-size:16px}.header .sub-title{margin-left:30px;color:#acacac}.header-fix{height:48px}.footer{width:100%;height:24px;position:fixed;bottom:0;text-align:center;line-height:24px;background-color:#d5d5d5;border-top:1px solid #a2a2a2;z-index:999}.content{margin:20px 0 50px 0}.content .cfg-title{font-size:16px;font-weight:bold}.content .form-group{margin-bottom:5px}.content .col-sm-1,.content .col-sm-2,.content .col-sm-3,.content .col-sm-4,.content .col-sm-5,.content .col-sm-6,.content .col-sm-7,.content .col-sm-8,.content .col-sm-9,.content .col-sm-10,.content .col-sm-11{padding-left:3px;padding-right:3px}.content .arg-detail ol,.content .arg-detail ul{margin-bottom:0}.content .arg-detail-common{background-color:#dbffbe;border-radius:5px;padding:15px}.content .input-args{font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace}.content .desc{margin-top:5px;color:#6b6b6b}.arg-varb{color:#0a6aa1;font-weight:bold;font-family:Consolas,Lucida Console,Monaco,Courier,'Courier New',monospace;display:inline-block;width:164px}#gritter-notice-wrapper{z-index:9999}.gritter-bottom,.gritter-item,.gritter-top{background:rgba(0,0,0,0.8) !important}.gritter-top{border-top-left-radius:3px;border-top-right-radius:3px}.gritter-bottom{border-bottom-left-radius:3px;border-bottom-right-radius:3px}.gritter-close,.gritter-light .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%}.gritter-close:before,.gritter-light .gritter-close:before{content:'\f00d' !important;font-family:FontAwesome !important;font-size:9px !important;width:16px !important;height:16px !important;line-height:16px !important;color:#fff !important;text-indent:0 !important;position:absolute !important;text-align:center !important;right:0 !important;top:0 !important}.gritter-title{font-size:13px !important;line-height:16px !important;padding-bottom:5px !important;font-weight:400 !important;color:#fff !important;text-shadow:none !important}.gritter-item{color:#aaa !important;font-size:13px !important;padding:2px 15px 5px !important}.gritter-error .gritter-bottom,.gritter-error .gritter-item,.gritter-error .gritter-top{background:rgba(123,32,32,0.9) !important}.gritter-error .gritter-title{color:#fff !important}.gritter-error .gritter-item{color:#ddd !important}.gritter-error .gritter-close{left:auto !important;right:5px !important;top:5px !important;width:16px !important;height:16px !important;line-height:16px !important;display:block !important;border-radius:50%;background:#e33b3b !important}.gritter-success .gritter-bottom,.gritter-success .gritter-item,.gritter-success .gritter-top{background:rgba(1,65,16,0.9) !important}.gritter-success .gritter-title{color:#ddd !important}.gritter-success .gritter-item{color:#ccc !important}.gritter-success .gritter-close{background:#0eb320 !important}#gritter-notice-wrapper{width:320px;max-width:480px}

View File

@ -69,10 +69,6 @@
<label for="ssh-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<input id="ssh-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径">
<!-- <div class="input-group">-->
<!-- <input id="ssh-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径">-->
<!-- <span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="ssh-select-app">选择...</button></span>-->
<!-- </div>-->
</div>
</div>
@ -80,6 +76,7 @@
<label for="ssh-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="ssh-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
<div id="ssh-desc"></div>
</div>
</div>
</div>
@ -99,10 +96,7 @@
<div class="form-group form-group-sm">
<label for="sftp-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="sftp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="sftp-select-app">选择...</button></span>
</div>
<input id="sftp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径">
</div>
</div>
@ -110,58 +104,45 @@
<label for="sftp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="sftp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
<div id="sftp-desc"></div>
</div>
</div>
</div>
<hr/>
<p class="cfg-title">本地 TELNET 客户端配置</p>
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="telnet-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
<div class="col-sm-4">
<select id="telnet-type" class="form-control"></select>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="telnet-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="telnet-select-app">选择...</button></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<label for="telnet-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="telnet-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
</div>
</div>
</div>
<!-- <hr/>-->
<!-- <p class="cfg-title">本地 TELNET 客户端配置</p>-->
<!---->
<!-- <div class="form-horizontal">-->
<!-- <div class="form-group form-group-sm">-->
<!-- <label for="telnet-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>-->
<!-- <div class="col-sm-4">-->
<!-- <select id="telnet-type" class="form-control"></select>-->
<!-- </div>-->
<!-- </div>-->
<!---->
<!-- <div class="form-group form-group-sm">-->
<!-- <label for="telnet-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>-->
<!-- <div class="col-sm-9">-->
<!-- <input id="telnet-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径">-->
<!-- </div>-->
<!-- </div>-->
<!---->
<!-- <div class="form-group form-group-sm">-->
<!-- <label for="telnet-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>-->
<!-- <div class="col-sm-9">-->
<!-- <input id="telnet-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />-->
<!--<div id="telnet-desc"></div>-->
<!-- </div>-->
<!-- </div>-->
<!---->
<!-- </div>-->
<hr/>
<p class="cfg-title">本地 RDP 客户端配置</p>
<!--<div class="arg-detail arg-detail-common">-->
<!--RDP专用命令行参数-->
<!--<ul>-->
<!--<li><span class="arg-varb">{tmp_rdp_file}</span> 替换为助手工具生成的临时配置文件(.rdp的绝对路径用于支持按.rdp配置文件进行连接的RDP客户端</li>-->
<!--<li><span class="arg-varb">{size}</span> [仅FreeRDP] 替换为屏幕尺寸</li>-->
<!--<li><span class="arg-varb">{console}</span> [仅FreeRDP] 替换为是否以Console模式连接</li>-->
<!--<li><span class="arg-varb">{clipboard}</span> [仅FreeRDP] 替换为是否允许剪贴板</li>-->
<!--<li><span class="arg-varb">{drives}</span> [仅FreeRDP] 替换为是否允许映射本地磁盘</li>-->
<!--</ul>-->
<!--</div>-->
<div class="form-horizontal">
<div class="form-group form-group-sm">
<label for="ssh-type" class="col-sm-2 control-label"><strong>客户端:</strong></label>
@ -173,10 +154,7 @@
<div class="form-group form-group-sm">
<label for="ssh-app" class="col-sm-2 control-label"><strong>程序路径:</strong></label>
<div class="col-sm-9">
<div class="input-group">
<input id="rdp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径" readonly="readonly">
<span class="input-group-btn"><button class="btn btn-sm btn-primary" type="button" id="rdp-select-app">选择...</button></span>
</div>
<input id="rdp-app" type="text" class="form-control input-args" placeholder="客户端可执行程序文件路径">
</div>
</div>
@ -184,6 +162,9 @@
<label for="rdp-cmdline" class="col-sm-2 control-label"><strong>命令参数:</strong></label>
<div class="col-sm-9">
<input id="rdp-cmdline" type="text" class="form-control input-args" placeholder="客户端启动所需命令行参数" />
<div id="rdp-desc"></div>
<!-- <div class="desc"><i class="fa fa-info-circle"></i> 建议使用homebrew安装freerdp安装后freerdp默认路径在/usr/local/Cellar/freerdp/x.y.z/bin/xfreerdp</div>-->
<!-- <div class="desc"><i class="fa fa-info-circle"></i> 首次安装freerdp后需要重新启动计算机</div>-->
</div>
</div>
</div>

View File

@ -10,22 +10,23 @@ var dom = {
ssh_type: $('#ssh-type'),
ssh_app: $('#ssh-app'),
ssh_cmdline: $('#ssh-cmdline'),
ssh_select_app: $('#ssh-select-app'),
ssh_desc: $('#ssh-desc'),
sftp_type: $('#sftp-type'),
sftp_app: $('#sftp-app'),
sftp_cmdline: $('#sftp-cmdline'),
sftp_select_app: $('#sftp-select-app'),
sftp_desc: $('#sftp-desc'),
telnet_type: $('#telnet-type'),
telnet_app: $('#telnet-app'),
telnet_cmdline: $('#telnet-cmdline'),
telnet_select_app: $('#telnet-select-app'),
telnet_desc: $('#telnet-desc'),
rdp_type: $('#rdp-type'),
rdp_app: $('#rdp-app'),
rdp_cmdline: $('#rdp-cmdline'),
rdp_select_app: $('#rdp-select-app'),
rdp_desc: $('#rdp-desc'),
btn_save: $('#btn-save')
};
@ -107,6 +108,8 @@ function update_dom() {
dom.ssh_type.val(selected);
dom.ssh_app.val(app);
dom.ssh_cmdline.val(cmdline);
$(dom.ssh_type).trigger('change');
}
}
@ -139,6 +142,8 @@ function update_dom() {
dom.sftp_type.val(selected);
dom.sftp_app.val(app);
dom.sftp_cmdline.val(cmdline);
$(dom.sftp_type).trigger('change');
}
}
@ -172,6 +177,8 @@ function update_dom() {
dom.telnet_type.val(selected);
dom.telnet_app.val(app);
dom.telnet_cmdline.val(cmdline);
$(dom.telnet_type).trigger('change');
}
}
@ -205,6 +212,8 @@ function update_dom() {
dom.rdp_type.val(selected);
dom.rdp_app.val(app);
dom.rdp_cmdline.val(cmdline);
$(dom.rdp_type).trigger('change');
}
}
}
@ -230,14 +239,14 @@ function on_save() {
break;
}
}
for (i = 0; i < g_cfg.telnet.available.length; i++) {
var item = g_cfg.telnet.available[i];
if (item.name === g_cfg.telnet.selected) {
item.app = dom.telnet_app.val();
item.cmdline = dom.telnet_cmdline.val();
break;
}
}
// for (i = 0; i < g_cfg.telnet.available.length; i++) {
// var item = g_cfg.telnet.available[i];
// if (item.name === g_cfg.telnet.selected) {
// item.app = dom.telnet_app.val();
// item.cmdline = dom.telnet_cmdline.val();
// break;
// }
// }
for (i = 0; i < g_cfg.rdp.available.length; i++) {
var item = g_cfg.rdp.available[i];
if (item.name === g_cfg.rdp.selected) {
@ -319,8 +328,6 @@ function notify_success(message_, title_) {
$(document).ready(function () {
get_version();
get_config();
dom.ssh_type.change(function () {
g_cfg.ssh.selected = dom.ssh_type.val();
for (var i = 0; i < g_cfg.ssh.available.length; i++) {
@ -328,22 +335,19 @@ $(document).ready(function () {
if (item.name === g_cfg.ssh.selected) {
dom.ssh_app.val(item.app);
dom.ssh_cmdline.val(item.cmdline);
var html = [];
for(var j = 0; j < item.desc.length; j++) {
html.push('<div class="desc"><i class="fa fa-info-circle"></i> ' + item.desc[j] + '</div>');
}
dom.ssh_desc.html(html.join(''));
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.ssh_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.ssh_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.sftp_type.change(function () {
g_cfg.sftp.selected = dom.sftp_type.val();
for (var i = 0; i < g_cfg.sftp.available.length; i++) {
@ -351,20 +355,17 @@ $(document).ready(function () {
if (item.name === g_cfg.sftp.selected) {
dom.sftp_app.val(item.app);
dom.sftp_cmdline.val(item.cmdline);
var html = [];
for(var j = 0; j < item.desc.length; j++) {
html.push('<div class="desc"><i class="fa fa-info-circle"></i> ' + item.desc[j] + '</div>');
}
dom.sftp_desc.html(html.join(''));
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.sftp_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.sftp_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.telnet_type.change(function () {
@ -374,20 +375,17 @@ $(document).ready(function () {
if (item.name === g_cfg.telnet.selected) {
dom.telnet_app.val(item.app);
dom.telnet_cmdline.val(item.cmdline);
var html = [];
for(var j = 0; j < item.desc.length; j++) {
html.push('<div class="desc"><i class="fa fa-info-circle"></i> ' + item.desc[j] + '</div>');
}
dom.telnet_desc.html(html.join(''));
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.telnet_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.telnet_app.val(path);
} else {
console.log("can not select file.");
}
});
});
dom.rdp_type.change(function () {
@ -397,23 +395,23 @@ $(document).ready(function () {
if (item.name === g_cfg.rdp.selected) {
dom.rdp_app.val(item.app);
dom.rdp_cmdline.val(item.cmdline);
var html = [];
for(var j = 0; j < item.desc.length; j++) {
html.push('<div class="desc"><i class="fa fa-info-circle"></i> ' + item.desc[j] + '</div>');
}
dom.rdp_desc.html(html.join(''));
return;
}
}
notify_error('所选的配置项不存在!');
});
dom.rdp_select_app.click(function () {
select_local_file(function (code, path) {
if (code == 0) {
dom.rdp_app.val(path);
} else {
console.log("can not select file.");
}
});
});
get_config();
dom.btn_save.click(function () {
on_save();
});
});
});

View File

@ -98,6 +98,12 @@ html, body {
.input-args {
font-family: @font-family-mono;
}
.desc {
// display:inline-block;
margin-top:5px;
color:rgb(107, 107, 107);
}
}
.arg-varb {

View File

@ -100,15 +100,13 @@ bool TsCfg::_parse_app(const Json::Value& m_root, const ex_astr& str_app, APP_CO
cfg.cmdline = jAppList[i]["cmdline"].asCString();
if(jAppList[i]["desc"].size() > 0) {
// cfg.description = jApp["available"][i]["app"].asCString();
const Json::Value& jAppDescList = jAppList[i]["desc"];
int j = 0;
for(j = 0; j < jAppDescList.size(); ++j) {
if(!jAppDescList[i].isString())
if(!jAppDescList[j].isString())
return false;
cfg.description.push_back(jAppDescList[i].asCString());
cfg.description.push_back(jAppDescList[j].asCString());
}
}
@ -139,8 +137,8 @@ bool TsCfg::_load(const ex_astr& str_json) {
return false;
if(!_parse_app(m_root, "sftp", sftp))
return false;
if(!_parse_app(m_root, "telnet", telnet))
return false;
// if(!_parse_app(m_root, "telnet", telnet))
// return false;
if(!_parse_app(m_root, "rdp", rdp))
return false;

View File

@ -687,9 +687,34 @@ void TsHttpRpc::_rpc_func_run_client(const ex_astr& func_args, ex_astr& buf)
//==============================================
// sorry, TELNET not supported yet for macOS.
_create_json_ret(buf, TPE_NOT_IMPLEMENT);
return;
}
_create_json_ret(buf, TPE_NOT_IMPLEMENT);
return;
// if(g_cfg.telnet.name == "terminal" || g_cfg.telnet.name == "iterm2") {
// char szCmd[1024] = {0};
// ex_strformat(szCmd, 1023, "telnet -l %s %s %d", sid.c_str(), teleport_ip.c_str(), teleport_port);
//
// char szTitle[128] = {0};
// ex_strformat(szTitle, 127, "TP#%s", real_host_ip.c_str());
//
// int ret = AppDelegate_start_ssh_client(g_app, szCmd, g_cfg.telnet.name.c_str(), g_cfg.telnet.cmdline.c_str(), szTitle);
// if(ret == 0)
// _create_json_ret(buf, TPE_OK);
// else
// _create_json_ret(buf, TPE_FAILED);
// return;
// }
//
// if(g_cfg.telnet.application.length() == 0) {
// _create_json_ret(buf, TPE_NOT_EXISTS);
// return;
// }
//
// s_exec = g_cfg.telnet.application;
// s_argv.push_back(s_exec.c_str());
//
// s_arg = g_cfg.telnet.cmdline;
}
//---- split s_arg and push to s_argv ---

View File

@ -262,6 +262,9 @@ function tp_error_msg(error_code, message) {
case TPE_PRIVILEGE:
msg = '没有此操作权限';
break;
case TPE_NOT_IMPLEMENT:
msg = '功能尚未实现';
break;
case TPE_EXISTS:
msg = '已经存在';
break;