@whitesev/utils 2.5.4 → 2.5.6

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.
@@ -32,5 +32,14 @@ declare class UtilsGMCookie {
32
32
  * @param callback 删除操作后的回调(成功/失败)
33
33
  */
34
34
  delete(option: UtilsGMCookieDeleteOptions, callback?: (error?: Error) => void): void;
35
+ /**
36
+ * 解析cookie字符串
37
+ * 例如:document.cookie
38
+ * @param cookieStr
39
+ */
40
+ parseCookie(cookieStr: string): {
41
+ key: string;
42
+ value: string;
43
+ }[];
35
44
  }
36
45
  export { UtilsGMCookie };
@@ -121,20 +121,32 @@ export declare interface Vue2Instance {
121
121
  back: () => void;
122
122
  go: (...args: any[]) => void;
123
123
  replace: (...args: any[]) => void;
124
+ /** 添加路由 */
124
125
  addRoute: (...args: any[]) => void;
125
126
  addRoutes: (...args: any[]) => void;
126
127
  [key: string]: any;
127
128
  };
128
129
  $ssrContext: any;
129
-
130
+ /** 观察者 @returns 取消观察者 */
130
131
  $watch: (
132
+ /** 需要观察的属性 */
131
133
  key: string | string[] | (() => any),
132
- handler: (this: any, newVal: any, oldVal: any) => void,
134
+ /** 属性改变时触发的回调 */
135
+ handler: (
136
+ this: Vue2Instance,
137
+ /** 新值,也就是改变后的值 */
138
+ newVal: any,
139
+ /** 旧值,也就是改变前的值 */
140
+ oldVal: any
141
+ ) => void,
142
+ /** 监听配置 */
133
143
  options?: {
144
+ /** 是否立即执行handler */
134
145
  immediate?: boolean;
146
+ /** 是否深度监听 */
135
147
  deep?: boolean;
136
148
  }
137
- ) => void;
149
+ ) => Function;
138
150
 
139
151
  [key: string]: any;
140
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Utils.ts CHANGED
@@ -29,7 +29,7 @@ class Utils {
29
29
  this.windowApi = new WindowApi(option);
30
30
  }
31
31
  /** 版本号 */
32
- version = "2024.12.3";
32
+ version = "2024.12.25";
33
33
 
34
34
  /**
35
35
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -1245,7 +1245,7 @@ class Utils {
1245
1245
  deviation = Number.isNaN(deviation) ? 1 : deviation;
1246
1246
  const UtilsContext = this;
1247
1247
  // 最大值 2147483647
1248
- const maxZIndex = Math.pow(2, 31) - 1;
1248
+ // const maxZIndex = Math.pow(2, 31) - 1;
1249
1249
  // 比较值 2000000000
1250
1250
  const maxZIndexCompare = 2 * Math.pow(10, 9);
1251
1251
  // 当前页面最大的z-index
@@ -223,6 +223,27 @@ class UtilsGMCookie {
223
223
  }
224
224
  }
225
225
  }
226
+ /**
227
+ * 解析cookie字符串
228
+ * 例如:document.cookie
229
+ * @param cookieStr
230
+ */
231
+ parseCookie(cookieStr: string) {
232
+ let cookies = cookieStr.split(";");
233
+ let result: { key: string; value: string }[] = [];
234
+ for (const cookieItem of cookies) {
235
+ let item = cookieItem.trim();
236
+ let itemSplit = item.split("=");
237
+ let itemName = itemSplit[0];
238
+ itemSplit.splice(0, 1);
239
+ let itemValue = decodeURIComponent(itemSplit.join(""));
240
+ result.push({
241
+ key: itemName,
242
+ value: itemValue,
243
+ });
244
+ }
245
+ return result;
246
+ }
226
247
  }
227
248
 
228
249
  export { UtilsGMCookie };
@@ -121,20 +121,32 @@ export declare interface Vue2Instance {
121
121
  back: () => void;
122
122
  go: (...args: any[]) => void;
123
123
  replace: (...args: any[]) => void;
124
+ /** 添加路由 */
124
125
  addRoute: (...args: any[]) => void;
125
126
  addRoutes: (...args: any[]) => void;
126
127
  [key: string]: any;
127
128
  };
128
129
  $ssrContext: any;
129
-
130
+ /** 观察者 @returns 取消观察者 */
130
131
  $watch: (
132
+ /** 需要观察的属性 */
131
133
  key: string | string[] | (() => any),
132
- handler: (this: any, newVal: any, oldVal: any) => void,
134
+ /** 属性改变时触发的回调 */
135
+ handler: (
136
+ this: Vue2Instance,
137
+ /** 新值,也就是改变后的值 */
138
+ newVal: any,
139
+ /** 旧值,也就是改变前的值 */
140
+ oldVal: any
141
+ ) => void,
142
+ /** 监听配置 */
133
143
  options?: {
144
+ /** 是否立即执行handler */
134
145
  immediate?: boolean;
146
+ /** 是否深度监听 */
135
147
  deep?: boolean;
136
148
  }
137
- ) => void;
149
+ ) => Function;
138
150
 
139
151
  [key: string]: any;
140
152
  }