@qlibs/utils 1.11.0 → 1.12.0
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/dist/utils/auth.d.ts +3 -0
- package/dist/utils/auth.js +22 -0
- package/dist/utils/basePath.d.ts +1 -1
- package/dist/utils/basePath.js +7 -2
- package/package.json +1 -1
package/dist/utils/auth.d.ts
CHANGED
|
@@ -4,3 +4,6 @@ export declare function removeToken(): void;
|
|
|
4
4
|
export declare function saveUserData(userData: object): void;
|
|
5
5
|
export declare function getUserData(): any;
|
|
6
6
|
export declare function removeUserData(): void;
|
|
7
|
+
export declare function saveMySubRoles(mySubRoles: object): void;
|
|
8
|
+
export declare function getMySubRoles(): any;
|
|
9
|
+
export declare function removeMySubRoles(): void;
|
package/dist/utils/auth.js
CHANGED
|
@@ -6,8 +6,12 @@ exports.removeToken = removeToken;
|
|
|
6
6
|
exports.saveUserData = saveUserData;
|
|
7
7
|
exports.getUserData = getUserData;
|
|
8
8
|
exports.removeUserData = removeUserData;
|
|
9
|
+
exports.saveMySubRoles = saveMySubRoles;
|
|
10
|
+
exports.getMySubRoles = getMySubRoles;
|
|
11
|
+
exports.removeMySubRoles = removeMySubRoles;
|
|
9
12
|
const APP_AUTH_TOKEN = 'APP_AUTH_TOKEN';
|
|
10
13
|
const APP_AUTH_USER_DATA = 'APP_AUTH_USER_DATA';
|
|
14
|
+
const MY_SUB_ROLES = 'MY_SUB_ROLES';
|
|
11
15
|
function saveToken(token) {
|
|
12
16
|
return localStorage.setItem(APP_AUTH_TOKEN, token);
|
|
13
17
|
}
|
|
@@ -35,3 +39,21 @@ function getUserData() {
|
|
|
35
39
|
function removeUserData() {
|
|
36
40
|
return localStorage.removeItem(APP_AUTH_USER_DATA);
|
|
37
41
|
}
|
|
42
|
+
function saveMySubRoles(mySubRoles) {
|
|
43
|
+
return localStorage.setItem(MY_SUB_ROLES, JSON.stringify(mySubRoles));
|
|
44
|
+
}
|
|
45
|
+
function getMySubRoles() {
|
|
46
|
+
const res = localStorage.getItem(MY_SUB_ROLES);
|
|
47
|
+
try {
|
|
48
|
+
if (res) {
|
|
49
|
+
return JSON.parse(res);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function removeMySubRoles() {
|
|
58
|
+
return localStorage.removeItem(MY_SUB_ROLES);
|
|
59
|
+
}
|
package/dist/utils/basePath.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function getBasePath(): string;
|
|
2
|
-
export declare function goBack(navigateFunction
|
|
2
|
+
export declare function goBack(navigateFunction?: Function): void;
|
package/dist/utils/basePath.js
CHANGED
|
@@ -11,11 +11,16 @@ function getBasePath() {
|
|
|
11
11
|
return '/' + baseSegments.join('/');
|
|
12
12
|
}
|
|
13
13
|
function goBack(navigateFunction) {
|
|
14
|
-
if (window.history.length > 0) {
|
|
14
|
+
if ((window.history || []).length > 0 && navigateFunction) {
|
|
15
15
|
navigateFunction(-1);
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
const backPath = getBasePath();
|
|
19
|
-
navigateFunction
|
|
19
|
+
if (navigateFunction) {
|
|
20
|
+
navigateFunction(backPath);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
window.location.href = backPath;
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
}
|