From 0d533ea8fbbe29c8224f26da89b5f9717c49cd97 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 3 Feb 2023 14:51:54 +0800 Subject: [PATCH] 0203 --- package.json | 1 - src/config/route.js | 13 ------ src/layout/components/NavMenu.vue | 7 ++- src/utils/request.js | 74 +++++++++++++++---------------- 4 files changed, 40 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 300e02f6..cb9ce11d 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,6 @@ "vue/multi-word-component-names": 0, "no-debugger": "off", "no-console": "off", - "drop_debugger":true, "no-trailing-spaces": "off" } }, diff --git a/src/config/route.js b/src/config/route.js index ac3cae9e..aa239a4c 100644 --- a/src/config/route.js +++ b/src/config/route.js @@ -27,18 +27,6 @@ // ] const routes = [ - { - "path": "/bigScreen", - "name": "bigScreen", - "meta": { - "title": "驾驶舱", - "icon": "el-icon-position", - "perms": ["bigScreen"], - "fullpage": true, - "type": "link", - }, - "component": "bigScreen" - }, { "name": "home", "path": "/home", @@ -68,7 +56,6 @@ const routes = [ "icon": "el-icon-position", "perms": ["bigScreen"], "fullpage": true, - "type": "link", }, "component": "bigScreen" }, diff --git a/src/layout/components/NavMenu.vue b/src/layout/components/NavMenu.vue index 70a692c7..c3854178 100644 --- a/src/layout/components/NavMenu.vue +++ b/src/layout/components/NavMenu.vue @@ -12,7 +12,6 @@ @@ -38,9 +37,9 @@ blankPageClick(path){ // console.log(window.location); // console.log(path); - // let linkUrl = window.location.origin+"/#"+path; - // console.log(linkUrl) - // debugger; + let linkUrl = window.location.origin+"/#"+path; + console.log(linkUrl) + debugger; let routeUrl = this.$router.resolve({path: path}); diff --git a/src/utils/request.js b/src/utils/request.js index b58948e3..4ad14f80 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -40,44 +40,44 @@ axios.interceptors.response.use( if (error.response) { if (error.response.status == 401) { if(error.response.data.err_code == 'no_active_account'){ - // ElNotification.warning({ - // title: '请求失败', - // message: "账户密码错误或已禁用" - // }); - if (!isRefreshing) { - isRefreshing = true; - axios({ - method: 'post', - url: sysConfig.API_URL+'/auth/token/refresh/', - headers: { - Authorization: `Bearer ${tool.cookie.get("TOKEN")}`, - }, - data:{refresh:tool.cookie.get("TOKEN_REFRESH")} - }).then(res=>{ - debugger; - console.log(res.data.access); - // 替换本地的token - tool.cookie.set("TOKEN", res.data.access); - tool.data.set("TOKEN_TIME", new Date().getTime()); - error.config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + res.data.access; - isRefreshing = false; - requests.forEach(cb => cb()) - //发起后将requests置空 - requests=[]; - return axios(error.config) - }).catch(()=>{ - // refresh_token 有值 , 但是过期了, 请求失败 - router.push('/login') - }) + ElNotification.warning({ + title: '请求失败', + message: "账户密码错误或已禁用" + }); + // if (!isRefreshing) { + // isRefreshing = true; + // axios({ + // method: 'post', + // url: sysConfig.API_URL+'/auth/token/refresh/', + // headers: { + // Authorization: `Bearer ${tool.cookie.get("TOKEN")}`, + // }, + // data:{refresh:tool.cookie.get("TOKEN_REFRESH")} + // }).then(res=>{ + // debugger; + // console.log(res.data.access); + // // 替换本地的token + // tool.cookie.set("TOKEN", res.data.access); + // tool.data.set("TOKEN_TIME", new Date().getTime()); + // error.config.headers[sysConfig.TOKEN_NAME] = sysConfig.TOKEN_PREFIX + res.data.access; + // isRefreshing = false; + // requests.forEach(cb => cb()) + // //发起后将requests置空 + // requests=[]; + // return axios(error.config) + // }).catch(()=>{ + // // refresh_token 有值 , 但是过期了, 请求失败 + // router.push('/login') + // }) - }else{ - //如果正在刷新token,将发起的请求暂存在requests中 - return new Promise((resolve)=>{ - requests.push(()=>{ - resolve(axios(error.config)); - }) - }) - } + // }else{ + // //如果正在刷新token,将发起的请求暂存在requests中 + // return new Promise((resolve)=>{ + // requests.push(()=>{ + // resolve(axios(error.config)); + // }) + // }) + // } }else{ // ElMessageBox.confirm('当前用户已被登出或无权限访问当前资源,请尝试重新登录后再操作。', '无权限访问', { // type: 'error',