vue2-client 1.10.32-alpha → 1.10.32
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 +107 -107
- package/src/App.vue +196 -183
- package/src/base-client/components/common/XAddNativeForm/demo.vue +1 -1
- package/src/base-client/components/common/XDataCard/XDataCard.vue +16 -17
- package/src/base-client/components/common/XForm/XForm.vue +393 -393
- package/src/base-client/components/common/XForm/XFormItem.vue +47 -9
- package/src/base-client/components/common/XFormGroup/XFormGroup.vue +301 -301
- package/src/base-client/components/common/XFormTable/demo.vue +2 -2
- package/src/layouts/BlankView.vue +3 -59
- package/src/router/async/router.map.js +148 -95
- package/src/router/guards.js +263 -266
- package/src/utils/routerUtil.js +450 -526
- package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +0 -121
package/src/router/guards.js
CHANGED
|
@@ -1,266 +1,263 @@
|
|
|
1
|
-
import { hasAuthority } from '@vue2-client/utils/authority-utils'
|
|
2
|
-
import { loginIgnore } from '@vue2-client/router/index'
|
|
3
|
-
import { checkAuthorization, METHOD, request } from '@vue2-client/utils/request'
|
|
4
|
-
import NProgress from 'nprogress'
|
|
5
|
-
import { logout } from '@vue2-client/services/user'
|
|
6
|
-
import {
|
|
7
|
-
startLogin,
|
|
8
|
-
checkSingleAuthorization,
|
|
9
|
-
} from '@vue2-client/utils/login'
|
|
10
|
-
import AES from '@vue2-client/utils/EncryptUtil'
|
|
11
|
-
import Vue from 'vue'
|
|
12
|
-
import { funcToRouter, loadRoutes } from '@vue2-client/utils/routerUtil'
|
|
13
|
-
import { indexedDB } from '@vue2-client/utils/indexedDB'
|
|
14
|
-
|
|
15
|
-
NProgress.configure({ showSpinner: false })
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 进度条开始
|
|
19
|
-
* @param to
|
|
20
|
-
* @param form
|
|
21
|
-
* @param next
|
|
22
|
-
*/
|
|
23
|
-
const progressStart = (to, from, next) => {
|
|
24
|
-
// start progress bar
|
|
25
|
-
if (!NProgress.isStarted()) {
|
|
26
|
-
NProgress.start()
|
|
27
|
-
}
|
|
28
|
-
next()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 登录守卫
|
|
33
|
-
* @param to
|
|
34
|
-
* @param form
|
|
35
|
-
* @param next
|
|
36
|
-
* @param options
|
|
37
|
-
*/
|
|
38
|
-
const loginGuard = (to, from, next, options) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
*
|
|
203
|
-
* @param
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
next(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*
|
|
223
|
-
* @param
|
|
224
|
-
* @
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
*
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
|
|
265
|
-
afterEach: [progressDone],
|
|
266
|
-
}
|
|
1
|
+
import { hasAuthority } from '@vue2-client/utils/authority-utils'
|
|
2
|
+
import { loginIgnore } from '@vue2-client/router/index'
|
|
3
|
+
import { checkAuthorization, METHOD, request } from '@vue2-client/utils/request'
|
|
4
|
+
import NProgress from 'nprogress'
|
|
5
|
+
import { logout } from '@vue2-client/services/user'
|
|
6
|
+
import {
|
|
7
|
+
startLogin,
|
|
8
|
+
checkSingleAuthorization,
|
|
9
|
+
} from '@vue2-client/utils/login'
|
|
10
|
+
import AES from '@vue2-client/utils/EncryptUtil'
|
|
11
|
+
import Vue from 'vue'
|
|
12
|
+
import { funcToRouter, loadRoutes } from '@vue2-client/utils/routerUtil'
|
|
13
|
+
import { indexedDB } from '@vue2-client/utils/indexedDB'
|
|
14
|
+
|
|
15
|
+
NProgress.configure({ showSpinner: false })
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 进度条开始
|
|
19
|
+
* @param to
|
|
20
|
+
* @param form
|
|
21
|
+
* @param next
|
|
22
|
+
*/
|
|
23
|
+
const progressStart = (to, from, next) => {
|
|
24
|
+
// start progress bar
|
|
25
|
+
if (!NProgress.isStarted()) {
|
|
26
|
+
NProgress.start()
|
|
27
|
+
}
|
|
28
|
+
next()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 登录守卫
|
|
33
|
+
* @param to
|
|
34
|
+
* @param form
|
|
35
|
+
* @param next
|
|
36
|
+
* @param options
|
|
37
|
+
*/
|
|
38
|
+
const loginGuard = (to, from, next, options) => {
|
|
39
|
+
if (window.__MICRO_APP_ENVIRONMENT__) {
|
|
40
|
+
window.microApp.dispatch({ type: '子应用发送给主应用的数据', to: to.path })
|
|
41
|
+
}
|
|
42
|
+
const urlParams = new URLSearchParams(window.location.search)
|
|
43
|
+
const LoginTicket = urlParams.get('LoginTicket')
|
|
44
|
+
// 如果是需要我们自己登陆的项目
|
|
45
|
+
const token = urlParams.get('token')
|
|
46
|
+
// 如果是v2 的项目 资源管理和营收分开库的那种项目 传递用户信息进来
|
|
47
|
+
const tokenV2 = urlParams.get('tokenV2')
|
|
48
|
+
// 如果是 v4 的父项目,通过localStorage传递信息
|
|
49
|
+
const V4_LOGIN_DATA_KEY = localStorage.getItem('v4LoginData')
|
|
50
|
+
if (LoginTicket) {
|
|
51
|
+
const loginTicket = decodeURIComponent(LoginTicket)
|
|
52
|
+
const { AESDecrypt } = AES
|
|
53
|
+
const info = AESDecrypt(loginTicket, '3KMKqvgwR8ULbR8Z')
|
|
54
|
+
const { store, message, router } = options
|
|
55
|
+
// 单页面通常是嵌入到v3的项目中,没有单独的清除按钮,所以需要清除indexedDB
|
|
56
|
+
indexedDB.clear()
|
|
57
|
+
if (
|
|
58
|
+
(!loginIgnore.includes(to) || to.name === '404') &&
|
|
59
|
+
!checkSingleAuthorization('SinglePage', loginTicket)
|
|
60
|
+
) {
|
|
61
|
+
localStorage.setItem('SinglePage_TOKEN', loginTicket)
|
|
62
|
+
startLogin({
|
|
63
|
+
...info,
|
|
64
|
+
pathname: window.location.pathname.replace(process.env.VUE_APP_PUBLIC_PATH, ''),
|
|
65
|
+
store,
|
|
66
|
+
router,
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
const roles = store.getters['account/roles']
|
|
70
|
+
let user = {}
|
|
71
|
+
try {
|
|
72
|
+
user = JSON.parse(localStorage.getItem(process.env.VUE_APP_USER_KEY))
|
|
73
|
+
} catch (e) {
|
|
74
|
+
user = localStorage.getItem(process.env.VUE_APP_USER_KEY)
|
|
75
|
+
}
|
|
76
|
+
const setUser = store._mutations['account/setUser'][0]
|
|
77
|
+
setUser(user)
|
|
78
|
+
if (roles.length === 0 && !loginIgnore.includes(to)) {
|
|
79
|
+
message.warning('登录已失效,请重新登录')
|
|
80
|
+
logout().finally((res) => {
|
|
81
|
+
next({ path: '/login' })
|
|
82
|
+
})
|
|
83
|
+
} else {
|
|
84
|
+
next()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} else if (token) {
|
|
88
|
+
const { AESDecrypt } = AES
|
|
89
|
+
const info = AESDecrypt(token, '3KMKqvgwR8ULbR8Z')
|
|
90
|
+
const { store, message, router } = options
|
|
91
|
+
// 单页面通常是嵌入到v3的项目中,没有单独的清除按钮,所以需要清除indexedDB
|
|
92
|
+
indexedDB.clear()
|
|
93
|
+
if (
|
|
94
|
+
(!loginIgnore.includes(to) || to.name === '404') &&
|
|
95
|
+
!checkSingleAuthorization('SinglePage', token)
|
|
96
|
+
) {
|
|
97
|
+
localStorage.setItem('SinglePage_TOKEN', token)
|
|
98
|
+
startLogin({
|
|
99
|
+
...info,
|
|
100
|
+
pathname: window.location.pathname.replace(process.env.VUE_APP_PUBLIC_PATH, ''),
|
|
101
|
+
store,
|
|
102
|
+
router,
|
|
103
|
+
})
|
|
104
|
+
} else {
|
|
105
|
+
const roles = store.getters['account/roles']
|
|
106
|
+
let user = {}
|
|
107
|
+
try {
|
|
108
|
+
user = JSON.parse(localStorage.getItem(process.env.VUE_APP_USER_KEY))
|
|
109
|
+
} catch (e) {
|
|
110
|
+
user = localStorage.getItem(process.env.VUE_APP_USER_KEY)
|
|
111
|
+
}
|
|
112
|
+
const setUser = store._mutations['account/setUser'][0]
|
|
113
|
+
setUser(user)
|
|
114
|
+
if (roles.length === 0 && !loginIgnore.includes(to)) {
|
|
115
|
+
message.warning('登录已失效,请重新登录')
|
|
116
|
+
logout().finally((res) => {
|
|
117
|
+
next({ path: '/login' })
|
|
118
|
+
})
|
|
119
|
+
} else {
|
|
120
|
+
next()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} else if (tokenV2) {
|
|
124
|
+
const { AESDecrypt } = AES
|
|
125
|
+
const info = AESDecrypt(tokenV2, '3KMKqvgwR8ULbR8Z')
|
|
126
|
+
request(`/rs/user/${info.name}/${info.password}/智慧燃气`, METHOD.GET).then(
|
|
127
|
+
res => {
|
|
128
|
+
const curUser = {
|
|
129
|
+
name: res.name,
|
|
130
|
+
username: res.name,
|
|
131
|
+
orgid: res.name,
|
|
132
|
+
avatar: '',
|
|
133
|
+
ename: res.ename,
|
|
134
|
+
id: res.id,
|
|
135
|
+
orgName: res.f_fengongsi,
|
|
136
|
+
contact: '',
|
|
137
|
+
phone: '',
|
|
138
|
+
orgs: res.orgs
|
|
139
|
+
}
|
|
140
|
+
Vue.$store.commit('account/setUser', Object.assign(curUser, res))
|
|
141
|
+
const login = {
|
|
142
|
+
f: res,
|
|
143
|
+
jwt: res.id,
|
|
144
|
+
r: res.roles
|
|
145
|
+
}
|
|
146
|
+
Vue.$store.commit('account/setLogin', login)
|
|
147
|
+
loadRoutes(funcToRouter(res.functions))
|
|
148
|
+
next()
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
} else if (V4_LOGIN_DATA_KEY) {
|
|
152
|
+
const v4LoginData = JSON.parse(localStorage.getItem('userInfo'))
|
|
153
|
+
const curUser = {
|
|
154
|
+
name: v4LoginData.name,
|
|
155
|
+
username: v4LoginData.name,
|
|
156
|
+
orgid: v4LoginData.name,
|
|
157
|
+
avatar: '',
|
|
158
|
+
ename: v4LoginData.ename,
|
|
159
|
+
id: v4LoginData.id,
|
|
160
|
+
orgName: v4LoginData.orgs,
|
|
161
|
+
contact: '',
|
|
162
|
+
phone: '',
|
|
163
|
+
orgs: v4LoginData.orgs
|
|
164
|
+
}
|
|
165
|
+
Vue.$store.commit('account/setUser', Object.assign(curUser, v4LoginData))
|
|
166
|
+
const login = {
|
|
167
|
+
f: v4LoginData,
|
|
168
|
+
jwt: v4LoginData.id,
|
|
169
|
+
r: v4LoginData.r
|
|
170
|
+
}
|
|
171
|
+
Vue.$store.commit('account/setLogin', login)
|
|
172
|
+
if (!Vue.$store.state?.setting?.menuData || Vue.$store.state?.setting?.menuData?.length === 0) {
|
|
173
|
+
loadRoutes(funcToRouter(v4LoginData.functions))
|
|
174
|
+
}
|
|
175
|
+
next()
|
|
176
|
+
} else {
|
|
177
|
+
const { store, message } = options
|
|
178
|
+
if (
|
|
179
|
+
(!loginIgnore.includes(to) || to.name === '404') &&
|
|
180
|
+
!checkAuthorization()
|
|
181
|
+
) {
|
|
182
|
+
message.warning('登录已失效,请重新登录')
|
|
183
|
+
next({ path: '/login' })
|
|
184
|
+
} else {
|
|
185
|
+
const roles = store.getters['account/roles']
|
|
186
|
+
if (roles.length === 0 && !loginIgnore.includes(to)) {
|
|
187
|
+
message.warning('登录已失效,请重新登录')
|
|
188
|
+
logout().finally((res) => {
|
|
189
|
+
next({ path: '/login' })
|
|
190
|
+
})
|
|
191
|
+
} else {
|
|
192
|
+
next()
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 权限守卫
|
|
200
|
+
* @param to
|
|
201
|
+
* @param form
|
|
202
|
+
* @param next
|
|
203
|
+
* @param options
|
|
204
|
+
*/
|
|
205
|
+
const authorityGuard = (to, from, next, options) => {
|
|
206
|
+
const { store, message } = options
|
|
207
|
+
const permissions = store.getters['account/permissions']
|
|
208
|
+
const roles = store.getters['account/roles']
|
|
209
|
+
if (!hasAuthority(to, permissions, roles)) {
|
|
210
|
+
message.warning(`对不起,您无权访问页面: ${to.fullPath},请联系管理员`)
|
|
211
|
+
next({ path: '/403' })
|
|
212
|
+
// NProgress.done()
|
|
213
|
+
} else {
|
|
214
|
+
next()
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 混合导航模式下一级菜单跳转重定向
|
|
220
|
+
* @param to
|
|
221
|
+
* @param from
|
|
222
|
+
* @param next
|
|
223
|
+
* @param options
|
|
224
|
+
* @returns {*}
|
|
225
|
+
*/
|
|
226
|
+
const redirectGuard = (to, from, next, options) => {
|
|
227
|
+
const { store } = options
|
|
228
|
+
const getFirstChild = (routes) => {
|
|
229
|
+
const route = routes[0]
|
|
230
|
+
if (!route.children || route.children.length === 0) {
|
|
231
|
+
return route
|
|
232
|
+
}
|
|
233
|
+
return getFirstChild(route.children)
|
|
234
|
+
}
|
|
235
|
+
if (store.state.setting.layout === 'mix') {
|
|
236
|
+
const firstMenu = store.getters['setting/firstMenu']
|
|
237
|
+
if (firstMenu.find((item) => item.fullPath === to.fullPath)) {
|
|
238
|
+
store.commit('setting/setActivatedFirst', to.fullPath)
|
|
239
|
+
const subMenu = store.getters['setting/subMenu']
|
|
240
|
+
if (subMenu.length > 0) {
|
|
241
|
+
const redirect = getFirstChild(subMenu)
|
|
242
|
+
return next({ path: redirect.fullPath })
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
next()
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 进度条结束
|
|
251
|
+
* @param to
|
|
252
|
+
* @param form
|
|
253
|
+
* @param options
|
|
254
|
+
*/
|
|
255
|
+
const progressDone = () => {
|
|
256
|
+
// finish progress bar
|
|
257
|
+
NProgress.done()
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export default {
|
|
261
|
+
beforeEach: [progressStart, loginGuard, authorityGuard, redirectGuard],
|
|
262
|
+
afterEach: [progressDone],
|
|
263
|
+
}
|