更新
This commit is contained in:
@@ -46,7 +46,7 @@ export default {
|
||||
logout() {
|
||||
serve.loginOut().then((res) => {
|
||||
if (res.code === 20000) {
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("customerToken");
|
||||
this.$router.push("/login");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ const whiteList = ["/login"]; // no redirect whitelist
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
NProgress.start();
|
||||
document.title = getPageTitle(to.meta.title);
|
||||
const hasToken = localStorage.getItem("token");
|
||||
const hasToken = localStorage.getItem("customerToken");
|
||||
if (hasToken) {
|
||||
if (to.path === "/login") {
|
||||
next({ path: "/" });
|
||||
|
||||
@@ -12,7 +12,7 @@ const service = axios.create({
|
||||
// 请求拦截
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
let token = localStorage.getItem("token");
|
||||
let token = localStorage.getItem("customerToken");
|
||||
|
||||
if (token) {
|
||||
config.headers["Authorization"] = token;
|
||||
@@ -63,7 +63,7 @@ service.interceptors.response.use(
|
||||
if (res && res.code) {
|
||||
if (res.code === 42011) {
|
||||
Vue.prototype.$message.error(res.msg || "您的登录已失效,请重新登录");
|
||||
localStorage.removeItem("token");
|
||||
localStorage.removeItem("removeItem");
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
|
||||
@@ -164,7 +164,7 @@ export default {
|
||||
imgDialog: false,
|
||||
headers: {
|
||||
dataSources: "WEB",
|
||||
Authorization: localStorage.getItem("token"),
|
||||
Authorization: localStorage.getItem("customerToken"),
|
||||
JSESSIONID: JSESSIONID,
|
||||
token: utils.bcrypt(JSESSIONID),
|
||||
},
|
||||
|
||||
@@ -155,7 +155,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
localStorage.setItem("token", res.data.accessToken);
|
||||
localStorage.setItem("customerToken", res.data.accessToken);
|
||||
this.$router.replace("/");
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
Reference in New Issue
Block a user