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
- const str = this.getAll()[key];
11
- if (encrypt) return str ? EncryptConfig.decryptMethod(str) : void 0;
12
- return str;
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(key, "", -1);
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
- const str = StorageUtil.localStorage.getItem(key);
43
- if (str) return encrypt ? JSON.parse(EncryptConfig.decryptMethod(str)) : JSON.parse(str);
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
- const str = StorageUtil.sessionStorage.getItem(key);
70
- if (str) return encrypt ? JSON.parse(EncryptConfig.decryptMethod(str)) : JSON.parse(str);
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的值 - 加密
@@ -12,3 +12,10 @@ export type StorageCookieSetOptions = {
12
12
  // 是否加密
13
13
  encrypt?: boolean
14
14
  }
15
+
16
+ export type StorageCookieRemoveOptions = {
17
+ // 路径
18
+ path?: string
19
+ // 域名
20
+ domain?: string
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrxy-yk",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A collection of Vue 3 components and utilities",
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "mrxy-yk",
4
- "version": "1.13.0",
4
+ "version": "1.13.2",
5
5
  "js-types-syntax": "typescript",
6
6
  "contributions": {
7
7
  "html": {