|
@@ -1,18 +1,8 @@
|
|
|
import store from '@/store/index';
|
|
|
|
|
|
-const checkLogin = router => {
|
|
|
+const checkLogin = (router, func) => {
|
|
|
router.beforeEach(async (to, form, next) => {
|
|
|
- let res = await store.dispatch('login/toGetUser');
|
|
|
- // if (to.name === 'login') {
|
|
|
- // next();
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // let user = store.state.user;
|
|
|
- // if (user) {
|
|
|
- // next();
|
|
|
- // }
|
|
|
- // //下面是没登录的情况,需要跳转页面到用户未登录页
|
|
|
- // else next({ name: 'login' });
|
|
|
+ let res = await store.dispatch('login/toGetUser', func ? func : null);
|
|
|
next();
|
|
|
});
|
|
|
};
|