Ver código fonte

token失效后弹框错误隐藏,并跳转登录页

ming 3 anos atrás
pai
commit
ae0128a4e9

+ 3 - 3
public/static/config.js

@@ -1,9 +1,9 @@
 // api 请求路径
 var PLATFROM_CONFIG = {};
-// PLATFROM_CONFIG.baseUrl = "http://172.16.120.104:8010/" //杨强本地
-// PLATFROM_CONFIG.baseUrl = "http://172.16.1.196:8010/" //超博本地
+PLATFROM_CONFIG.baseUrl = "http://172.16.120.104:8010/" //杨强本地
+    // PLATFROM_CONFIG.baseUrl = "http://172.16.1.196:8010/" //超博本地
 
-PLATFROM_CONFIG.baseUrl = "https://qhome.usky.cn/fivapi/" //线上
+// PLATFROM_CONFIG.baseUrl = "https://qhome.usky.cn/fivapi/" //线上
 PLATFROM_CONFIG.images = "https://qhome.usky.cn/file/" //线上图片
 PLATFROM_CONFIG.fileUrl = "https://qhome.usky.cn/file/" //xlsx文件访问路径
 

+ 9 - 9
src/config/default/net.config.js

@@ -2,13 +2,13 @@
  * @description 导出默认网路配置
  **/
 const network = {
-  //配后端数据的接收方式application/json;charset=UTF-8 或 application/x-www-form-urlencoded;charset=UTF-8
-  contentType: 'application/json;charset=UTF-8',
-  //消息框消失时间
-  messageDuration: 3000,
-  //最长请求时间
-  requestTimeout: 10000,
-  //操作正常code,支持String、Array、int多种类型
-  successCode: [200, 0],
+    //配后端数据的接收方式application/json;charset=UTF-8 或 application/x-www-form-urlencoded;charset=UTF-8
+    contentType: 'application/json;charset=UTF-8',
+    //消息框消失时间
+    messageDuration: 3000,
+    //最长请求时间
+    requestTimeout: 10000,
+    //操作正常code,支持String、Array、int多种类型
+    successCode: [200, 0],
 }
-module.exports = network
+module.exports = network

+ 1 - 0
src/store/modules/user.js

@@ -139,6 +139,7 @@ const actions = {
      * @param {*} { commit, dispatch }
      */
     async resetAll({ dispatch }) {
+
         await dispatch('setAccessToken', '')
         await dispatch('acl/setFull', false, { root: true })
         await dispatch('acl/setRole', [], { root: true })

+ 8 - 3
src/utils/request.js

@@ -25,11 +25,16 @@ let loadingInstance
  */
 const handleCode = (code, msg) => {
     switch (code) {
-        case 401:
-            message.error(msg || '登录失效')
+        case '401':
+            // message.error(msg || '登录失效')
+            // message.error(msg + '  ,请重新登录...' || '登录失效')
+            router.replace({ path: "/login" });
+            // setTimeout(() => {
+            //     router.replace({ path: "/login" });
+            // }, 3000)
             store.dispatch('user/resetAll').catch(() => {})
             break
-        case 403:
+        case '403':
             router.push({ path: '/401' }).catch(() => {})
             break
         default: