|
@@ -1,52 +1,59 @@
|
1
|
|
-import router from "./router";
|
2
|
|
-import store from "./store";
|
3
|
|
-import NProgress from "nprogress"; // progress bar
|
4
|
|
-import "nprogress/nprogress.css"; // progress bar style
|
|
1
|
+import router from './router'
|
|
2
|
+import store from './store'
|
|
3
|
+import NProgress from 'nprogress' // progress bar
|
|
4
|
+import 'nprogress/nprogress.css' // progress bar style
|
5
|
5
|
|
6
|
|
-NProgress.configure({ showSpinner: false }); // NProgress Configuration
|
|
6
|
+NProgress.configure({
|
|
7
|
+ showSpinner: false
|
|
8
|
+}) // NProgress Configuration
|
7
|
9
|
|
8
|
|
-const loginWhiteList = ["/token/verify", "/401", "/404"]; // 登录验证白名单
|
9
|
|
-const permissionWhiteList = loginWhiteList.concat(["/"]); // 权限验证白名单
|
|
10
|
+const loginWhiteList = ['/token/verify', '/401', '/404'] // 登录验证白名单
|
|
11
|
+const permissionWhiteList = loginWhiteList.concat(['/']) // 权限验证白名单
|
10
|
12
|
|
11
|
13
|
router.beforeEach((to, from, next) => {
|
12
|
14
|
// 线上注释
|
13
|
|
- if (!store.getters.configlist || store.getters.configlist === undefined || store.getters.configlist.length <= 0) {
|
14
|
|
- store.dispatch('VerifyConfigList', []).then(() => {
|
15
|
|
- next()
|
16
|
|
- })
|
17
|
|
- }
|
18
|
|
- if (store.getters.permission_routers === undefined) {
|
19
|
|
- store.dispatch('xt_GenerateRoutes', []).then(() => {
|
20
|
|
- next()
|
21
|
|
- })
|
22
|
|
- } else {
|
23
|
|
- next()
|
24
|
|
- }
|
25
|
|
- return
|
|
15
|
+ // if (!store.getters.configlist || store.getters.configlist === undefined || store.getters.configlist.length <= 0) {
|
|
16
|
+ // store.dispatch('VerifyConfigList', []).then(() => {
|
|
17
|
+ // next()
|
|
18
|
+ // })
|
|
19
|
+ // }
|
|
20
|
+ // if (store.getters.permission_routers === undefined) {
|
|
21
|
+ // store.dispatch('xt_GenerateRoutes', []).then(() => {
|
|
22
|
+ // next()
|
|
23
|
+ // })
|
|
24
|
+ // } else {
|
|
25
|
+ // next()
|
|
26
|
+ // }
|
|
27
|
+ // return
|
26
|
28
|
// 线上注释
|
27
|
29
|
|
28
|
|
- NProgress.start();
|
|
30
|
+ NProgress.start()
|
29
|
31
|
// console.log(store.getters.current_role_urls.indexOf(to.path))
|
30
|
32
|
// alert('path:' + to.path)
|
31
|
33
|
// 如果 url 带有 lt (login_token)参数,则跳转到验证 token 时等待的页面
|
32
|
34
|
if (to.query.lt != null && to.query.lt.length > 0) {
|
33
|
35
|
// alert('will go to verify token: ' + to.query.lt)
|
34
|
|
- next({ path: "/token/verify", query: { token: to.query.lt } });
|
|
36
|
+ next({
|
|
37
|
+ path: '/token/verify',
|
|
38
|
+ query: {
|
|
39
|
+ token: to.query.lt
|
|
40
|
+ }
|
|
41
|
+ })
|
35
|
42
|
|
36
|
43
|
// 否则 如果没有 user 信息,则前往 sso 登录
|
37
|
44
|
} else if (store.getters.xt_user.user.id === 0) {
|
38
|
45
|
if (loginWhiteList.indexOf(to.path) !== -1) {
|
39
|
46
|
// alert('登录白名单内,跳过登录')
|
40
|
|
- next();
|
|
47
|
+ next()
|
41
|
48
|
} else {
|
42
|
49
|
// alert('前往登录')
|
43
|
|
- window.location.href = process.env.BASE_API + "/login"; // sso 地址
|
|
50
|
+ window.location.href = process.env.BASE_API + '/login' // sso 地址
|
44
|
51
|
}
|
45
|
52
|
|
46
|
53
|
// 否则 如果当前 url 不需要验证访问权限,则通过
|
47
|
54
|
} else if (permissionWhiteList.indexOf(to.path) !== -1) {
|
48
|
55
|
// alert('权限验证白名单内,直接进入')
|
49
|
|
- next();
|
|
56
|
+ next()
|
50
|
57
|
|
51
|
58
|
// 否则 如果拥有当前 url 的权限,则通过
|
52
|
59
|
// } else if (store.getters.current_role_urls.indexOf(to.path) !== -1) {
|
|
@@ -58,11 +65,11 @@ router.beforeEach((to, from, next) => {
|
58
|
65
|
// console.log(store.getters.current_role_urls)
|
59
|
66
|
// console.log(store.getters.current_role_urls.indexOf(to.path))
|
60
|
67
|
// alert('401')
|
61
|
|
- next();
|
|
68
|
+ next()
|
62
|
69
|
// next({ path: '/404' })
|
63
|
70
|
}
|
64
|
|
-});
|
|
71
|
+})
|
65
|
72
|
|
66
|
73
|
router.afterEach(() => {
|
67
|
|
- NProgress.done();
|
68
|
|
-});
|
|
74
|
+ NProgress.done()
|
|
75
|
+})
|