|
@@ -2,6 +2,14 @@ import store from '@/store/index';
|
|
|
|
|
|
const checkLogin = (router, func) => {
|
|
|
router.beforeEach(async (to, form, next) => {
|
|
|
+ if (to.name == 'index') {
|
|
|
+ let token = localStorage.getItem('token');
|
|
|
+ if (token) {
|
|
|
+ next();
|
|
|
+ } else {
|
|
|
+ next({ name: 'login' });
|
|
|
+ }
|
|
|
+ }
|
|
|
let res = await store.dispatch('login/toGetUser', func ? func : null);
|
|
|
next();
|
|
|
});
|