panhui 3 жил өмнө
parent
commit
1a67f01a16
1 өөрчлөгдсөн 17 нэмэгдсэн , 10 устгасан
  1. 17 10
      src/router/index.js

+ 17 - 10
src/router/index.js

@@ -51,17 +51,24 @@ const router = createRouter({
 })
 
 router.beforeEach((to, from, next) => {
-    const uerStore = useUserStore()
-    if (!uerStore.user && to.meta.pageType !== Page.Login) {
-        uerStore
-            .get()
-            .then(() => {
-                next()
-            })
-            .catch(() => {
-                next()
-            })
+    const userStore = useUserStore()
+    if (to.meta.pageType != Page.Every) {
+        if (!userStore.user && to.meta.pageType !== Page.Login) {
+            userStore
+                .get()
+                .then(() => {
+                    next()
+                })
+                .catch(() => {
+                    next()
+                })
+        } else {
+            next()
+        }
     } else {
+        if (!userStore.user) {
+            userStore.get()
+        }
         next()
     }
 })