|
@@ -26,16 +26,21 @@ const router = createRouter({
|
|
|
},
|
|
|
routes: [...ROUTES]
|
|
|
});
|
|
|
+
|
|
|
//全局路由前置守卫
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
+ // 不需要验证登录的页面
|
|
|
+ let whitePages = [
|
|
|
+ '/pages/login/index',
|
|
|
+ '/pages/login/indexs',
|
|
|
+ '/pages/index/index',
|
|
|
+ ]
|
|
|
+
|
|
|
// next();
|
|
|
if (store.getters.token) {
|
|
|
next();
|
|
|
} else {
|
|
|
- if (
|
|
|
- // 这些页面不需要验证登录
|
|
|
- to.path == '/pages/login/index' || '/pages/login/indexs' || '/pages/index/index'
|
|
|
- ) {
|
|
|
+ if (whitePages.indexOf(to.path) >= 0) {
|
|
|
next();
|
|
|
} else {
|
|
|
next('/pages/login/index');
|