imatrix-ui 2.8.63-dw → 2.8.64-dw

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": "imatrix-ui",
3
- "version": "2.8.63-dw",
3
+ "version": "2.8.64-dw",
4
4
  "description": "前端组件库:表格、表单、组织结构树等",
5
5
  "main": "lib/super-ui.umd.min.js",
6
6
  "private": false,
@@ -1,27 +1,36 @@
1
1
  import Cookies from 'js-cookie'
2
+ import Vue from 'vue'
2
3
 
3
4
  const jwtKey = 'JWT'
4
5
  const currentUserNameKey = 'USERNAME'
5
6
  const currentUserInfoKey = 'CURRENT_USER'
6
7
 
7
8
  function getToken() {
8
- return Cookies.get(jwtKey)
9
+ let token = getCookieCache(jwtKey)
10
+ const projectModel = Vue.prototype.projectModel
11
+ if (!token && projectModel && projectModel === 'developing.model') {
12
+ // 如果是开发环境从sessionStorage中获得token
13
+ token = getSessionCache(jwtKey)
14
+ }
15
+ return token
9
16
  }
10
17
 
11
18
  function setToken(token) {
12
- Cookies.set(jwtKey, token, {
13
- path: '/'
14
- })
19
+ setCookieCache(jwtKey, token)
20
+ setSessionCache(jwtKey, token)
15
21
  }
16
22
 
17
23
  function removeToken() {
18
- Cookies.remove(jwtKey, {
19
- path: '/'
20
- })
24
+ removeCookieCache(jwtKey)
25
+ removeSessionCache(jwtKey)
21
26
  }
22
27
 
23
28
  function getUsername() {
24
- return getCookieCache(currentUserNameKey)
29
+ let username = getCookieCache(currentUserNameKey)
30
+ if (!username) {
31
+ username = getSessionCache(currentUserNameKey)
32
+ }
33
+ return username
25
34
  }
26
35
 
27
36
  function setUsername(username) {
@@ -35,7 +44,10 @@ function removeUsername() {
35
44
  }
36
45
 
37
46
  function getCurrentUser() {
38
- const userJson = getCookieCache(currentUserInfoKey)
47
+ let userJson = getCookieCache(currentUserInfoKey)
48
+ if (!userJson) {
49
+ userJson = getSessionCache(currentUserInfoKey)
50
+ }
39
51
  if (userJson) {
40
52
  return JSON.parse(userJson)
41
53
  }
@@ -58,8 +70,7 @@ function removeCurrentUser() {
58
70
  }
59
71
 
60
72
  function getCookieCache(key) {
61
- const value = Cookies.get(key)
62
- return value
73
+ return Cookies.get(key)
63
74
  }
64
75
 
65
76
  function setCookieCache(key, value) {
@@ -75,8 +86,7 @@ function removeCookieCache(key) {
75
86
  }
76
87
 
77
88
  function getSessionCache(key) {
78
- const value = sessionStorage.getItem(key)
79
- return value
89
+ return sessionStorage.getItem(key)
80
90
  }
81
91
 
82
92
  function setSessionCache(key, value) {