|
@@ -72,7 +72,21 @@ const router = new VueRouter({
|
|
|
base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,
|
|
|
routes,
|
|
|
});
|
|
|
-checkLogin(router);
|
|
|
+
|
|
|
+router.beforeEach(async (to, form, next) => {
|
|
|
+ if (to.name == 'user_index') {
|
|
|
+ let res = await store.dispatch('login/toGetUser');
|
|
|
+ if (res) {
|
|
|
+ next();
|
|
|
+ } else {
|
|
|
+ next({ name: 'login' });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+// checkLogin(router);
|
|
|
const originalPush = VueRouter.prototype.push;
|
|
|
VueRouter.prototype.push = function push(location, onResolve, onReject) {
|
|
|
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
|