|
@@ -43,46 +43,35 @@ router.beforeEach((to, from, next) => {
|
|
|
document.title = to.meta.title
|
|
|
}
|
|
|
|
|
|
- //如果目标路由为登陆时,恢复用户原始状态
|
|
|
- if (to.path === '/') {
|
|
|
- next({ path: '/home' })
|
|
|
- // next()
|
|
|
-
|
|
|
- // removeToken()
|
|
|
-
|
|
|
- // localStorage.removeItem("accessToken");
|
|
|
-
|
|
|
- console.log(removeToken())
|
|
|
- document.getElementById('routers').style.display = "none"
|
|
|
- } else {
|
|
|
- document.getElementById('routers').style.display = "block"
|
|
|
- }
|
|
|
if (to.path !== '/') {
|
|
|
if (localStorage.getItem('accessToken') === null) {
|
|
|
+ removeToken()//不用管
|
|
|
// if (localStorage.getItem('userInfo') === null) {
|
|
|
|
|
|
// 本地存储的accessToken不存在时,跳转至后台登录页
|
|
|
// alert('本地存储的accessToken不存在')
|
|
|
|
|
|
- window.location.href = 'https://wx.ewoogi.com/manage/#/login'
|
|
|
-
|
|
|
+ console.log(window.location)
|
|
|
+ if (window.location.host === 'localhost:8080') {
|
|
|
+ next({ path: '/' })
|
|
|
+ } else {
|
|
|
+ window.location.href = 'https://wx.ewoogi.com/manage/#/login'
|
|
|
+ }
|
|
|
|
|
|
- // next({ path: '/' })
|
|
|
document.getElementById('routers').style.display = "none"
|
|
|
- // setTimeout(() => {
|
|
|
- // ElMessage.warning({
|
|
|
- // message: '请登录后重试!',
|
|
|
- // type: 'warning'
|
|
|
- // });
|
|
|
- // }, 100);
|
|
|
+ // setTimeout(() => {
|
|
|
+ // ElMessage.warning({
|
|
|
+ // message: '请登录后重试!',
|
|
|
+ // type: 'warning'
|
|
|
+ // })
|
|
|
+ // }, 100);
|
|
|
|
|
|
} else {
|
|
|
-
|
|
|
// alert('本地存储的accessToken存在')
|
|
|
next();
|
|
|
-
|
|
|
}
|
|
|
} else {
|
|
|
+ document.getElementById('routers').style.display = "block"
|
|
|
//路由的next必须存在,否则无法进入下一页
|
|
|
next()
|
|
|
}
|