From 3fe27a3b570a7d6d8f8d66d0fab34d011257b56d Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 16 Dec 2024 19:43:47 +0800
Subject: [PATCH] 突发事件模拟内容调整,路由拦截跳转调整

---
 src/permission.js |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/permission.js b/src/permission.js
index 652bd76..93f066b 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -2,7 +2,7 @@
  * @Author: shuishen 1109946754@qq.com
  * @Date: 2024-10-30 17:03:57
  * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2024-10-30 17:07:40
+ * @LastEditTime: 2024-12-16 19:35:12
  * @FilePath: \bigScreen\src\permission.js
  * @Description: 
  * 
@@ -22,14 +22,19 @@
   const meta = to.meta || {}
 
   if (token) {
-    if (to.path === '/login') {
-      //如果登录成功访问登录页跳转到主页
+    if (!to.matched.length) {
+      // 如果路由不存在
       next({ path: '/' })
     } else {
-      if (token.length === 0) {
-        next({ path: '/login' })
+      if (to.path === '/login') {
+        //如果登录成功访问登录页跳转到主页
+        next({ path: '/' })
       } else {
-        next()
+        if (token.length === 0) {
+          next({ path: '/login' })
+        } else {
+          next()
+        }
       }
     }
   } else {
@@ -45,3 +50,4 @@
 router.afterEach(to => {
 
 })
+

--
Gitblit v1.9.3