Skip to content

Commit

Permalink
【app】opt 取消lease失效自动移除key的功能 #52
Browse files Browse the repository at this point in the history
  • Loading branch information
tzfun committed Dec 13, 2024
1 parent ac5f2ce commit 811d397
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
16 changes: 5 additions & 11 deletions app/src/components/tree/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,21 @@ const keyId = computed<string>(() => {
return `key-${props.treeId}`
})
const treeRootObj = ref()
const treeLastSelectedItem = ref<string>()
const triggerRemovedKey = ref<string>()
const beforeClick = (_treeId: string, treeNode: TreeNode) => {
if (!treeNode) {
return false;
}
if (treeNode.isParent) {
treeRootObj.value.expandNode(treeNode)
return false;
}
return treeNode.id != triggerRemovedKey.value;
}
const onClick = (_e: MouseEvent, _treeId: string, treeNode: TreeNode) => {
if (treeNode.isParent) {
treeRootObj.value.expandNode(treeNode)
if (treeLastSelectedItem.value) {
let node = getTreeNodeById(treeLastSelectedItem.value)
if (node) {
treeRootObj.value.selectNode(node)
}
}
} else {
treeLastSelectedItem.value = treeNode.id
if (!treeNode.isParent) {
emits('on-click', treeNode.id)
}
if (!props.enableSelect) {
Expand Down
15 changes: 10 additions & 5 deletions app/src/pages/main/Keys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type DiffInfo = {
content: string
}
// 自动移除lease失效key的开关
const AUTO_REMOVE_EXPIRED_KEY = false
const KEY_SPLITTER = computed<string>(() => {
return _useSettings().value.kvPathSplitter
})
Expand Down Expand Up @@ -394,7 +397,7 @@ const showKV = (key: string): Promise<void> => {
currentKv.value = kv
currentKvChanged.value = false
if (kv.leaseInfo) {
if (kv.leaseInfo && AUTO_REMOVE_EXPIRED_KEY) {
let timer = setTimeout(() => {
keyLeaseListeners.delete(timer)
onKeyTimeOver(kv.key)
Expand Down Expand Up @@ -643,11 +646,13 @@ const onKeyTimeOver = (key: string) => {
}
const clearAllKeyLeaseListener = () => {
for (let keyLeaseListener of keyLeaseListeners) {
clearTimeout(keyLeaseListener)
}
if (AUTO_REMOVE_EXPIRED_KEY) {
for (let keyLeaseListener of keyLeaseListeners) {
clearTimeout(keyLeaseListener)
}
keyLeaseListeners.clear()
keyLeaseListeners.clear()
}
}
const onClickKeyCollectionTreeItem = (key: string) => {
Expand Down

0 comments on commit 811d397

Please # to comment.