|
@@ -42,15 +42,26 @@ router.beforeEach((to, from, next) => {
|
|
|
|
|
|
//如果目标路由为登陆时,恢复用户原始状态
|
|
|
if (to.path === '/') {
|
|
|
- removeToken()
|
|
|
- sessionStorage.removeItem("userInfo");
|
|
|
+ // next({ path: '/home' })
|
|
|
+ // removeToken()
|
|
|
+
|
|
|
+ // localStorage.removeItem("accessToken");
|
|
|
+
|
|
|
+ console.log(removeToken())
|
|
|
document.getElementById('routers').style.display = "none"
|
|
|
} else {
|
|
|
document.getElementById('routers').style.display = "block"
|
|
|
}
|
|
|
if (to.path !== '/') {
|
|
|
- if (sessionStorage.getItem('userInfo') === null) {
|
|
|
- next({ path: '/' })
|
|
|
+ if (localStorage.getItem('accessToken') === null) {
|
|
|
+
|
|
|
+ // 本地存储的accessToken不存在时,跳转至后台登录页
|
|
|
+ // alert('本地存储的accessToken不存在')
|
|
|
+
|
|
|
+ window.location.href = 'https://wx.ewoogi.com/adminfiv/#/login'
|
|
|
+
|
|
|
+
|
|
|
+ // next({ path: '/' })
|
|
|
document.getElementById('routers').style.display = "none"
|
|
|
// setTimeout(() => {
|
|
|
// ElMessage.warning({
|
|
@@ -60,6 +71,8 @@ router.beforeEach((to, from, next) => {
|
|
|
// }, 100);
|
|
|
|
|
|
} else {
|
|
|
+
|
|
|
+ // alert('本地存储的accessToken存在')
|
|
|
next();
|
|
|
|
|
|
}
|