Browse Source

fix: add tab create keepalive params

nian 2 months ago
parent
commit
8e63314bd3
3 changed files with 9 additions and 5 deletions
  1. 5 2
      src/layouts/main/index.vue
  2. 1 1
      src/stores/tabs.ts
  3. 3 2
      src/typings/vue-router.d.ts

+ 5 - 2
src/layouts/main/index.vue

@@ -27,7 +27,7 @@ const navigationTransitionName = ref('scale')
 const isMounted = ref(false)
 
 const keepAliveTabs = computed(() => {
-  return tabsStore.tabs.filter((tab) => tab.keepAlived).map((tab) => tab.componentName ?? '')
+  return tabsStore.tabs.filter((tab) => tab.keepAlive).map((tab) => tab.componentName ?? '')
 })
 
 let oldTabs: Tab[] = []
@@ -145,7 +145,10 @@ onMounted(() => {
     v-if="preferencesStore.preferences.enableNavigationTransition"
     v-slot="{ Component, route }"
   >
-    <Transition :name="navigationTransitionName">
+    <Transition
+      type="transition"
+      :name="navigationTransitionName"
+    >
       <KeepAlive :include="keepAliveTabs">
         <component
           :is="Component"

+ 1 - 1
src/stores/tabs.ts

@@ -14,7 +14,7 @@ export interface Tab {
   componentName?: string
   locked?: boolean
   pinned?: boolean
-  keepAlived?: boolean
+  keepAlive?: boolean
 }
 
 export const useTabsStore = defineStore('tabsStore', () => {

+ 3 - 2
src/typings/vue-router.d.ts

@@ -2,12 +2,13 @@ import type { RouteParamsGeneric } from 'vue-router'
 
 declare module 'vue-router' {
   interface RouteMeta {
-    componentName?: string
-    pinned?: boolean
     title?: string
     icon?: string
+    componentName?: string
+    pinned?: boolean
     showTab?: boolean
     enableMultiTab?: boolean
+    withKeepAlive?: boolean
     renderTabTitle?: (params: RouteParamsGeneric) => string
   }
 }