Parcourir la source

fix: directly set language value instead of calling method

Avoid potential tree-shaking issue with store methods in production

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
yb il y a 2 semaines
Parent
commit
5667dcffff
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 4 1
      src/components/LangDropdown.vue

+ 4 - 1
src/components/LangDropdown.vue

@@ -19,6 +19,7 @@ import { computed } from 'vue'
 import { ArrowDown } from '@element-plus/icons-vue'
 import { Icon } from '@iconify/vue'
 import { useAppStore } from '@/store/app'
+import i18n from '@/locales'
 
 const appStore = useAppStore()
 
@@ -27,7 +28,9 @@ const currentLangLabel = computed(() => {
 })
 
 function handleLanguage(lang: string) {
-  appStore.changeLanguage(lang)
+  // 直接设置 store 的 language 值和 i18n locale
+  appStore.language = lang
+  i18n.global.locale.value = lang
 }
 </script>