|
@@ -1,12 +1,12 @@
|
|
|
-import { createRouter, createWebHistory } from 'vue-router'
|
|
|
-import store from '@/stores/counter'
|
|
|
-import axios from 'axios'
|
|
|
+import { createRouter, createWebHistory } from 'vue-router';
|
|
|
+import store from '@/stores/counter';
|
|
|
+import axios from 'axios';
|
|
|
|
|
|
-import common from './module/common'
|
|
|
+import common from './module/common';
|
|
|
|
|
|
-import system from './module/system'
|
|
|
+import system from './module/system';
|
|
|
|
|
|
-import account from './module/account'
|
|
|
+import account from './module/account';
|
|
|
|
|
|
const router = createRouter({
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
@@ -34,27 +34,27 @@ const router = createRouter({
|
|
|
]
|
|
|
}
|
|
|
]
|
|
|
-})
|
|
|
+});
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
- document.title = `${to.meta.title} `
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- next()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-})
|
|
|
+ document.title = `${to.meta.title} `;
|
|
|
+ const token = localStorage.getItem('token');
|
|
|
+ if (token) {
|
|
|
+ const res = await axios.request({
|
|
|
+ method: 'get',
|
|
|
+ url: '/zkzx/v2/api/token/tokenView',
|
|
|
+ responseType: 'json',
|
|
|
+ headers: {
|
|
|
+ token: token
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(res.data);
|
|
|
+ if (res.data.errcode == '0') {
|
|
|
+ store.commit('setUser', res.data.data, { root: true });
|
|
|
+ }
|
|
|
+ next();
|
|
|
+ } else {
|
|
|
+ window.alert('无登录信息,无法打开');
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
-export default router
|
|
|
+export default router;
|