perf: add batch delete to menu item "more" in browser pane

This commit is contained in:
Lykin 2024-01-22 11:40:31 +08:00
parent c2c1e9cfba
commit ff2043c0e2
2 changed files with 20 additions and 3 deletions

View File

@ -72,8 +72,10 @@ const dbSelectOptions = computed(() => {
const moreOptions = [
{ key: 'import', label: 'interface.import_key', icon: Import },
{ key: 'divider1', type: 'divider' },
{ key: 'delete', label: 'interface.batch_delete_key', icon: Delete },
{ key: 'flush', label: 'interface.flush_db', icon: Delete },
{ key: 'divider', type: 'divider' },
{ key: 'divider2', type: 'divider' },
{ key: 'disconnect', label: 'interface.disconnect', icon: Unlink },
]
@ -230,6 +232,21 @@ const onSelectOptions = (select) => {
case 'import':
onImportData()
break
case 'delete':
let key = '*'
const selectedKey = get(browserTreeRef.value?.getSelectedKey(), 0)
if (selectedKey != null) {
const node = browserStore.getNode(selectedKey)
if (node != null) {
const { type = ConnectionType.RedisValue, redisKey } = node
if (type === ConnectionType.RedisKey) {
// has prefix
key = redisKey + browserStore.getSeparator(props.server) + '*'
}
}
}
dialogStore.openDeleteKeyDialog(props.server, props.db, key)
break
case 'flush':
onFlush()
break

View File

@ -183,9 +183,9 @@ const useDialogStore = defineStore('dialog', {
*
* @param {string} server
* @param {number} db
* @param {string|string[]} key
* @param {string|string[]} [key]
*/
openDeleteKeyDialog(server, db, key) {
openDeleteKeyDialog(server, db, key = '*') {
this.deleteKeyParam.server = server
this.deleteKeyParam.db = db
this.deleteKeyParam.key = key