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 --- a/src/assets/nav/setUpConglomerate.png +++ b/src/assets/nav/setUpConglomerate.png 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, },