[baozhangchao] 3 年前
父节点
当前提交
670a9928a0
共有 3 个文件被更改,包括 28 次插入6 次删除
  1. 1
    1
      src/main.js
  2. 26
    4
      src/utils/initial.js
  3. 1
    1
      vue.config.js

+ 1
- 1
src/main.js 查看文件

29
     store,
29
     store,
30
     render: h => h(App),
30
     render: h => h(App),
31
   }).$mount('#app')
31
   }).$mount('#app')
32
+
32
 }).catch(e => {
33
 }).catch(e => {
33
   console.error(e)
34
   console.error(e)
34
   // alert('系统错误, 请刷新重试')
35
   // alert('系统错误, 请刷新重试')
35
-
36
   // 重试一次
36
   // 重试一次
37
   redirect(true)
37
   redirect(true)
38
 })
38
 })

+ 26
- 4
src/utils/initial.js 查看文件

59
 
59
 
60
 
60
 
61
 export function Login () {
61
 export function Login () {
62
+  console.log(1);
62
   const code = process.env.NODE_ENV === 'development' ? '123' : getCode()
63
   const code = process.env.NODE_ENV === 'development' ? '123' : getCode()
63
 
64
 
64
-  let isLoaded = false;
65
+  let isLoaded = false; //定义变量
65
 
66
 
67
+
68
+  //执行Timeout 如果一秒内登陆成功,由LoginUser改变isLoaded状态,Timeout 一秒后发现isLoaded为true,则关闭。
66
   const t = setTimeout(() => {
69
   const t = setTimeout(() => {
70
+    console.log(2);
71
+
67
     if (isLoaded) {
72
     if (isLoaded) {
68
       hideLoading()
73
       hideLoading()
69
     } else {
74
     } else {
70
       isLoaded = true
75
       isLoaded = true
71
     }
76
     }
72
-
73
     clearTimeout(t);
77
     clearTimeout(t);
74
   }, 1000);
78
   }, 1000);
75
 
79
 
86
     store.commit('SET_USER_INFO', userInfo)
90
     store.commit('SET_USER_INFO', userInfo)
87
     let location = window.location.href
91
     let location = window.location.href
88
 
92
 
93
+    console.log(3, isLoaded);
94
+
95
+
89
     try {
96
     try {
90
       pv({ addr: location })
97
       pv({ addr: location })
91
     } catch (error) {
98
     } catch (error) {
99
     } catch (error) {
106
     } catch (error) {
100
       console.error(error)
107
       console.error(error)
101
     }
108
     }
102
-
103
     if (isLoaded) {
109
     if (isLoaded) {
104
-      hideLoading()
110
+      console.log(4, isLoaded);
111
+
105
     } else {
112
     } else {
106
       isLoaded = true
113
       isLoaded = true
114
+      hideLoading()
115
+
116
+      console.log(4, isLoaded);
117
+
107
     }
118
     }
119
+    // setTimeout(() => {
120
+    //   console.log("🚀 ~ file: initial.js ~ line 110 ~ setTimeout ~ isLoaded", isLoaded)
121
+
122
+    //   if (isLoaded) {
123
+    //     hideLoading()
124
+    //   } else {
125
+
126
+    //     isLoaded = true
127
+    //   }
128
+    // }, 5000)
129
+
108
 
130
 
109
     return;
131
     return;
110
   })
132
   })

+ 1
- 1
vue.config.js 查看文件

8
   devServer: {
8
   devServer: {
9
     proxy: {
9
     proxy: {
10
       '/api': {
10
       '/api': {
11
-        target: "http://192.168.89.147:8081/",
11
+        target: "http://192.168.89.147:8089/",
12
         // ws: true,
12
         // ws: true,
13
         changeOrigin: true,
13
         changeOrigin: true,
14
         // pathRewrite: {
14
         // pathRewrite: {