yangg 1 éve
szülő
commit
c6907f62f0
1 módosított fájl, 3 hozzáadás és 3 törlés
  1. 3 3
      src/components/layout/Header.vue

+ 3 - 3
src/components/layout/Header.vue

@@ -261,14 +261,14 @@ const search = ref(false);
 
 // multi language
 const i18n = reactive(useI18n());
-let uid = ref('')
+let uid:any = ref('')
 let face = ref('')
 let nickName = ref('')
 let email = ref("")
 watch(route, (to, from) => {
     // 检查本地存储中是否存在用户信息
     if (localStorage.getItem('USER') !== null) {
-        uid = JSON.parse(localStorage.getItem('USER')).uid
+        uid = JSON.parse(localStorage.getItem('USER') ?? 'null').uid
         init(uid)
     } else {
         router.push(({ path: '/login' }))
@@ -341,7 +341,7 @@ const messages = ref([
 ]);
 
 onMounted(() => {
-    uid = JSON.parse(localStorage.getItem('USER')).uid
+    uid = JSON.parse(localStorage.getItem('USER') ?? 'null').uid
     init(uid)
     setActiveDropdown();
 });