perf: re-refresh with re-click the activated key after more then 1 sec (#242)

This commit is contained in:
Lykin 2024-05-15 17:37:24 +08:00
parent 455a911154
commit abf5534165
2 changed files with 25 additions and 2 deletions

View File

@ -598,13 +598,25 @@ const renderSuffix = ({ option }) => {
return null
}
const lastLoadKey = ref(0)
/**
*
* @param {RedisNodeItem} node
*/
const updateKeyDetail = (node) => {
if (node.type === ConnectionType.RedisValue) {
if (tabStore.setActivatedKey(props.server, node.key)) {
const preK = tabStore.getActivatedKey(props.server)
if (!isEmpty(preK) && preK === node.key && Date.now() - lastLoadKey.value > 1000) {
// reload key already activated
lastLoadKey.value = Date.now()
const { db, redisKey, redisKeyCode } = node
browserStore.reloadKey({
server: props.server,
db,
key: redisKeyCode || redisKey,
})
} else if (tabStore.setActivatedKey(props.server, node.key)) {
const { db, redisKey, redisKeyCode } = node
browserStore.loadKeySummary({
server: props.server,

View File

@ -780,9 +780,20 @@ const useTabStore = defineStore('tab', {
},
/**
* set activated key
* get activated key
* @param {string} server
* @return {string|null}
*/
getActivatedKey(server) {
let tab = find(this.tabList, { name: server })
return get(tab, 'activatedKey')
},
/**
* set activated key and return current activatedKey
* @param {string} server
* @param {string} key
* @return {boolean}
*/
setActivatedKey(server, key) {
/** @type TabItem**/