Ver código fonte

1、添加多语言支持

qmj 2 semanas atrás
pai
commit
3d0f8dd8c1
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      src/components/LangSelect/index.vue

+ 3 - 2
src/components/LangSelect/index.vue

@@ -49,14 +49,15 @@ watch(locale, (newLocale) => {
 })
 
 const handleChange = (value) => {
-  // 获取当前登录用户名
-  const userName = userStore.name || ''
+  // 获取当前登录用户名,如果没有则传入空字符串
+  const userName = userStore.name || 'username'
   
   changeLanguages(value, userName).then(response => {
     // 处理响应
   }).catch(error => {
     console.error('切换语言失败:', error)
   })
+  
   setLocale(value)
   currentLocale.value = value
   // 更新页面标题