mrxy-yk 1.13.0 → 1.13.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageCookieSetOptions } from './type';
|
|
1
|
+
import { StorageCookieRemoveOptions, StorageCookieSetOptions } from './type';
|
|
2
2
|
export declare class StorageCookie {
|
|
3
3
|
/**
|
|
4
4
|
* 获取cookie
|
|
@@ -19,6 +19,7 @@ export declare class StorageCookie {
|
|
|
19
19
|
/**
|
|
20
20
|
* 删除cookie
|
|
21
21
|
* @param key
|
|
22
|
+
* @param options
|
|
22
23
|
*/
|
|
23
|
-
static remove(key: string): void;
|
|
24
|
+
static remove(key: string, options?: StorageCookieRemoveOptions): void;
|
|
24
25
|
}
|
|
@@ -7,9 +7,13 @@ var StorageCookie = class {
|
|
|
7
7
|
* @param encrypt
|
|
8
8
|
*/
|
|
9
9
|
static get(key, encrypt = true) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
try {
|
|
11
|
+
const str = this.getAll()[key];
|
|
12
|
+
if (encrypt) return str ? EncryptConfig.decryptMethod(str) : void 0;
|
|
13
|
+
return str;
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
static set(...args) {
|
|
15
19
|
let key;
|
|
@@ -59,9 +63,16 @@ var StorageCookie = class {
|
|
|
59
63
|
/**
|
|
60
64
|
* 删除cookie
|
|
61
65
|
* @param key
|
|
66
|
+
* @param options
|
|
62
67
|
*/
|
|
63
|
-
static remove(key) {
|
|
64
|
-
this.set(
|
|
68
|
+
static remove(key, options = {}) {
|
|
69
|
+
this.set({
|
|
70
|
+
path: "/",
|
|
71
|
+
value: "",
|
|
72
|
+
...options,
|
|
73
|
+
key,
|
|
74
|
+
expires: -1
|
|
75
|
+
});
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
//#endregion
|
|
@@ -39,8 +39,12 @@ var StorageUtil = class StorageUtil {
|
|
|
39
39
|
* @param encrypt
|
|
40
40
|
*/
|
|
41
41
|
get(key, encrypt = true) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
try {
|
|
43
|
+
const str = StorageUtil.localStorage.getItem(key);
|
|
44
|
+
if (str) return encrypt ? JSON.parse(EncryptConfig.decryptMethod(str)) : JSON.parse(str);
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
44
48
|
},
|
|
45
49
|
/**
|
|
46
50
|
* 设置localStorage的值 - 加密
|
|
@@ -66,8 +70,12 @@ var StorageUtil = class StorageUtil {
|
|
|
66
70
|
* @param encrypt
|
|
67
71
|
*/
|
|
68
72
|
get(key, encrypt = true) {
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
try {
|
|
74
|
+
const str = StorageUtil.sessionStorage.getItem(key);
|
|
75
|
+
if (str) return encrypt ? JSON.parse(EncryptConfig.decryptMethod(str)) : JSON.parse(str);
|
|
76
|
+
} catch {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
71
79
|
},
|
|
72
80
|
/**
|
|
73
81
|
* 设置sessionStorage的值 - 加密
|
package/package.json
CHANGED