@@ -5,10 +5,10 @@ import type {
5
5
RouteRecordNormalized ,
6
6
} from 'vue-router' ;
7
7
8
- import { computed , watch } from 'vue' ;
8
+ import { computed , ref , watch } from 'vue' ;
9
9
import { useRoute , useRouter } from 'vue-router' ;
10
10
11
- import { $t } from '@vben/locales' ;
11
+ import { $t , useI18n } from '@vben/locales' ;
12
12
import {
13
13
IcRoundClose ,
14
14
IcRoundMultipleStop ,
@@ -33,8 +33,11 @@ function useTabs() {
33
33
return route . path ;
34
34
} ) ;
35
35
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 ) ) ;
38
41
} ) ;
39
42
40
43
/**
@@ -44,9 +47,6 @@ function useTabs() {
44
47
const affixTabs = filterTree ( router . getRoutes ( ) , ( route ) => {
45
48
return ! ! route . meta ?. affixTab ;
46
49
} ) ;
47
- affixTabs . forEach ( ( tab ) => {
48
- Object . assign ( tab , wrapperTabLocale ( tab ) ) ;
49
- } ) ;
50
50
tabsStore . setAffixTabs ( affixTabs ) ;
51
51
} ;
52
52
@@ -83,7 +83,7 @@ function useTabs() {
83
83
watch (
84
84
( ) => route . path ,
85
85
( ) => {
86
- tabsStore . addTab ( wrapperTabLocale ( route ) as RouteLocationNormalized ) ;
86
+ tabsStore . addTab ( route as RouteLocationNormalized ) ;
87
87
} ,
88
88
{ immediate : true } ,
89
89
) ;
0 commit comments