perf: re-refresh with re-click the activated key after more then 1 sec (#242)
This commit is contained in:
parent
455a911154
commit
abf5534165
|
@ -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,
|
||||
|
|
|
@ -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**/
|
||||
|
|
Loading…
Reference in New Issue