guhongwei 4 лет назад
Родитель
Сommit
5278609dd3
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      src/router/before.js

+ 9 - 0
src/router/before.js

@@ -0,0 +1,9 @@
+import store from '@/store/index';
+
+const checkLogin = (router, func) => {
+  router.beforeEach(async (to, form, next) => {
+    let res = await store.dispatch('login/toGetUser', func ? func : null);
+    next();
+  });
+};
+export default checkLogin;