|
@@ -13,7 +13,7 @@ const routes = [
|
13
|
13
|
{
|
14
|
14
|
path: '/',
|
15
|
15
|
name: 'index',
|
16
|
|
- redirect: '/dashboard',
|
|
16
|
+ redirect: '/exception/indexWelcome', // /dashboard
|
17
|
17
|
component: () => import('@/layout/index.vue'),
|
18
|
18
|
children: [
|
19
|
19
|
...pages,
|
|
@@ -39,10 +39,14 @@ const routes = [
|
39
|
39
|
name: 'norights',
|
40
|
40
|
component: () => import('@/views/NoRights.vue'),
|
41
|
41
|
},
|
42
|
|
- {
|
43
|
|
- path: 'indexWelcome',
|
|
42
|
+ { // 显示欢迎语
|
|
43
|
+ path: '/exception/indexWelcome',
|
44
|
44
|
name: 'indexWelcome',
|
45
|
45
|
component: () => import('@/views/indexWelcome.vue'),
|
|
46
|
+ meta: {
|
|
47
|
+ menuShow: false,
|
|
48
|
+ title: '欢迎语',
|
|
49
|
+ },
|
46
|
50
|
},
|
47
|
51
|
]
|
48
|
52
|
},
|
|
@@ -58,13 +62,23 @@ const router = new VueRouter({ routes })
|
58
|
62
|
router.beforeEach((to, from, next) => {
|
59
|
63
|
NProgress.start()
|
60
|
64
|
|
61
|
|
- console.log(to)
|
62
|
65
|
const toLogin = { name: 'login', query: { from: to.name } }
|
63
|
66
|
const toIndex = { name: 'index' }
|
64
|
67
|
const to403 = { name: 'norights' }
|
65
|
68
|
|
|
69
|
+ // console.log(to)
|
|
70
|
+ /**
|
|
71
|
+ * 在 utils/index.js 文件里面,有一段代码是 获取用户信息的请求,
|
|
72
|
+ * 当后端返回状态码 401 ,就跳转到 login页面,会出现无限死循环,不停的跳转 login 页面
|
|
73
|
+ * 所以在这里判断 如果是路由是 login 就直接进行下一步
|
|
74
|
+ */
|
|
75
|
+ if (to.name === 'login') {
|
|
76
|
+ return next()
|
|
77
|
+ }
|
|
78
|
+
|
66
|
79
|
// 尝试去获取人员
|
67
|
80
|
store.dispatch('getUser').then(() => {
|
|
81
|
+
|
68
|
82
|
// 校验权限
|
69
|
83
|
if (checkAuthority(store.state, to.name)) {
|
70
|
84
|
return to.name === 'login' || to.fullPath.indexOf('/exception') > -1 ? next(toIndex) : next()
|