fix: db0 was not clean after reopen connection

This commit is contained in:
tiny-craft 2023-07-24 16:16:09 +08:00
parent d7dc40d6e2
commit 9dd9b208cf
4 changed files with 18 additions and 7 deletions

View File

@ -119,6 +119,15 @@ const menuOptions = {
label: i18n.t('filter_key'), label: i18n.t('filter_key'),
icon: renderIcon(Filter), icon: renderIcon(Filter),
}, },
{
type: 'divider',
key: 'd2',
},
{
key: 'key_remove',
label: i18n.t('batch_delete'),
icon: renderIcon(Delete),
},
{ {
type: 'divider', type: 'divider',
key: 'd1', key: 'd1',
@ -161,7 +170,7 @@ const menuOptions = {
}, },
{ {
key: 'key_remove', key: 'key_remove',
label: i18n.t('remove_path'), label: i18n.t('batch_delete'),
icon: renderIcon(Delete), icon: renderIcon(Delete),
}, },
], ],
@ -445,7 +454,7 @@ const handleSelectContextMenu = (key) => {
connectionStore.loadKeyValue(props.server, db, redisKey) connectionStore.loadKeyValue(props.server, db, redisKey)
break break
case 'key_remove': case 'key_remove':
dialogStore.openDeleteKeyDialog(props.server, db, redisKey + ':*') dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
break break
case 'value_remove': case 'value_remove':
confirmDialog.warning(i18n.t('remove_tip', { name: redisKey }), () => { confirmDialog.warning(i18n.t('remove_tip', { name: redisKey }), () => {

View File

@ -52,7 +52,7 @@
"remove_conn_group": "Delete Connection Group", "remove_conn_group": "Delete Connection Group",
"no_group": "No Group", "no_group": "No Group",
"copy_path": "Copy Path", "copy_path": "Copy Path",
"remove_path": "Remove Path", "batch_delete": "Batch Delete",
"copy_key": "Copy Key Name", "copy_key": "Copy Key Name",
"remove_key": "Remove Key", "remove_key": "Remove Key",
"new_conn_title": "New Connection", "new_conn_title": "New Connection",

View File

@ -54,7 +54,7 @@
"remove_conn_group": "删除连接分组", "remove_conn_group": "删除连接分组",
"no_group": "无分组", "no_group": "无分组",
"copy_path": "复制路径", "copy_path": "复制路径",
"remove_path": "删除路径", "batch_delete": "批量删除键",
"copy_key": "复制键名", "copy_key": "复制键名",
"remove_key": "删除键", "remove_key": "删除键",
"new_conn_title": "新建连接", "new_conn_title": "新建连接",

View File

@ -316,6 +316,7 @@ const useConnectionStore = defineStore('connections', {
} }
const dbs = [] const dbs = []
for (let i = 0; i < db.length; i++) { for (let i = 0; i < db.length; i++) {
this._getNodeMap(name, i).clear()
dbs.push({ dbs.push({
key: `${name}/${db[i].name}`, key: `${name}/${db[i].name}`,
label: db[i].name, label: db[i].name,
@ -324,6 +325,7 @@ const useConnectionStore = defineStore('connections', {
db: i, db: i,
type: ConnectionType.RedisDB, type: ConnectionType.RedisDB,
isLeaf: false, isLeaf: false,
children: undefined,
}) })
} }
this.databases[name] = dbs this.databases[name] = dbs
@ -344,7 +346,7 @@ const useConnectionStore = defineStore('connections', {
const dbs = this.databases[name] const dbs = this.databases[name]
for (const db of dbs) { for (const db of dbs) {
this.removeKeyFilter(name, db.db) this.removeKeyFilter(name, db.db)
this.nodeMap[`${name}#${db.db}`]?.clear() this._getNodeMap(name, db.db).clear()
} }
this.removeKeyFilter(name, -1) this.removeKeyFilter(name, -1)
delete this.databases[name] delete this.databases[name]
@ -469,7 +471,7 @@ const useConnectionStore = defineStore('connections', {
dbs[db].children = undefined dbs[db].children = undefined
dbs[db].isLeaf = false dbs[db].isLeaf = false
this.nodeMap[`${connName}#${db}`]?.clear() this._getNodeMap(connName, db).clear()
}, },
/** /**
@ -483,7 +485,7 @@ const useConnectionStore = defineStore('connections', {
dbs[db].isLeaf = false dbs[db].isLeaf = false
dbs[db].opened = false dbs[db].opened = false
this.nodeMap[`${connName}#${db}`]?.clear() this._getNodeMap(connName, db).clear()
}, },
/** /**