feat: 商家端新增redirect登录功能

master
Yer 2023-07-25 10:10:20 +08:00
parent 4389911436
commit 7bc5d67efc
2 changed files with 20 additions and 7 deletions

View File

@ -23,6 +23,15 @@ const service = axios.create({
timeout: 10000,
baseURL: baseUrl
});
const recordCurrentPath = () => {
return router.history.current.fullPath
}
// 跳转登录页
const redirectLogin = () => {
router.push({path:'/login',query:{redirect: recordCurrentPath()}});
}
service.interceptors.request.use(
config => {
if (config.method == "get") {
@ -72,7 +81,7 @@ service.interceptors.response.use(
} else {
Message.error("未知错误,请重新登录");
}
router.push("/login");
redirectLogin();
}
break;
case 500:
@ -110,7 +119,7 @@ service.interceptors.response.use(
}
} else {
Cookies.set("userInfoSeller", "");
router.push("/login");
redirectLogin();
}
isRefreshToken = 0;
}

View File

@ -156,10 +156,14 @@ export default {
util.initRouter(this);
this.$store.commit("setAvatarPath", res.result.storeLogo);
const redirectRouter = this.$route.query.redirect;
//
this.$router.push({
name: "home_index",
});
const push = {
path: redirectRouter || "/home",
}
this.$router.push(push);
} else {
this.loading = false;
}