Sfoglia il codice sorgente

fix: 修改语言切换不会同步的问题

MTrun 3 anni fa
parent
commit
3d9cd8013d

+ 1 - 1
src/components/UserInfo/components/SystemSet/index.vue

@@ -54,7 +54,7 @@ const langStore = useLangStore()
 const list = reactive<ListType[]>([
   {
     key: 'lang',
-    value: false,
+    value: langStore.getReload,
     type: 'switch',
     name: '切换语言',
     desc: '切换语言是否重新加载页面',

+ 18 - 8
src/components/UserInfo/index.vue

@@ -19,11 +19,11 @@
   </n-dropdown>
 
   <!-- 系统设置 model -->
-  <SystemSet v-model:modelShow="modelShow"/>
+  <SystemSet v-model:modelShow="modelShow" />
 </template>
 
 <script lang="ts" setup>
-import { h, ref, reactive } from 'vue'
+import { h, ref, watchEffect } from 'vue'
 import { NAvatar, NText } from 'naive-ui'
 import { renderIcon } from '@/utils'
 import { openDoc, logout } from '@/utils'
@@ -68,8 +68,9 @@ const renderUserInfo = () => {
     ]
   )
 }
+const options = ref()
 
-const options = reactive([
+const init = (doc: string, contact: string, sysSet: string, logout: string) => [
   {
     label: '我的信息',
     key: 'info',
@@ -81,17 +82,17 @@ const options = reactive([
     key: 'd1'
   },
   {
-    label: t('global.doc'),
+    label: doc,
     key: 'doc',
     icon: renderIcon(DocumentTextIcon)
   },
   {
-    label: t('global.contact'),
+    label: contact,
     key: 'contact',
     icon: renderIcon(ChatboxEllipsesIcon)
   },
   {
-    label: t('global.sys_set'),
+    label: sysSet,
     key: 'sysSet',
     icon: renderIcon(SettingsSharpIcon)
   },
@@ -100,11 +101,20 @@ const options = reactive([
     key: 'd3'
   },
   {
-    label: t('global.logout'),
+    label: logout,
     key: 'logout',
     icon: renderIcon(LogOutOutlineIcon)
   }
-])
+]
+
+watchEffect(() => {
+  options.value = init(
+    t('global.doc'),
+    t('global.contact'),
+    t('global.sys_set'),
+    t('global.logout')
+  )
+})
 
 // 图片渲染错误
 const errorHandle = (e: Event) => {