Commit 0bb1a61775d81396aae54f61b1f319bfb1f857ce
1 parent
89af7d4b
兼容长水登录错误信息隐藏
Showing
3 changed files
with
24 additions
and
23 deletions
src/api/axios.js
| 1 | 1 | import axios from "axios"; |
| 2 | -import Cookies from "js-cookie"; | |
| 3 | 2 | import NProgress from "nprogress"; |
| 4 | 3 | import { Message } from "element-ui"; |
| 5 | 4 | import router from "@/router/index"; |
| 6 | 5 | import store from "@/store"; |
| 7 | 6 | import conf from "../config/index"; // 路径配置 |
| 7 | +import { getURLParams } from "@/utils"; | |
| 8 | + | |
| 9 | +let code = getURLParams("code") || localStorage.getItem("csCode") || ""; | |
| 10 | + | |
| 11 | + | |
| 8 | 12 | // axios默认配置 |
| 9 | 13 | const service = axios.create({ |
| 10 | 14 | baseURL: conf.baseURL, // api的base_url |
| ... | ... | @@ -20,9 +24,6 @@ service.interceptors.request.use( |
| 20 | 24 | const source = axios.CancelToken.source(); |
| 21 | 25 | store.commit("setTokenSources", [source.token, source.cancel]); |
| 22 | 26 | config.cancelToken = source.token; |
| 23 | - // if (Cookies.get("access_token")) { | |
| 24 | - // config.headers.Authorization = "Bearer" + Cookies.get("access_token") | |
| 25 | - // } | |
| 26 | 27 | return config; |
| 27 | 28 | }, |
| 28 | 29 | (error) => { |
| ... | ... | @@ -39,26 +40,22 @@ service.interceptors.response.use( |
| 39 | 40 | store.commit("delTokenSources", response.config.cancelToken); |
| 40 | 41 | } |
| 41 | 42 | if (response.status == 200) { |
| 42 | - // Cookies.set("access_token", response.data.info, { expires: 1 / 12 }) | |
| 43 | - // console.log(response.status) | |
| 44 | 43 | if (res.status == 999) { |
| 45 | 44 | // if (!location.href.includes("localhost")) { |
| 46 | - if (res.data) { | |
| 47 | - window.location.href = res.data; | |
| 48 | - } else { | |
| 49 | - router.push({ path: "/login" }); | |
| 50 | - if (res.info.includes("不存在")) { | |
| 51 | - Message({ | |
| 52 | - info: res.info, | |
| 53 | - type: "error", | |
| 54 | - duration: 3 * 1000, | |
| 55 | - }); | |
| 56 | - } | |
| 45 | + if (res.data) { | |
| 46 | + window.location.href = res.data; | |
| 47 | + } else { | |
| 48 | + router.push({ path: "/login" }); | |
| 49 | + if (res.info.includes("不存在")) { | |
| 50 | + Message({ | |
| 51 | + info: res.info, | |
| 52 | + type: "error", | |
| 53 | + duration: 3 * 1000, | |
| 54 | + }); | |
| 57 | 55 | } |
| 56 | + } | |
| 58 | 57 | // } |
| 59 | - } else { | |
| 60 | - // Cookies.set("access_token", response.data.info, { expires: 1 / 12 }) | |
| 61 | - } | |
| 58 | + } | |
| 62 | 59 | } |
| 63 | 60 | return Promise.resolve(res); |
| 64 | 61 | }, |
| ... | ... | @@ -81,7 +78,11 @@ service.interceptors.response.use( |
| 81 | 78 | }); |
| 82 | 79 | router.push({ path: "/login" }); |
| 83 | 80 | } |
| 84 | - return Promise.resolve(data); | |
| 81 | + if (code) { | |
| 82 | + return | |
| 83 | + } else { | |
| 84 | + return Promise.resolve(data); | |
| 85 | + } | |
| 85 | 86 | } |
| 86 | 87 | Message.closeAll(); |
| 87 | 88 | Message({ | ... | ... |
src/assets/nav/setUpConglomerate.png
vue.config.js
| ... | ... | @@ -22,8 +22,8 @@ module.exports = { |
| 22 | 22 | }, |
| 23 | 23 | proxy: { |
| 24 | 24 | "/": { |
| 25 | - // target:"http://121.40.127.171", | |
| 26 | - target:"http://ezquiz.sunvotecloud.cn", | |
| 25 | + target:"http://121.40.127.171", | |
| 26 | + // target:"http://ezquiz.sunvotecloud.cn", | |
| 27 | 27 | changeOrigin: true, |
| 28 | 28 | ws:true, |
| 29 | 29 | }, | ... | ... |