vue2-client 1.6.49 → 1.6.51-single
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +81 -81
- package/src/router/async/router.map.js +74 -68
- package/src/router/guards.js +148 -113
- package/src/utils/login.js +101 -0
package/package.json
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vue2-client",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"private": false,
|
|
5
|
-
"scripts": {
|
|
6
|
-
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
|
|
7
|
-
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
|
|
8
|
-
"test:unit": "vue-cli-service test:unit",
|
|
9
|
-
"lint": "vue-cli-service lint",
|
|
10
|
-
"build:preview": "vue-cli-service build --mode preview",
|
|
11
|
-
"lint:nofix": "vue-cli-service lint --no-fix"
|
|
12
|
-
},
|
|
13
|
-
"dependencies": {
|
|
14
|
-
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
15
|
-
"@antv/data-set": "^0.11.8",
|
|
16
|
-
"@antv/g2plot": "^2.4.29",
|
|
17
|
-
"@vue/babel-preset-jsx": "^1.4.0",
|
|
18
|
-
"animate.css": "^4.1.1",
|
|
19
|
-
"ant-design-vue": "^1.7.8",
|
|
20
|
-
"axios": "^0.27.2",
|
|
21
|
-
"clipboard": "^2.0.11",
|
|
22
|
-
"core-js": "^3.30.1",
|
|
23
|
-
"crypto-js": "^4.1.1",
|
|
24
|
-
"date-fns": "^2.29.3",
|
|
25
|
-
"default-passive-events": "^2.0.0",
|
|
26
|
-
"enquire.js": "^2.1.6",
|
|
27
|
-
"file-saver": "^2.0.5",
|
|
28
|
-
"highlight.js": "^11.7.0",
|
|
29
|
-
"js-base64": "^3.7.5",
|
|
30
|
-
"js-cookie": "^2.2.1",
|
|
31
|
-
"jsencrypt": "^3.3.2",
|
|
32
|
-
"lodash.get": "^4.4.2",
|
|
33
|
-
"mockjs": "^1.1.0",
|
|
34
|
-
"nprogress": "^0.2.0",
|
|
35
|
-
"videojs-contrib-hls": "^5.15.0",
|
|
36
|
-
"viser-vue": "^2.4.8",
|
|
37
|
-
"vue": "2.6.14",
|
|
38
|
-
"vue-i18n": "^8.28.2",
|
|
39
|
-
"vue-json-viewer": "^2.2.22",
|
|
40
|
-
"vue-router": "^3.6.5",
|
|
41
|
-
"vue-video-player": "^5.0.2",
|
|
42
|
-
"vuedraggable": "^2.24.3",
|
|
43
|
-
"vuex": "^3.6.2",
|
|
44
|
-
"xlsx": "0.18.5"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@ant-design/colors": "^7.0.0",
|
|
48
|
-
"@babel/core": "^7.21.4",
|
|
49
|
-
"@vue/cli-plugin-babel": "^4.5.19",
|
|
50
|
-
"@vue/cli-plugin-eslint": "^4.5.19",
|
|
51
|
-
"@vue/cli-service": "^4.5.19",
|
|
52
|
-
"@vue/eslint-config-standard": "^4.0.0",
|
|
53
|
-
"@vuepress/plugin-back-to-top": "^1.9.9",
|
|
54
|
-
"babel-eslint": "^10.1.0",
|
|
55
|
-
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
56
|
-
"babel-polyfill": "^6.26.0",
|
|
57
|
-
"compression-webpack-plugin": "^4.0.1",
|
|
58
|
-
"deepmerge": "^4.3.1",
|
|
59
|
-
"eslint": "^6.8.0",
|
|
60
|
-
"eslint-plugin-import": "^2.26.0",
|
|
61
|
-
"eslint-plugin-node": "^11.1.0",
|
|
62
|
-
"eslint-plugin-promise": "^4.3.1",
|
|
63
|
-
"eslint-plugin-standard": "^4.1.0",
|
|
64
|
-
"eslint-plugin-vue": "^6.2.2",
|
|
65
|
-
"fast-deep-equal": "^3.1.3",
|
|
66
|
-
"less-loader": "^6.2.0",
|
|
67
|
-
"script-loader": "^0.7.2",
|
|
68
|
-
"style-resources-loader": "^1.5.0",
|
|
69
|
-
"vue-cli-plugin-style-resources-loader": "^0.1.5",
|
|
70
|
-
"vue-template-compiler": "2.6.14",
|
|
71
|
-
"vuepress": "^1.9.9",
|
|
72
|
-
"webpack": "^4.46.0",
|
|
73
|
-
"webpack-theme-color-replacer": "^1.4.7",
|
|
74
|
-
"whatwg-fetch": "^3.6.2"
|
|
75
|
-
},
|
|
76
|
-
"browserslist": [
|
|
77
|
-
"> 1%",
|
|
78
|
-
"last 2 versions",
|
|
79
|
-
"not ie <= 10"
|
|
80
|
-
]
|
|
81
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vue2-client",
|
|
3
|
+
"version": "1.6.51-single",
|
|
4
|
+
"private": false,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
|
|
7
|
+
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
|
|
8
|
+
"test:unit": "vue-cli-service test:unit",
|
|
9
|
+
"lint": "vue-cli-service lint",
|
|
10
|
+
"build:preview": "vue-cli-service build --mode preview",
|
|
11
|
+
"lint:nofix": "vue-cli-service lint --no-fix"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
15
|
+
"@antv/data-set": "^0.11.8",
|
|
16
|
+
"@antv/g2plot": "^2.4.29",
|
|
17
|
+
"@vue/babel-preset-jsx": "^1.4.0",
|
|
18
|
+
"animate.css": "^4.1.1",
|
|
19
|
+
"ant-design-vue": "^1.7.8",
|
|
20
|
+
"axios": "^0.27.2",
|
|
21
|
+
"clipboard": "^2.0.11",
|
|
22
|
+
"core-js": "^3.30.1",
|
|
23
|
+
"crypto-js": "^4.1.1",
|
|
24
|
+
"date-fns": "^2.29.3",
|
|
25
|
+
"default-passive-events": "^2.0.0",
|
|
26
|
+
"enquire.js": "^2.1.6",
|
|
27
|
+
"file-saver": "^2.0.5",
|
|
28
|
+
"highlight.js": "^11.7.0",
|
|
29
|
+
"js-base64": "^3.7.5",
|
|
30
|
+
"js-cookie": "^2.2.1",
|
|
31
|
+
"jsencrypt": "^3.3.2",
|
|
32
|
+
"lodash.get": "^4.4.2",
|
|
33
|
+
"mockjs": "^1.1.0",
|
|
34
|
+
"nprogress": "^0.2.0",
|
|
35
|
+
"videojs-contrib-hls": "^5.15.0",
|
|
36
|
+
"viser-vue": "^2.4.8",
|
|
37
|
+
"vue": "2.6.14",
|
|
38
|
+
"vue-i18n": "^8.28.2",
|
|
39
|
+
"vue-json-viewer": "^2.2.22",
|
|
40
|
+
"vue-router": "^3.6.5",
|
|
41
|
+
"vue-video-player": "^5.0.2",
|
|
42
|
+
"vuedraggable": "^2.24.3",
|
|
43
|
+
"vuex": "^3.6.2",
|
|
44
|
+
"xlsx": "0.18.5"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@ant-design/colors": "^7.0.0",
|
|
48
|
+
"@babel/core": "^7.21.4",
|
|
49
|
+
"@vue/cli-plugin-babel": "^4.5.19",
|
|
50
|
+
"@vue/cli-plugin-eslint": "^4.5.19",
|
|
51
|
+
"@vue/cli-service": "^4.5.19",
|
|
52
|
+
"@vue/eslint-config-standard": "^4.0.0",
|
|
53
|
+
"@vuepress/plugin-back-to-top": "^1.9.9",
|
|
54
|
+
"babel-eslint": "^10.1.0",
|
|
55
|
+
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
56
|
+
"babel-polyfill": "^6.26.0",
|
|
57
|
+
"compression-webpack-plugin": "^4.0.1",
|
|
58
|
+
"deepmerge": "^4.3.1",
|
|
59
|
+
"eslint": "^6.8.0",
|
|
60
|
+
"eslint-plugin-import": "^2.26.0",
|
|
61
|
+
"eslint-plugin-node": "^11.1.0",
|
|
62
|
+
"eslint-plugin-promise": "^4.3.1",
|
|
63
|
+
"eslint-plugin-standard": "^4.1.0",
|
|
64
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
65
|
+
"fast-deep-equal": "^3.1.3",
|
|
66
|
+
"less-loader": "^6.2.0",
|
|
67
|
+
"script-loader": "^0.7.2",
|
|
68
|
+
"style-resources-loader": "^1.5.0",
|
|
69
|
+
"vue-cli-plugin-style-resources-loader": "^0.1.5",
|
|
70
|
+
"vue-template-compiler": "2.6.14",
|
|
71
|
+
"vuepress": "^1.9.9",
|
|
72
|
+
"webpack": "^4.46.0",
|
|
73
|
+
"webpack-theme-color-replacer": "^1.4.7",
|
|
74
|
+
"whatwg-fetch": "^3.6.2"
|
|
75
|
+
},
|
|
76
|
+
"browserslist": [
|
|
77
|
+
"> 1%",
|
|
78
|
+
"last 2 versions",
|
|
79
|
+
"not ie <= 10"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
@@ -1,68 +1,74 @@
|
|
|
1
|
-
const { homePage } = require(
|
|
2
|
-
// 视图组件
|
|
3
|
-
const view = {
|
|
4
|
-
tabs: () => import(
|
|
5
|
-
blank: () => import(
|
|
6
|
-
page: () => import(
|
|
7
|
-
}
|
|
8
|
-
// 动态路由对象定义
|
|
9
|
-
const routerResource = {}
|
|
10
|
-
// --------------------------------------基本视图组件--------------------------------------
|
|
11
|
-
// 空白视图
|
|
12
|
-
routerResource.blank = view.blank
|
|
13
|
-
// 单页面视图
|
|
14
|
-
routerResource.singlePage = view.blank
|
|
15
|
-
|
|
16
|
-
// --------------------------------------仪表盘--------------------------------------
|
|
17
|
-
routerResource.dashboard = view.blank
|
|
18
|
-
// 工作台
|
|
19
|
-
routerResource.workplace = () =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
routerResource.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
routerResource.
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
const { homePage } = require("../../config");
|
|
2
|
+
// 视图组件
|
|
3
|
+
const view = {
|
|
4
|
+
tabs: () => import("@vue2-client/layouts/tabs"),
|
|
5
|
+
blank: () => import("@vue2-client/layouts/BlankView"),
|
|
6
|
+
page: () => import("@vue2-client/layouts/PageView"),
|
|
7
|
+
};
|
|
8
|
+
// 动态路由对象定义
|
|
9
|
+
const routerResource = {};
|
|
10
|
+
// --------------------------------------基本视图组件--------------------------------------
|
|
11
|
+
// 空白视图
|
|
12
|
+
routerResource.blank = view.blank;
|
|
13
|
+
// 单页面视图
|
|
14
|
+
routerResource.singlePage = view.blank;
|
|
15
|
+
|
|
16
|
+
// --------------------------------------仪表盘--------------------------------------
|
|
17
|
+
routerResource.dashboard = view.blank;
|
|
18
|
+
// 工作台
|
|
19
|
+
routerResource.workplace = () =>
|
|
20
|
+
import("@vue2-client/pages/dashboard/workplace");
|
|
21
|
+
// --------------------------------------系统配置--------------------------------------
|
|
22
|
+
routerResource.system = view.blank;
|
|
23
|
+
// 字典管理
|
|
24
|
+
routerResource.dictionaryManage = () =>
|
|
25
|
+
import("@vue2-client/pages/system/dictionary");
|
|
26
|
+
// 查询配置管理
|
|
27
|
+
routerResource.queryParamsManage = () =>
|
|
28
|
+
import("@vue2-client/pages/system/queryParams");
|
|
29
|
+
// 文件管理
|
|
30
|
+
routerResource.fileManager = () => import("@vue2-client/pages/system/file");
|
|
31
|
+
// 登录日志
|
|
32
|
+
routerResource.loginInfor = () =>
|
|
33
|
+
import("@vue2-client/pages/system/monitor/loginInfor");
|
|
34
|
+
// 操作日志
|
|
35
|
+
routerResource.operLog = () =>
|
|
36
|
+
import("@vue2-client/pages/system/monitor/operLog");
|
|
37
|
+
// 系统问题反馈工单
|
|
38
|
+
routerResource.submitTicket = () => import("@vue2-client/pages/system/ticket");
|
|
39
|
+
// 系统设置
|
|
40
|
+
routerResource.settings = () => import("@vue2-client/pages/system/settings");
|
|
41
|
+
|
|
42
|
+
// 基础路由组件注册
|
|
43
|
+
const routerMap = {
|
|
44
|
+
login: {
|
|
45
|
+
authority: "*",
|
|
46
|
+
path: "/login",
|
|
47
|
+
component: () => import("@vue2-client/pages/login"),
|
|
48
|
+
},
|
|
49
|
+
root: {
|
|
50
|
+
path: "/",
|
|
51
|
+
name: "首页",
|
|
52
|
+
redirect: homePage,
|
|
53
|
+
component:
|
|
54
|
+
process.env.VUE_APP_SINGLE_PAPER === "TRUE" ? view.blank : view.tabs,
|
|
55
|
+
},
|
|
56
|
+
exp403: {
|
|
57
|
+
authority: "*",
|
|
58
|
+
name: "exp403",
|
|
59
|
+
path: "403",
|
|
60
|
+
component: () => import("@vue2-client/pages/exception/403"),
|
|
61
|
+
},
|
|
62
|
+
exp404: {
|
|
63
|
+
name: "exp404",
|
|
64
|
+
path: "404",
|
|
65
|
+
component: () => import("@vue2-client/pages/exception/404"),
|
|
66
|
+
},
|
|
67
|
+
exp500: {
|
|
68
|
+
name: "exp500",
|
|
69
|
+
path: "500",
|
|
70
|
+
component: () => import("@vue2-client/pages/exception/500"),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
Object.assign(routerMap, routerResource);
|
|
74
|
+
export default routerMap;
|
package/src/router/guards.js
CHANGED
|
@@ -1,113 +1,148 @@
|
|
|
1
|
-
import { hasAuthority } from
|
|
2
|
-
import { loginIgnore } from
|
|
3
|
-
import { checkAuthorization } from
|
|
4
|
-
import NProgress from
|
|
5
|
-
import { logout } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
import { hasAuthority } from "@vue2-client/utils/authority-utils";
|
|
2
|
+
import { loginIgnore } from "@vue2-client/router/index";
|
|
3
|
+
import { checkAuthorization } from "@vue2-client/utils/request";
|
|
4
|
+
import NProgress from "nprogress";
|
|
5
|
+
import { logout } from "@vue2-client/services/user";
|
|
6
|
+
import { startLogin } from "vue2-client/src/utils/login";
|
|
7
|
+
import AES from "vue2-client/src/utils/EncryptUtil";
|
|
8
|
+
NProgress.configure({ showSpinner: false });
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 进度条开始
|
|
12
|
+
* @param to
|
|
13
|
+
* @param form
|
|
14
|
+
* @param next
|
|
15
|
+
*/
|
|
16
|
+
const progressStart = (to, from, next) => {
|
|
17
|
+
// start progress bar
|
|
18
|
+
if (!NProgress.isStarted()) {
|
|
19
|
+
NProgress.start();
|
|
20
|
+
}
|
|
21
|
+
next();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 登录守卫
|
|
26
|
+
* @param to
|
|
27
|
+
* @param form
|
|
28
|
+
* @param next
|
|
29
|
+
* @param options
|
|
30
|
+
*/
|
|
31
|
+
const loginGuard = (to, from, next, options) => {
|
|
32
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
33
|
+
const token = urlParams.get("token");
|
|
34
|
+
if (token) {
|
|
35
|
+
const { AESDecrypt } = AES;
|
|
36
|
+
const info = AESDecrypt(token, "3KMKqvgwR8ULbR8Z");
|
|
37
|
+
const { store, message, router } = options;
|
|
38
|
+
if (
|
|
39
|
+
(!loginIgnore.includes(to) || to.name === "404") &&
|
|
40
|
+
!checkAuthorization()
|
|
41
|
+
) {
|
|
42
|
+
startLogin({
|
|
43
|
+
...info,
|
|
44
|
+
store,
|
|
45
|
+
router,
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
const roles = store.getters["account/roles"];
|
|
49
|
+
const user = localStorage.getItem(process.env.VUE_APP_USER_KEY);
|
|
50
|
+
const setUser = store._mutations["account/setUser"][0];
|
|
51
|
+
setUser(user);
|
|
52
|
+
if (roles.length === 0 && !loginIgnore.includes(to)) {
|
|
53
|
+
message.warning("登录已失效,请重新登录");
|
|
54
|
+
logout().finally((res) => {
|
|
55
|
+
next({ path: "/login" });
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
next();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
const { store, message } = options;
|
|
63
|
+
if (
|
|
64
|
+
(!loginIgnore.includes(to) || to.name === "404") &&
|
|
65
|
+
!checkAuthorization()
|
|
66
|
+
) {
|
|
67
|
+
message.warning("登录已失效,请重新登录");
|
|
68
|
+
next({ path: "/login" });
|
|
69
|
+
} else {
|
|
70
|
+
const roles = store.getters["account/roles"];
|
|
71
|
+
if (roles.length === 0 && !loginIgnore.includes(to)) {
|
|
72
|
+
message.warning("登录已失效,请重新登录");
|
|
73
|
+
logout().finally((res) => {
|
|
74
|
+
next({ path: "/login" });
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
next();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 权限守卫
|
|
85
|
+
* @param to
|
|
86
|
+
* @param form
|
|
87
|
+
* @param next
|
|
88
|
+
* @param options
|
|
89
|
+
*/
|
|
90
|
+
const authorityGuard = (to, from, next, options) => {
|
|
91
|
+
const { store, message } = options;
|
|
92
|
+
const permissions = store.getters["account/permissions"];
|
|
93
|
+
const roles = store.getters["account/roles"];
|
|
94
|
+
if (!hasAuthority(to, permissions, roles)) {
|
|
95
|
+
message.warning(`对不起,您无权访问页面: ${to.fullPath},请联系管理员`);
|
|
96
|
+
next({ path: "/403" });
|
|
97
|
+
// NProgress.done()
|
|
98
|
+
} else {
|
|
99
|
+
next();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 混合导航模式下一级菜单跳转重定向
|
|
105
|
+
* @param to
|
|
106
|
+
* @param from
|
|
107
|
+
* @param next
|
|
108
|
+
* @param options
|
|
109
|
+
* @returns {*}
|
|
110
|
+
*/
|
|
111
|
+
const redirectGuard = (to, from, next, options) => {
|
|
112
|
+
const { store } = options;
|
|
113
|
+
const getFirstChild = (routes) => {
|
|
114
|
+
const route = routes[0];
|
|
115
|
+
if (!route.children || route.children.length === 0) {
|
|
116
|
+
return route;
|
|
117
|
+
}
|
|
118
|
+
return getFirstChild(route.children);
|
|
119
|
+
};
|
|
120
|
+
if (store.state.setting.layout === "mix") {
|
|
121
|
+
const firstMenu = store.getters["setting/firstMenu"];
|
|
122
|
+
if (firstMenu.find((item) => item.fullPath === to.fullPath)) {
|
|
123
|
+
store.commit("setting/setActivatedFirst", to.fullPath);
|
|
124
|
+
const subMenu = store.getters["setting/subMenu"];
|
|
125
|
+
if (subMenu.length > 0) {
|
|
126
|
+
const redirect = getFirstChild(subMenu);
|
|
127
|
+
return next({ path: redirect.fullPath });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
next();
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 进度条结束
|
|
136
|
+
* @param to
|
|
137
|
+
* @param form
|
|
138
|
+
* @param options
|
|
139
|
+
*/
|
|
140
|
+
const progressDone = () => {
|
|
141
|
+
// finish progress bar
|
|
142
|
+
NProgress.done();
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default {
|
|
146
|
+
beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
|
|
147
|
+
afterEach: [progressDone],
|
|
148
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { getRoutesConfig, login, V4Login } from "@vue2-client/services/user";
|
|
2
|
+
import { loadRoutes, funcToRouter } from "@vue2-client/utils/routerUtil";
|
|
3
|
+
import JSEncrypt from "jsencrypt";
|
|
4
|
+
import { ACCESS_TOKEN } from "@vue2-client/store/mutation-types";
|
|
5
|
+
import { positions } from "@vue2-client/mock/common";
|
|
6
|
+
import { timeFix } from "@vue2-client/utils/util";
|
|
7
|
+
import { indexedDB } from "@vue2-client/utils/indexedDB";
|
|
8
|
+
import Vue from "vue";
|
|
9
|
+
import { message } from "ant-design-vue";
|
|
10
|
+
import { setAuthorization } from "@vue2-client/utils/request";
|
|
11
|
+
function setAccessToken(data) {
|
|
12
|
+
if (data) {
|
|
13
|
+
localStorage.setItem(ACCESS_TOKEN, data);
|
|
14
|
+
let timestamp = new Date().getTime(); // 当前的时间戳
|
|
15
|
+
timestamp = timestamp + 12 * 60 * 60 * 1000;
|
|
16
|
+
// 格式化时间获取年月日, 登陆过期时间
|
|
17
|
+
const dateAfter = new Date(timestamp);
|
|
18
|
+
setAuthorization({ token: data, expireAt: dateAfter });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function afterGeneral(result, options) {
|
|
22
|
+
const { name, password, store } = options;
|
|
23
|
+
const user = Object.assign(
|
|
24
|
+
{
|
|
25
|
+
id: result.id,
|
|
26
|
+
username: result.ename,
|
|
27
|
+
password: password,
|
|
28
|
+
name: result.name,
|
|
29
|
+
avatar:
|
|
30
|
+
"https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png",
|
|
31
|
+
address: "西安市",
|
|
32
|
+
position: positions[0],
|
|
33
|
+
},
|
|
34
|
+
result
|
|
35
|
+
);
|
|
36
|
+
const setUser = store._mutations["account/setUser"][0];
|
|
37
|
+
const setPermissions = store._mutations["account/setPermissions"][0];
|
|
38
|
+
const setRoles = store._mutations["account/setRoles"][0];
|
|
39
|
+
setUser(user);
|
|
40
|
+
setPermissions([{ id: "queryForm", operation: ["add", "edit"] }]);
|
|
41
|
+
setRoles([{ id: "admin", operation: ["add", "edit", "delete"] }]);
|
|
42
|
+
loadRoutes(funcToRouter(user.functions));
|
|
43
|
+
// 每次重新登录时,清除indexedDB缓存
|
|
44
|
+
indexedDB.clear();
|
|
45
|
+
message.success(timeFix().CN + `,${result.name} 欢迎回来`, 3);
|
|
46
|
+
}
|
|
47
|
+
function afterLogin(res, options) {
|
|
48
|
+
const { name, password, store, router } = options;
|
|
49
|
+
const setting = store.state.setting;
|
|
50
|
+
const loginRes = res.states;
|
|
51
|
+
if (loginRes === "登录成功") {
|
|
52
|
+
const encrypt = new JSEncrypt();
|
|
53
|
+
encrypt.setPublicKey(
|
|
54
|
+
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB"
|
|
55
|
+
);
|
|
56
|
+
const data = encrypt.encrypt(
|
|
57
|
+
JSON.stringify({ username: name, password: password })
|
|
58
|
+
);
|
|
59
|
+
// 获取路由配置
|
|
60
|
+
getRoutesConfig(data, setting.routeName)
|
|
61
|
+
.then((result) => {
|
|
62
|
+
Vue.$login
|
|
63
|
+
.login(result)
|
|
64
|
+
.then(() => {
|
|
65
|
+
// V3任何情况首位加入资源管理
|
|
66
|
+
const resourceManageMain = {
|
|
67
|
+
name: "资源管理",
|
|
68
|
+
icon: "api",
|
|
69
|
+
position: 1,
|
|
70
|
+
link: "resourceManageMain",
|
|
71
|
+
};
|
|
72
|
+
result.functions.unshift(resourceManageMain);
|
|
73
|
+
afterGeneral(result, options);
|
|
74
|
+
setAccessToken(data);
|
|
75
|
+
if (result.deps === "用户工单登记") {
|
|
76
|
+
router.push(setting.ticketPage).catch(() => {});
|
|
77
|
+
} else {
|
|
78
|
+
router.push(setting.homePage).catch(() => {});
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
.finally(() => {});
|
|
82
|
+
})
|
|
83
|
+
.catch((res) => {});
|
|
84
|
+
} else {
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function startLogin(options) {
|
|
88
|
+
const { name, password, store } = options;
|
|
89
|
+
const setting = store.state.setting;
|
|
90
|
+
switch (setting.compatible) {
|
|
91
|
+
case "V2":
|
|
92
|
+
case "V3": {
|
|
93
|
+
login(name, password)
|
|
94
|
+
.then((res) => {
|
|
95
|
+
afterLogin(res, options);
|
|
96
|
+
})
|
|
97
|
+
.catch((msg) => {});
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|