vue2-client 1.8.27 → 1.8.28

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.27",
3
+ "version": "1.8.28",
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,15 @@ const progressStart = (to, from, next) => {
33
35
  * @param options
34
36
  */
35
37
  const loginGuard = (to, from, next, options) => {
38
+ console.log('loginGuard', to, from, next, options)
39
+
36
40
  const urlParams = new URLSearchParams(window.location.search)
37
41
  const token = urlParams.get('token')
38
42
  const V4_LOGIN_DATA_KEY = localStorage.getItem('v4LoginData')
39
- if (token || V4_LOGIN_DATA_KEY) {
40
- let info = {}
43
+ if (token) {
44
+ const { AESDecrypt } = AES
45
+ const info = AESDecrypt(token, '3KMKqvgwR8ULbR8Z')
41
46
  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
47
  if (
50
48
  (!loginIgnore.includes(to) || to.name === '404') &&
51
49
  !checkSingleAuthorization()
@@ -70,6 +68,29 @@ const loginGuard = (to, from, next, options) => {
70
68
  next()
71
69
  }
72
70
  }
71
+ } else if (V4_LOGIN_DATA_KEY) {
72
+ const v4LoginData = JSON.parse(localStorage.getItem('userInfo'))
73
+ const curUser = {
74
+ name: v4LoginData.name,
75
+ username: v4LoginData.name,
76
+ orgid: v4LoginData.name,
77
+ avatar: '',
78
+ ename: v4LoginData.ename,
79
+ id: v4LoginData.id,
80
+ orgName: v4LoginData.orgs,
81
+ contact: '',
82
+ phone: '',
83
+ orgs: v4LoginData.orgs
84
+ }
85
+ Vue.$store.commit('account/setUser', Object.assign(curUser, v4LoginData))
86
+ const login = {
87
+ f: v4LoginData,
88
+ jwt: v4LoginData.id,
89
+ r: v4LoginData.r
90
+ }
91
+ Vue.$store.commit('account/setLogin', login)
92
+ // loadRoutes(funcToRouter(v4LoginData.functions))
93
+ next()
73
94
  } else {
74
95
  const { store, message } = options
75
96
  if (