8521a4e9 by 任超

Merge branch 'master' into dev

2 parents fad6506d e3eaf360
......@@ -19,11 +19,11 @@
</div>
</template>
<script>
import sidebarLeft from "./Sidebar/sidebarLeft";
import sidebarRight from "./Sidebar/sidebarRight";
import { logout } from "@/api/login.js";
import { mapGetters } from "vuex";
export default {
import sidebarLeft from "./Sidebar/sidebarLeft";
import sidebarRight from "./Sidebar/sidebarRight";
import { logout } from "@/api/login.js";
import { mapGetters } from "vuex";
export default {
components: {
sidebarLeft,
sidebarRight,
......@@ -57,89 +57,89 @@
});
},
},
};
};
</script>
<style lang="scss" scoped>
/deep/.el-menu--horizontal {
/deep/.el-menu--horizontal {
display: flex;
align-items: center;
}
}
.menubg {
.menubg {
height: 34px;
width: 130px;
width: 130px !important;
text-align: center;
color: #ffffff;
margin-right: 20px;
background: url("~@/image/navbar.png") no-repeat;
background-size: 100% 100%;
}
}
/deep/.el-menu-item {
/deep/.el-menu-item {
@extend .menubg;
}
}
/deep/.el-submenu {
/deep/.el-submenu {
@extend .menubg;
}
}
/deep/.el-submenu__title {
/deep/.el-submenu__title {
height: 34px;
color: #ffffff;
}
}
/deep/.el-submenu__title span {
/deep/.el-submenu__title span {
font-size: 14px;
}
}
.sidebarLeft {
.sidebarLeft {
position: relative;
top: 13px;
width: 30%;
}
}
/deep/.el-menu {
/deep/.el-menu {
display: flex;
justify-content: space-between;
}
width: 100%;
}
/deep/.el-menu-item {
/deep/.el-menu-item {
flex: 1;
width: 100%;
}
}
.sidebarRight {
.sidebarRight {
position: relative;
top: 13px;
width: 30%;
padding-left: 20px;
}
}
// 导航选中背景色
.xuanzhong {
// 导航选中背景色
.xuanzhong {
background: url("~@/image/selNavbar.png") no-repeat;
background-size: 100% 100%;
color: #ffffff !important;
font-weight: 700;
}
}
/deep/.el-menu-item:hover {
/deep/.el-menu-item:hover {
@extend .xuanzhong;
}
}
/deep/.el-submenu__title:hover {
/deep/.el-submenu__title:hover {
@extend .xuanzhong;
}
}
/deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
/deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
@extend .xuanzhong;
}
}
/deep/.el-menu-item.is-active {
/deep/.el-menu-item.is-active {
@extend .xuanzhong;
}
.navbar {
}
.navbar {
height: $headerHeight;
overflow: hidden;
position: relative;
......@@ -258,5 +258,5 @@
}
}
}
}
}
</style>
......
......@@ -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 {
......