From 0bb1a61775d81396aae54f61b1f319bfb1f857ce Mon Sep 17 00:00:00 2001 From: 梁保满 Date: Mon, 20 Mar 2023 11:15:25 +0800 Subject: [PATCH] 兼容长水登录错误信息隐藏 --- src/api/axios.js | 43 ++++++++++++++++++++++--------------------- src/assets/nav/setUpConglomerate.png | Bin 7628 -> 0 bytes vue.config.js | 4 ++-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/api/axios.js b/src/api/axios.js index 0c3632d..e41b360 100644 --- a/src/api/axios.js +++ b/src/api/axios.js @@ -1,10 +1,14 @@ import axios from "axios"; -import Cookies from "js-cookie"; import NProgress from "nprogress"; import { Message } from "element-ui"; import router from "@/router/index"; import store from "@/store"; import conf from "../config/index"; // 路径配置 +import { getURLParams } from "@/utils"; + +let code = getURLParams("code") || localStorage.getItem("csCode") || ""; + + // axios默认配置 const service = axios.create({ baseURL: conf.baseURL, // api的base_url @@ -20,9 +24,6 @@ service.interceptors.request.use( const source = axios.CancelToken.source(); store.commit("setTokenSources", [source.token, source.cancel]); config.cancelToken = source.token; - // if (Cookies.get("access_token")) { - // config.headers.Authorization = "Bearer" + Cookies.get("access_token") - // } return config; }, (error) => { @@ -39,26 +40,22 @@ service.interceptors.response.use( store.commit("delTokenSources", response.config.cancelToken); } if (response.status == 200) { - // Cookies.set("access_token", response.data.info, { expires: 1 / 12 }) - // console.log(response.status) if (res.status == 999) { // if (!location.href.includes("localhost")) { - if (res.data) { - window.location.href = res.data; - } else { - router.push({ path: "/login" }); - if (res.info.includes("不存在")) { - Message({ - info: res.info, - type: "error", - duration: 3 * 1000, - }); - } + if (res.data) { + window.location.href = res.data; + } else { + router.push({ path: "/login" }); + if (res.info.includes("不存在")) { + Message({ + info: res.info, + type: "error", + duration: 3 * 1000, + }); } + } // } - } else { - // Cookies.set("access_token", response.data.info, { expires: 1 / 12 }) - } + } } return Promise.resolve(res); }, @@ -81,7 +78,11 @@ service.interceptors.response.use( }); router.push({ path: "/login" }); } - return Promise.resolve(data); + if (code) { + return + } else { + return Promise.resolve(data); + } } Message.closeAll(); Message({ diff --git a/src/assets/nav/setUpConglomerate.png b/src/assets/nav/setUpConglomerate.png index 5fd7b09..615c6cc 100644 Binary files a/src/assets/nav/setUpConglomerate.png and b/src/assets/nav/setUpConglomerate.png differ diff --git a/vue.config.js b/vue.config.js index 7f67187..b4b81e6 100644 --- a/vue.config.js +++ b/vue.config.js @@ -22,8 +22,8 @@ module.exports = { }, proxy: { "/": { - // target:"http://121.40.127.171", - target:"http://ezquiz.sunvotecloud.cn", + target:"http://121.40.127.171", + // target:"http://ezquiz.sunvotecloud.cn", changeOrigin: true, ws:true, }, -- libgit2 0.21.4