huangbin 4 vuotta sitten
vanhempi
commit
01c19558b0
1 muutettua tiedostoa jossa 20 lisäystä ja 15 poistoa
  1. 20 15
      src/router/index.ts

+ 20 - 15
src/router/index.ts

@@ -872,23 +872,28 @@ router.beforeEach((to, from, next) => {
         if (isLogin()) {
             return next();
         } else {
-            // const account = '1456456000000103'
-            // const password = 'd41efe629f9ed46baaa8f1ced2de518c645060e1965807776334820e55ce07c2'
-            if (!getLoadIsComplete()) {
+            const account = '1456456000000103'
+            const password = 'd41efe629f9ed46baaa8f1ced2de518c645060e1965807776334820e55ce07c2'
+            if (!getLoadIsComplete()) { // 没有加载对应的资料,表示第一次启动项目
                 console.log('to', to);
-                setLoadComplete(false)
-                globalDataRefresh().then(() => {
-                    const { ACCOUNT, PASSWORD } = to.query
-                    login(ACCOUNT as string, PASSWORD as string, [], true).then(res => {
-                        setLoadComplete(true)
-                        localStorageUtil.setItem('loginAccount', ACCOUNT); // 缓存登录账号
-                        eventBus.$emit('loginSuccess', true);
-                        next({ name: 'home' })
-                    }).catch(err => {
-                        console.log('err', err);
+                const { ACCOUNT, PASSWORD } = to.query
+                if (ACCOUNT && PASSWORD) {
+                    setLoadComplete(false)
+                    globalDataRefresh().then(() => {
+                        const { ACCOUNT, PASSWORD } = to.query
+                        login(ACCOUNT as string, PASSWORD as string, [], true).then(res => {
+                            setLoadComplete(true)
+                            localStorageUtil.setItem('loginAccount', ACCOUNT); // 缓存登录账号
+                            eventBus.$emit('loginSuccess', true);
+                            next({ name: 'home' })
+                        }).catch(err => {
+                            console.log('err', err);
+                        })
                     })
-                })
-            } else {
+                } else { // 跳转到登录页面
+                    next()
+                }
+            } else {    // 
                 next()
             }
         }