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/lib/super-ui.umd.min.js +2 -2
- package/package.json +1 -1
- package/src/utils/auth-api.js +23 -13
package/package.json
CHANGED
package/src/utils/auth-api.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
19
|
+
setCookieCache(jwtKey, token)
|
|
20
|
+
setSessionCache(jwtKey, token)
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
function removeToken() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
24
|
+
removeCookieCache(jwtKey)
|
|
25
|
+
removeSessionCache(jwtKey)
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
function getUsername() {
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
return value
|
|
89
|
+
return sessionStorage.getItem(key)
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
function setSessionCache(key, value) {
|