// 状态码处理 import route from "@/router"; import store from "@/store"; import Vue from "vue"; let that = new Vue(); // token失效 const TOKEN_INVLIDE_TO_LOGIN = (code) => { // 状态码判断 if (code === "1012") { if (store.state.common.userInfo !== "") { that.$msg.error({ message: "登陆失败", description: "token已过期", }); } // 清除个人数据 store.commit("common/setUserInfo", ""); route.replace({ path: "/login", query: { redirect: route.currentRoute.fullPath, }, }); return false; } else { return true; } }; // 全局错误处理 const PUB_ERR = (code, message, config) => { if(code === '1018') { that.$msg.error({ message, }); } if (config.responseType && config.responseType === "blob") { return true; } return true; }; export default { TOKEN_INVLIDE_TO_LOGIN, PUB_ERR, };