Commit a2c15de9 authored by antoor's avatar antoor

Update the add-shell features

更新添加数据功能
parent ae97f7dd
...@@ -114,17 +114,19 @@ class Database { ...@@ -114,17 +114,19 @@ class Database {
addShell(event, opts) { addShell(event, opts) {
logger.info('addShell', opts); logger.info('addShell', opts);
this._url2ip(opts['url']) this._url2ip(opts.base['url'])
.then((ret) => { .then((ret) => {
this.cursor.insert({ this.cursor.insert({
category: opts['category'] || 'default', category: opts.base['category'] || 'default',
url: opts['url'], url: opts.base['url'],
pwd: opts['pwd'], pwd: opts.base['pwd'],
type: opts['type'], type: opts.base['type'],
ip: ret['ip'], ip: ret['ip'],
addr: ret['addr'], addr: ret['addr'],
encode: opts['encode'], encode: opts.base['encode'],
encoder: opts['encoder'], encoder: opts.base['encoder'],
httpConf: opts.http,
otherConf: opts.other,
ctime: +new Date, ctime: +new Date,
utime: +new Date utime: +new Date
}, (_err, _ret) => { }, (_err, _ret) => {
......
...@@ -188,7 +188,21 @@ class ContextMenu { ...@@ -188,7 +188,21 @@ class ContextMenu {
icon: 'plus-circle', icon: 'plus-circle',
text: LANG['list']['add']['toolbar']['add'] text: LANG['list']['add']['toolbar']['add']
}, {}, (data) => { }, {}, (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 { ...@@ -39,13 +39,22 @@ class Form {
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']); return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
}; };
// 回调数据 // 回调数据
callback ? callback( if (callback) {
this._parseFormData( win.progressOn();
callback(this._parseFormData(
this.baseForm.getValues(), this.baseForm.getValues(),
this.httpForm.getValues(), this.httpForm.getValues(),
this.otherForm.getValues() this.otherForm.getValues()
) )).then(() => {
) : null; // 添加/保存完毕后回调
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 { ...@@ -200,6 +209,7 @@ class Form {
let _baseData = { let _baseData = {
url: base['url'], url: base['url'],
pwd: base['pwd'], pwd: base['pwd'],
type: base['type'],
encode: base['encode'], encode: base['encode'],
encoder: base[`encoder_${base['type']}`] 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