diff --git a/frontend/src/business/components/common/head/HeaderUser.vue b/frontend/src/business/components/common/head/HeaderUser.vue index 6ec894f292..da6e482f5e 100644 --- a/frontend/src/business/components/common/head/HeaderUser.vue +++ b/frontend/src/business/components/common/head/HeaderUser.vue @@ -31,6 +31,7 @@ break; case "logout": this.$get("/signout", function () { + alert("signout"); localStorage.clear(); window.location.href = "/login"; }); diff --git a/frontend/src/business/components/common/router/router.js b/frontend/src/business/components/common/router/router.js index 9aba096521..1326953135 100644 --- a/frontend/src/business/components/common/router/router.js +++ b/frontend/src/business/components/common/router/router.js @@ -31,6 +31,7 @@ import TestPlanView from "../../track/plan/view/TestPlanView"; import TestCase from "../../track/case/TestCase"; import TestTrack from "../../track/TestTrack"; import ApiReportList from "../../api/report/ApiReportList"; +import axios from "axios"; Vue.use(VueRouter); @@ -244,4 +245,18 @@ const router = new VueRouter({ ] }); + +router.beforeEach((to, from, next) => { + //解决localStorage清空,cookie没失效导致的卡死问题 + if (!localStorage.getItem('Admin-Token')) { + axios.get("/signout"); + console.log("signout"); + localStorage.setItem('Admin-Token', "{}"); + window.location.href = "/login"; + next(); + } else { + next(); + } +}); + export default router