fix: force switch to key detail tab when `Auto Refresh` on

This commit is contained in:
Lykin 2024-10-18 16:37:03 +08:00
parent 3f5b63a36f
commit a3a1a17af3
2 changed files with 7 additions and 4 deletions

View File

@ -386,9 +386,10 @@ const useBrowserStore = defineStore('browser', {
* @param {number} db
* @param {string|number[]} [key] null or blank indicate that update tab to display normal content (blank content or server status)
* @param {boolean} [clearValue]
* @param {boolean} [redirect] redirect to key detail tab
* @return {Promise<void>}
*/
async loadKeySummary({ server, db, key, clearValue }) {
async loadKeySummary({ server, db, key, clearValue, redirect = true }) {
try {
const tab = useTabStore()
if (!isEmpty(key)) {
@ -402,7 +403,7 @@ const useBrowserStore = defineStore('browser', {
const k = nativeRedisKey(key)
const binaryKey = k !== key
tab.upsertTab({
subTab: BrowserTabType.KeyDetail,
subTab: redirect === false ? null : BrowserTabType.KeyDetail,
server,
db,
type,
@ -492,7 +493,7 @@ const useBrowserStore = defineStore('browser', {
if (showLoading) {
tab.updateLoading({ server, db, loading: true })
}
await this.loadKeySummary({ server, db, key, clearValue: true })
await this.loadKeySummary({ server, db, key, clearValue: true, redirect: false })
await this.loadKeyDetail({
server,
db,

View File

@ -3,6 +3,7 @@ import { defineStore } from 'pinia'
import { TabItem } from '@/objects/tabItem.js'
import useBrowserStore from 'stores/browser.js'
import { i18nGlobal } from '@/utils/i18n.js'
import { BrowserTabType } from '@/consts/browser_tab_type.js'
const useTabStore = defineStore('tab', {
/**
@ -179,6 +180,7 @@ const useTabStore = defineStore('tab', {
}) {
let tabIndex = findIndex(this.tabList, { name: server })
if (tabIndex === -1) {
subTab = subTab || BrowserTabType.KeyDetail
const tabItem = new TabItem({
name: server,
title: server,
@ -202,7 +204,7 @@ const useTabStore = defineStore('tab', {
} else {
const tab = this.tabList[tabIndex]
tab.blank = false
tab.subTab = subTab
tab.subTab = subTab || tab.subTab
// tab.title = db !== undefined ? `${server}/db${db}` : `${server}`
tab.title = server
tab.server = server