vue2-client 1.8.27 → 1.8.29

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/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
- **1.8.27 -2023-1-10 @张振宇**
4
+ **1.8.29 -2023-1-10 @张振宇**
5
5
  - 微前端兼容
6
6
 
7
7
  **1.8.26 -2023-1-10 @杨亚文**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.27",
3
+ "version": "1.8.29",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -8,6 +8,8 @@ import {
8
8
  checkSingleAuthorization,
9
9
  } from '@vue2-client/utils/login'
10
10
  import AES from '@vue2-client/utils/EncryptUtil'
11
+ import Vue from 'vue'
12
+ import { funcToRouter, loadRoutes } from '@vue2-client/utils/routerUtil'
11
13
 
12
14
  NProgress.configure({ showSpinner: false })
13
15
 
@@ -33,19 +35,16 @@ const progressStart = (to, from, next) => {
33
35
  * @param options
34
36
  */
35
37
  const loginGuard = (to, from, next, options) => {
38
+ if (window.__MICRO_APP_ENVIRONMENT__) {
39
+ window.microApp.dispatch({ type: '子应用发送给主应用的数据', to: to.path })
40
+ }
36
41
  const urlParams = new URLSearchParams(window.location.search)
37
42
  const token = urlParams.get('token')
38
43
  const V4_LOGIN_DATA_KEY = localStorage.getItem('v4LoginData')
39
- if (token || V4_LOGIN_DATA_KEY) {
40
- let info = {}
44
+ if (token) {
45
+ const { AESDecrypt } = AES
46
+ const info = AESDecrypt(token, '3KMKqvgwR8ULbR8Z')
41
47
  const { store, message, router } = options
42
-
43
- if (V4_LOGIN_DATA_KEY) {
44
- info = JSON.parse(V4_LOGIN_DATA_KEY)
45
- } else {
46
- const { AESDecrypt } = AES
47
- info = AESDecrypt(token, '3KMKqvgwR8ULbR8Z')
48
- }
49
48
  if (
50
49
  (!loginIgnore.includes(to) || to.name === '404') &&
51
50
  !checkSingleAuthorization()
@@ -70,6 +69,29 @@ const loginGuard = (to, from, next, options) => {
70
69
  next()
71
70
  }
72
71
  }
72
+ } else if (V4_LOGIN_DATA_KEY) {
73
+ const v4LoginData = JSON.parse(localStorage.getItem('userInfo'))
74
+ const curUser = {
75
+ name: v4LoginData.name,
76
+ username: v4LoginData.name,
77
+ orgid: v4LoginData.name,
78
+ avatar: '',
79
+ ename: v4LoginData.ename,
80
+ id: v4LoginData.id,
81
+ orgName: v4LoginData.orgs,
82
+ contact: '',
83
+ phone: '',
84
+ orgs: v4LoginData.orgs
85
+ }
86
+ Vue.$store.commit('account/setUser', Object.assign(curUser, v4LoginData))
87
+ const login = {
88
+ f: v4LoginData,
89
+ jwt: v4LoginData.id,
90
+ r: v4LoginData.r
91
+ }
92
+ Vue.$store.commit('account/setLogin', login)
93
+ loadRoutes(funcToRouter(v4LoginData.functions))
94
+ next()
73
95
  } else {
74
96
  const { store, message } = options
75
97
  if (
@@ -358,10 +358,7 @@ function parsefunc (func) {
358
358
  * 资源服务路由排序
359
359
  */
360
360
  function positionRouter (r) {
361
- let router = []
362
- for (const row of r) {
363
- router[row.position] = row
364
- }
361
+ let router = r.sort((a, b) => a.position - b.position)
365
362
  router = arrRemoveEmpty(router)
366
363
  return router
367
364
  }