Skip to content

Commit

Permalink
feat(tab): useTabStore add changeTabTitle() (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo authored Nov 12, 2024
1 parent e86e9cc commit e69159c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions web/src/store/modules/useTabStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const useTabStore = defineStore(

function addTab(route: MineTabbar) {
if (!tabList.value?.find(item => item.fullPath === route.fullPath)
&& !settingStore.getSettings('app').whiteRoute.includes(route.fullPath)
&& !settingStore.getSettings('app').whiteRoute.includes(route.name)
) {
tabList.value?.push({
name: route.name,
Expand Down Expand Up @@ -192,6 +192,14 @@ const useTabStore = defineStore(
return tabList.value.find(item => item.fullPath === route.fullPath)
}

function changeTabTitle(title: string, tab: MineTabbar | null = null) {
const t = (tab ?? getCurrentTab())
t.title = title
delete t?.i18n
useSettingStore().setTitle(title)
storage()
}

function clearTab() {
tabList.value = [defaultTab.value]
keepAliveStore.clean()
Expand All @@ -202,14 +210,15 @@ const useTabStore = defineStore(
}

async function go(item: any) {
await router.push(item?.fullPath ?? item.path)
await router.replace(item?.fullPath ?? item.path)
}

return {
tabList,
defaultTab,
go,
initTab,
changeTabTitle,
affixTab,
cancelAffixTab,
maxSizeTab,
Expand Down

0 comments on commit e69159c

Please sign in to comment.