|
@@ -272,26 +272,26 @@ const router = new VueRouter({
|
|
|
routes,
|
|
|
});
|
|
|
|
|
|
-router.beforeEach(async (to, form, next) => {
|
|
|
- if (to.name == 'user_index') {
|
|
|
- let res = await store.dispatch('login/toGetUser');
|
|
|
- if (res && res.uid) {
|
|
|
- next();
|
|
|
- } else {
|
|
|
- let key = sessionStorage.getItem('token');
|
|
|
- let user = jwt.decode(key);
|
|
|
- if (user && user.uid) {
|
|
|
- store.commit('setUser', user, { root: true });
|
|
|
- next();
|
|
|
- } else {
|
|
|
- next({ name: 'login' });
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- let res = await store.dispatch('login/toGetUser');
|
|
|
- next();
|
|
|
- }
|
|
|
-});
|
|
|
+// router.beforeEach(async (to, form, next) => {
|
|
|
+// if (to.name == 'user_index') {
|
|
|
+// let res = await store.dispatch('login/toGetUser');
|
|
|
+// if (res && res.uid) {
|
|
|
+// next();
|
|
|
+// } else {
|
|
|
+// let key = sessionStorage.getItem('token');
|
|
|
+// let user = jwt.decode(key);
|
|
|
+// if (user && user.uid) {
|
|
|
+// store.commit('setUser', user, { root: true });
|
|
|
+// next();
|
|
|
+// } else {
|
|
|
+// next({ name: 'login' });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// let res = await store.dispatch('login/toGetUser');
|
|
|
+// next();
|
|
|
+// }
|
|
|
+// });
|
|
|
const originalPush = VueRouter.prototype.push;
|
|
|
VueRouter.prototype.push = function push(location, onResolve, onReject) {
|
|
|
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
|