e3eaf360 by 任超

style:表头样式修改

2 parents 34318b99 944a09ed
......@@ -18,13 +18,13 @@ router.beforeEach(async (to, from, next) => {
let hasUser = store.state.user.hasUser;
let hasAddRoute = store.state.permission.addRoutes;
if (to.path == "/sb" || to.path == "/jg") {
sessionStorage.removeItem("token");
localStorage.removeItem("token");
sessionStorage.setItem("psth", to.path)
next();
} else {
let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT"
//判断token是否存在
const hasToken = sessionStorage.getItem("token");
const hasToken = localStorage.getItem("token");
if (hasToken) {
//请求用户信息
if (!hasUser) {
......
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-13 14:11:50
* @LastEditTime: 2023-03-14 14:39:24
*/
/**
* 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
......@@ -25,7 +25,7 @@ const service = axios.create({
service.interceptors.request.use(
(config) => {
//调用登录接口时无token,也不需要传token,其他接口都传入token
config.headers.Authorization = sessionStorage.getItem("token") || "";
config.headers.Authorization = localStorage.getItem("token") || "";
config.headers.Accept = "application/json";
return config;
},
......@@ -35,6 +35,7 @@ service.interceptors.request.use(
}
);
window.tokenValid = true
// response interceptor
service.interceptors.response.use(
(response) => {
......@@ -64,15 +65,20 @@ service.interceptors.response.use(
//对错误信息的处理函数
function handleErrorData (status) {
switch (status) {
// case 401:
// Message.error("由于长时间未操作,请重新登录!");
// router.replace({
// path: "/login/jg",
// query: {
// redirect: router.history.current.fullPath,
// },
// });
// break;
case 401:
// 多个请求不重复提示错误信息
if (window.tokenValid) {
window.tokenValid = false;
Message.error("由于长时间未操作,请重新登录!");
localStorage.removeItem("token");
router.replace({
path: "/jg",
query: {
redirect: router.history.current.fullPath,
},
});
}
break;
case 403:
Message.error("拒绝访问");
break;
......
......@@ -96,7 +96,7 @@
.then((res) => {
if (res.status === 1) {
//存储token
sessionStorage.setItem("token", `Bearer ${res.content}`);
localStorage.setItem("token", `Bearer ${res.content}`);
//登录成功后需判断有无重定向,没有重定向则跳转首页
this.$router.replace(this.$route.query.redirect || "/");
} else {
......
......@@ -103,7 +103,7 @@
if (res.status === 1) {
this.$store.dispatch('business/setInitRules', "layout1")
//存储token
sessionStorage.setItem("token", `Bearer ${res.content}`);
localStorage.setItem("token", `Bearer ${res.content}`);
//登录成功后需判断有无重定向,没有重定向则跳转首页
this.$router.replace(this.$route.query.redirect || "/");
} else {
......