Commit 8cf22a02 authored by Medicean's avatar Medicean

(Enhance:ShellManager) 新增「搜索数据」功能, 搜索本地数据,范围为当前分类下的 Shell

parent 7bdc7b3b
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* 分块传输自动根据黑名单字符(eg: eval, assert, execute, response 等)进行随机切割(thx @phith0n) * 分块传输自动根据黑名单字符(eg: eval, assert, execute, response 等)进行随机切割(thx @phith0n)
### 数据管理 ### 数据管理
* 新增「测试连接」功能 * 新增「测试连接」功能
* 新增「检测」功能, 检测支持的数据库函数(目前仅 PHP,ASP,ASPX 有效, ASP(X)仅检测使用到的组件是否存在) * 新增「检测」功能, 检测支持的数据库函数(目前仅 PHP,ASP,ASPX 有效, ASP(X)仅检测使用到的组件是否存在)
...@@ -44,6 +44,21 @@ ...@@ -44,6 +44,21 @@
* shell 配置页面提示不推荐使用 default、random 编码器, 明文传输 Payload 容易受到转义等影响,未来版本将会考虑移除 * shell 配置页面提示不推荐使用 default、random 编码器, 明文传输 Payload 容易受到转义等影响,未来版本将会考虑移除
* 新增「创建副本」菜单, 复制所选择的 Shell 并在相同分类下创建一个副本 * 新增「创建副本」菜单, 复制所选择的 Shell 并在相同分类下创建一个副本
* 新增「搜索数据」功能, 搜索本地数据,范围为当前分类下的 Shell
可选搜索字段: URL(URL地址), Password(密码), Remark(备注), All(在以上几个字段中出现)
唤醒快捷键 Ctrl+Shift+F 或者 Command + Shift + F (OSX)
退出:
1) 点击搜索框之外的任何区域
2) 按下 `ESC`
3) 再次按下唤醒快捷键
> 在使用快捷键时,如果当前活动 tab 不是数据管理,则会自动跳回数据管理
### 其它 ### 其它
......
...@@ -48,6 +48,27 @@ class Database { ...@@ -48,6 +48,27 @@ class Database {
.on('shell-getPluginDataConf', this.getPluginDataConf.bind(this)); .on('shell-getPluginDataConf', this.getPluginDataConf.bind(this));
} }
convertOptstoNedbQuery(opts={}) {
var self = this;
if(opts instanceof Array) {
for (let i = 0; i < opts.length; i++) {
opts[i] = self.convertOptstoNedbQuery(opts[i]);
}
}else if(opts instanceof Object) {
Object.keys(opts).map((f) => {
if(opts[f] instanceof Object) {
opts[f] = self.convertOptstoNedbQuery(opts[f]);
}
if(f == "$regex") {
if(opts[f].charAt(0) == '*') {
opts[f] = opts[f].substring(1);
}
opts[f] = new RegExp(opts[f], 'i');
}
});
}
return opts;
}
/** /**
* 查询shell数据 * 查询shell数据
* @param {Object} event ipcMain对象 * @param {Object} event ipcMain对象
...@@ -55,6 +76,7 @@ class Database { ...@@ -55,6 +76,7 @@ class Database {
* @return {[type]} [description] * @return {[type]} [description]
*/ */
findShell(event, opts = {}) { findShell(event, opts = {}) {
opts = this.convertOptstoNedbQuery(opts);
logger.debug('findShell', opts); logger.debug('findShell', opts);
this.cursor this.cursor
.find(opts) .find(opts)
......
...@@ -109,6 +109,12 @@ class Menubar { ...@@ -109,6 +109,12 @@ class Menubar {
label: LANG['edit']['paste'], accelerator: 'CmdOrCtrl+V', role: 'paste' label: LANG['edit']['paste'], accelerator: 'CmdOrCtrl+V', role: 'paste'
}, { }, {
type: 'separator' type: 'separator'
}, {
label: LANG['edit']['search'],
accelerator: 'Shift+CmdOrCtrl+F',
click: event.sender.send.bind(event.sender, 'menubar', 'shellmanager-search')
}, {
type: 'separator'
}, { }, {
label: LANG['edit']['selectall'], accelerator: 'CmdOrCtrl+A', role: 'selectall' label: LANG['edit']['selectall'], accelerator: 'CmdOrCtrl+A', role: 'selectall'
} }
......
...@@ -28,7 +28,8 @@ module.exports = { ...@@ -28,7 +28,8 @@ module.exports = {
cut: 'Cut', cut: 'Cut',
copy: 'Copy', copy: 'Copy',
paste: 'Paste', paste: 'Paste',
selectall: 'SelectAll' selectall: 'SelectAll',
search: 'Search'
}, },
window: { window: {
title: 'Window', title: 'Window',
......
...@@ -29,7 +29,8 @@ module.exports = { ...@@ -29,7 +29,8 @@ module.exports = {
cut: '剪切', cut: '剪切',
copy: '复制', copy: '复制',
paste: '粘贴', paste: '粘贴',
selectall: '全选' selectall: '全选',
search: '查找数据'
}, },
window: { window: {
title: '窗口', title: '窗口',
......
...@@ -22,7 +22,20 @@ class ShellManager { ...@@ -22,7 +22,20 @@ class ShellManager {
// 初始化右侧栏:目录 // 初始化右侧栏:目录
this.category = new Category(layout.cells('b'), this); this.category = new Category(layout.cells('b'), this);
this.searchPop = null;
this.searchForm = null;
this.initSearchUI();
this.reloadData(); this.reloadData();
// 注册菜单事件
antSword['menubar'].reg('shellmanager-search', () => {
antSword.tabbar.tabs("tab_shellmanager").setActive();
if(this.searchPop.isVisible()) {
this.searchPop.hide();
}else{
this.searchPop.show(120, document.body.clientHeight, 100, 100);
}
});
} }
/** /**
...@@ -31,6 +44,25 @@ class ShellManager { ...@@ -31,6 +44,25 @@ class ShellManager {
* @return {[type]} [description] * @return {[type]} [description]
*/ */
reloadData(arg = {}) { reloadData(arg = {}) {
if(this.searchPop.isVisible()) {
let sdata = this.searchForm.getValues();
var searchObj = {};
switch(sdata['searchtype']) {
case 'all':
searchObj["$or"] = [
{ "url": { $regex: sdata['searchtext']} },
{ "pwd": { $regex: sdata['searchtext']} },
{ "note": { $regex: sdata['searchtext']} },
];
break;
default:
searchObj[sdata['searchtype']] = { $regex: sdata['searchtext']};
break;
}
// 获取当前分类
searchObj['category'] = this.category.sidebar.getActiveItem();
$.extend(arg, searchObj);
}
const _data = Data.get(arg); const _data = Data.get(arg);
// 刷新UI::数据 // 刷新UI::数据
this.list.grid.clearAll(); this.list.grid.clearAll();
...@@ -59,6 +91,45 @@ class ShellManager { ...@@ -59,6 +91,45 @@ class ShellManager {
this.category.updateHeader(); this.category.updateHeader();
this.list.updateHeader(_data['data'].length); this.list.updateHeader(_data['data'].length);
} }
initSearchUI() {
let that = this;
let searchPop = new dhtmlXPopup();
let formData = [
{type: "settings", position: "label-left", labelWidth: 80, inputWidth: 130},
{type: "combo", name: 'searchtype', options: [
{text: "All", value: "all", selected: true},
{text: "URL", value: "url" },
{text: "Password", value: "pwd" },
{text: "Remark", value: "note" },
]},
{type: 'newcolumn', offset:20},
{type: "input", name: "searchtext"},
];
searchPop.attachEvent("onShow", function(){
if (that.searchForm == null) {
that.searchForm = searchPop.attachForm(formData);
// that.searchForm.attachEvent("onButtonClick", function(){
// searchPop.hide();
// });
that.searchForm.attachEvent("onInputChange", (name, value, form) => {
if(name == "searchtext") {
that.reloadData({});
}
});
}
// 去掉 popup 的角
var poparrows = document.getElementsByClassName('dhx_popup_arrow dhx_popup_arrow_top');
if (poparrows.length > 0 && poparrows[0].style.display != "none") {
poparrows[0].style.display="none";
}
that.searchForm.setItemFocus("searchtext");
});
// searchPop.attachEvent("onBeforeHide", function(type, ev, id){
// return false;
// });
that.searchPop = searchPop;
}
} }
module.exports = ShellManager; module.exports = ShellManager;
...@@ -51,7 +51,7 @@ class ContextMenu { ...@@ -51,7 +51,7 @@ class ContextMenu {
false, false,
['move', 'share-square', selectedMultiData, null, this.parseMoveCategoryMenu(ids)], ['move', 'share-square', selectedMultiData, null, this.parseMoveCategoryMenu(ids)],
['copy', 'copy', selectedData, this.copyData.bind(this, data[0])], ['copy', 'copy', selectedData, this.copyData.bind(this, data[0])],
['search', 'search', true], ['search', 'search', false, this.searchData.bind(this, event)],
false, false,
['clearCache', 'trash-o', selectedData, this.clearCache.bind(this, id)], ['clearCache', 'trash-o', selectedData, this.clearCache.bind(this, id)],
['clearAllCache', 'trash', false, this.clearAllCache.bind(this)] ['clearAllCache', 'trash', false, this.clearAllCache.bind(this)]
...@@ -301,8 +301,8 @@ class ContextMenu { ...@@ -301,8 +301,8 @@ class ContextMenu {
* 搜索数据 * 搜索数据
* @return {[type]} [description] * @return {[type]} [description]
*/ */
searchData() { searchData(event) {
antSword.modules.shellmanager.searchPop.show(120, document.body.clientHeight, 100, 100);
} }
/** /**
......
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