@@ -5,10 +5,10 @@ import type {
55 RouteRecordNormalized ,
66} from 'vue-router' ;
77
8- import { computed , watch } from 'vue' ;
8+ import { computed , ref , watch } from 'vue' ;
99import { useRoute , useRouter } from 'vue-router' ;
1010
11- import { $t } from '@vben/locales' ;
11+ import { $t , useI18n } from '@vben/locales' ;
1212import {
1313 IcRoundClose ,
1414 IcRoundMultipleStop ,
@@ -33,8 +33,11 @@ function useTabs() {
3333 return route . path ;
3434 } ) ;
3535
36- const currentTabs = computed ( ( ) => {
37- return tabsStore . getTabs ;
36+ const { locale } = useI18n ( ) ;
37+ const currentTabs =
38+ ref < ( RouteLocationNormalized | RouteRecordNormalized ) [ ] > ( ) ;
39+ watch ( [ ( ) => tabsStore . getTabs , ( ) => locale . value ] , ( [ tabs , _ ] ) => {
40+ currentTabs . value = tabs . map ( ( item ) => wrapperTabLocale ( item ) ) ;
3841 } ) ;
3942
4043 /**
@@ -44,9 +47,6 @@ function useTabs() {
4447 const affixTabs = filterTree ( router . getRoutes ( ) , ( route ) => {
4548 return ! ! route . meta ?. affixTab ;
4649 } ) ;
47- affixTabs . forEach ( ( tab ) => {
48- Object . assign ( tab , wrapperTabLocale ( tab ) ) ;
49- } ) ;
5050 tabsStore . setAffixTabs ( affixTabs ) ;
5151 } ;
5252
@@ -83,7 +83,7 @@ function useTabs() {
8383 watch (
8484 ( ) => route . path ,
8585 ( ) => {
86- tabsStore . addTab ( wrapperTabLocale ( route ) as RouteLocationNormalized ) ;
86+ tabsStore . addTab ( route as RouteLocationNormalized ) ;
8787 } ,
8888 { immediate : true } ,
8989 ) ;
0 commit comments