Commit a2c15de9 authored by antoor's avatar antoor

Update the add-shell features

更新添加数据功能
parent ae97f7dd
......@@ -114,17 +114,19 @@ class Database {
addShell(event, opts) {
logger.info('addShell', opts);
this._url2ip(opts['url'])
this._url2ip(opts.base['url'])
.then((ret) => {
this.cursor.insert({
category: opts['category'] || 'default',
url: opts['url'],
pwd: opts['pwd'],
type: opts['type'],
category: opts.base['category'] || 'default',
url: opts.base['url'],
pwd: opts.base['pwd'],
type: opts.base['type'],
ip: ret['ip'],
addr: ret['addr'],
encode: opts['encode'],
encoder: opts['encoder'],
encode: opts.base['encode'],
encoder: opts.base['encoder'],
httpConf: opts.http,
otherConf: opts.other,
ctime: +new Date,
utime: +new Date
}, (_err, _ret) => {
......
......@@ -188,7 +188,21 @@ class ContextMenu {
icon: 'plus-circle',
text: LANG['list']['add']['toolbar']['add']
}, {}, (data) => {
console.log('addData', data);
return new Promise((res, rej) => {
// 获取当前分类
data['base']['category'] = antSword.modules.shellmanager.category.sidebar.getActiveItem();
// 通知后台插入数据
const ret = antSword.ipcRenderer.sendSync('shell-add', data);
if (ret instanceof Object) {
// 重新加载数据
antSword.modules.shellmanager.reloadData({
category: data['base']['category']
});
return res();
} else {
return rej(ret.totring());
}
});
})
}
......
......@@ -39,13 +39,22 @@ class Form {
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
};
// 回调数据
callback ? callback(
this._parseFormData(
if (callback) {
win.progressOn();
callback(this._parseFormData(
this.baseForm.getValues(),
this.httpForm.getValues(),
this.otherForm.getValues()
)
) : null;
)).then(() => {
// 添加/保存完毕后回调
win.close();
toastr.success(LANG['list']['add']['success'], LANG_T['success']);
}).catch((e) => {
// 添加/保存错误
win.progressOff();
toastr.error(LANG['list']['add']['error'](e.toString()), LANG_T['error']);
});
};
});
}
......@@ -200,6 +209,7 @@ class Form {
let _baseData = {
url: base['url'],
pwd: base['pwd'],
type: base['type'],
encode: base['encode'],
encoder: base[`encoder_${base['type']}`]
};
......
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