@whitesev/utils 2.3.4 → 2.3.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.
@@ -434,7 +434,9 @@ declare class Utils {
434
434
  getMaxValue(val: UtilsOwnObject<number>, handler: (key: any, value: any) => number): number;
435
435
  /**
436
436
  * 获取页面中最大的z-index的元素信息
437
- * @param deviation 获取最大的z-index值的偏移,默认是+1
437
+ * @param deviation 获取最大的z-index值的偏移,默认是1
438
+ * @param node 进行判断的元素,默认是document
439
+ * @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
438
440
  * @example
439
441
  * Utils.getMaxZIndexNodeInfo();
440
442
  * > {
@@ -442,18 +444,20 @@ declare class Utils {
442
444
  * zIndex: 1001
443
445
  * }
444
446
  **/
445
- getMaxZIndexNodeInfo(deviation?: number): {
447
+ getMaxZIndexNodeInfo(deviation?: number, target?: Element | ShadowRoot | Document, ignoreCallBack?: ($ele: Element | HTMLElement | ShadowRoot) => boolean | void): {
446
448
  node: Element;
447
449
  zIndex: number;
448
450
  };
449
451
  /**
450
452
  * 获取页面中最大的z-index
451
- * @param deviation 获取最大的z-index值的偏移,默认是+1
453
+ * @param deviation 获取最大的z-index值的偏移,默认是1
454
+ * @param node 进行判断的元素,默认是document
455
+ * @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
452
456
  * @example
453
457
  * Utils.getMaxZIndex();
454
458
  * > 1001
455
459
  **/
456
- getMaxZIndex(deviation?: number): number;
460
+ getMaxZIndex(deviation?: number, target?: Element | DocumentOrShadowRoot | Document, ignoreCallBack?: ($ele: Element | HTMLElement | ShadowRoot) => boolean | void): number;
457
461
  /**
458
462
  * 获取最小值
459
463
  * @example
@@ -32,6 +32,7 @@ export declare interface Vue2Object {
32
32
  params: any;
33
33
  path: string;
34
34
  query: any;
35
+ [key: string]: any;
35
36
  };
36
37
  $router: {
37
38
  afterHooks: Function[];
@@ -41,40 +42,45 @@ export declare interface Vue2Object {
41
42
  fallback: boolean;
42
43
  history: {
43
44
  base: string;
44
- current: any;
45
+ current: Vue2Object["$route"];
45
46
  listeners: any[];
46
47
  router: Vue2Object["$router"];
47
48
  /**
48
49
  *
49
50
  * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
50
51
  * @param triggerListeners 是否应该触发连接到该历史的监听器
51
- * @returns
52
52
  */
53
53
  go: (delta: number, triggerListeners?: boolean) => void;
54
54
  /**
55
55
  *
56
56
  * @param to 要设置的地址
57
57
  * @param data 可选的 HistoryState 以关联该导航记录
58
- * @returns
59
58
  */
60
59
  push: (to: string, data?: any) => void;
61
60
  /**
62
61
  *
63
62
  * @param to 要设置的地址
64
63
  * @param data 可选的 HistoryState 以关联该导航记录
65
- * @returns
66
64
  */
67
65
  replace: (to: string, data?: any) => void;
66
+ [key: string]: any;
68
67
  };
69
68
  matcher: {
70
69
  addRoute: (...args: any[]) => any;
71
70
  addRoutes: (...args: any[]) => any;
72
71
  getRoutes: () => any;
73
72
  match: (...args: any[]) => any;
73
+ [key: string]: any;
74
74
  };
75
75
  mode: string;
76
+ options: {
77
+ mode: string;
78
+ routes: any[];
79
+ scrollBehavior: (...args: any[]) => any;
80
+ [key: string]: any;
81
+ };
76
82
  resolveHooks: ((...args: any[]) => any)[];
77
- currentRoute: any;
83
+ currentRoute: Vue2Object["$route"];
78
84
  beforeEach: (callback: ((
79
85
  /** 即将要进入的目标 路由对象 */
80
86
  to: Vue2Object["$route"],
@@ -97,6 +103,13 @@ export declare interface Vue2Object {
97
103
  from: Vue2Object["$route"]) => void)
98
104
  /** 移除上一个添加的监听 */
99
105
  | (() => void)) => void;
106
+ push: (...args: any[]) => void;
107
+ back: () => void;
108
+ go: (...args: any[]) => void;
109
+ replace: (...args: any[]) => void;
110
+ addRoute: (...args: any[]) => void;
111
+ addRoutes: (...args: any[]) => void;
112
+ [key: string]: any;
100
113
  };
101
114
  $ssrContext: any;
102
115
  $watch: (key: string | string[] | (() => any), handler: (this: any, newVal: any, oldVal: any) => void, options?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "2.3.4",
3
+ "version": "2.3.6",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Utils.ts CHANGED
@@ -53,7 +53,7 @@ class Utils {
53
53
  this.windowApi = new WindowApi(option);
54
54
  }
55
55
  /** 版本号 */
56
- version = "2024.9.28";
56
+ version = "2024.10.13";
57
57
 
58
58
  /**
59
59
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -1228,7 +1228,9 @@ class Utils {
1228
1228
  }
1229
1229
  /**
1230
1230
  * 获取页面中最大的z-index的元素信息
1231
- * @param deviation 获取最大的z-index值的偏移,默认是+1
1231
+ * @param deviation 获取最大的z-index值的偏移,默认是1
1232
+ * @param node 进行判断的元素,默认是document
1233
+ * @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
1232
1234
  * @example
1233
1235
  * Utils.getMaxZIndexNodeInfo();
1234
1236
  * > {
@@ -1236,11 +1238,23 @@ class Utils {
1236
1238
  * zIndex: 1001
1237
1239
  * }
1238
1240
  **/
1239
- getMaxZIndexNodeInfo(deviation?: number): {
1241
+ getMaxZIndexNodeInfo(
1242
+ deviation?: number,
1243
+ target?: Element | ShadowRoot | Document,
1244
+ ignoreCallBack?: (
1245
+ $ele: Element | HTMLElement | ShadowRoot
1246
+ ) => boolean | void
1247
+ ): {
1240
1248
  node: Element;
1241
1249
  zIndex: number;
1242
1250
  };
1243
- getMaxZIndexNodeInfo(deviation = 1): {
1251
+ getMaxZIndexNodeInfo(
1252
+ deviation = 1,
1253
+ target: Element | ShadowRoot | Document = this.windowApi.document,
1254
+ ignoreCallBack?: (
1255
+ $ele: Element | HTMLElement | ShadowRoot
1256
+ ) => boolean | void
1257
+ ): {
1244
1258
  node: Element;
1245
1259
  zIndex: number;
1246
1260
  } {
@@ -1268,6 +1282,12 @@ class Utils {
1268
1282
  * @param $ele
1269
1283
  */
1270
1284
  function queryMaxZIndex($ele: Element) {
1285
+ if (typeof ignoreCallBack === "function") {
1286
+ let ignoreResult = ignoreCallBack($ele);
1287
+ if (typeof ignoreResult === "boolean" && !ignoreResult) {
1288
+ return;
1289
+ }
1290
+ }
1271
1291
  /** 元素的样式 */
1272
1292
  const nodeStyle = UtilsContext.windowApi.window.getComputedStyle($ele);
1273
1293
  /* 不对position为static和display为none的元素进行获取它们的z-index */
@@ -1288,7 +1308,7 @@ class Utils {
1288
1308
  }
1289
1309
  }
1290
1310
  }
1291
- this.windowApi.document.querySelectorAll("*").forEach(($ele, index) => {
1311
+ target.querySelectorAll("*").forEach(($ele, index) => {
1292
1312
  queryMaxZIndex($ele);
1293
1313
  });
1294
1314
  zIndex += deviation;
@@ -1303,14 +1323,28 @@ class Utils {
1303
1323
  }
1304
1324
  /**
1305
1325
  * 获取页面中最大的z-index
1306
- * @param deviation 获取最大的z-index值的偏移,默认是+1
1326
+ * @param deviation 获取最大的z-index值的偏移,默认是1
1327
+ * @param node 进行判断的元素,默认是document
1328
+ * @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
1307
1329
  * @example
1308
1330
  * Utils.getMaxZIndex();
1309
1331
  * > 1001
1310
1332
  **/
1311
- getMaxZIndex(deviation?: number): number;
1312
- getMaxZIndex(deviation = 1): number {
1313
- return this.getMaxZIndexNodeInfo(deviation).zIndex;
1333
+ getMaxZIndex(
1334
+ deviation?: number,
1335
+ target?: Element | DocumentOrShadowRoot | Document,
1336
+ ignoreCallBack?: (
1337
+ $ele: Element | HTMLElement | ShadowRoot
1338
+ ) => boolean | void
1339
+ ): number;
1340
+ getMaxZIndex(
1341
+ deviation = 1,
1342
+ target: Element | ShadowRoot | Document = this.windowApi.document,
1343
+ ignoreCallBack?: (
1344
+ $ele: Element | HTMLElement | ShadowRoot
1345
+ ) => boolean | void
1346
+ ): number {
1347
+ return this.getMaxZIndexNodeInfo(deviation, target, ignoreCallBack).zIndex;
1314
1348
  }
1315
1349
  /**
1316
1350
  * 获取最小值
package/src/VueObject.ts CHANGED
@@ -34,6 +34,7 @@ export declare interface Vue2Object {
34
34
  params: any;
35
35
  path: string;
36
36
  query: any;
37
+ [key: string]: any;
37
38
  };
38
39
  $router: {
39
40
  afterHooks: Function[];
@@ -43,40 +44,45 @@ export declare interface Vue2Object {
43
44
  fallback: boolean;
44
45
  history: {
45
46
  base: string;
46
- current: any;
47
+ current: Vue2Object["$route"];
47
48
  listeners: any[];
48
49
  router: Vue2Object["$router"];
49
50
  /**
50
51
  *
51
52
  * @param delta 访问的距离。如果 delta < 0 则后退相应数量的记录,如果 > 0 则前进。
52
53
  * @param triggerListeners 是否应该触发连接到该历史的监听器
53
- * @returns
54
54
  */
55
55
  go: (delta: number, triggerListeners?: boolean) => void;
56
56
  /**
57
57
  *
58
58
  * @param to 要设置的地址
59
59
  * @param data 可选的 HistoryState 以关联该导航记录
60
- * @returns
61
60
  */
62
61
  push: (to: string, data?: any) => void;
63
62
  /**
64
63
  *
65
64
  * @param to 要设置的地址
66
65
  * @param data 可选的 HistoryState 以关联该导航记录
67
- * @returns
68
66
  */
69
67
  replace: (to: string, data?: any) => void;
68
+ [key: string]: any;
70
69
  };
71
70
  matcher: {
72
71
  addRoute: (...args: any[]) => any;
73
72
  addRoutes: (...args: any[]) => any;
74
73
  getRoutes: () => any;
75
74
  match: (...args: any[]) => any;
75
+ [key: string]: any;
76
76
  };
77
77
  mode: string;
78
+ options: {
79
+ mode: string;
80
+ routes: any[];
81
+ scrollBehavior: (...args: any[]) => any;
82
+ [key: string]: any;
83
+ };
78
84
  resolveHooks: ((...args: any[]) => any)[];
79
- currentRoute: any;
85
+ currentRoute: Vue2Object["$route"];
80
86
  beforeEach: (
81
87
  callback:
82
88
  | ((
@@ -108,6 +114,13 @@ export declare interface Vue2Object {
108
114
  /** 移除上一个添加的监听 */
109
115
  | (() => void)
110
116
  ) => void;
117
+ push: (...args: any[]) => void;
118
+ back: () => void;
119
+ go: (...args: any[]) => void;
120
+ replace: (...args: any[]) => void;
121
+ addRoute: (...args: any[]) => void;
122
+ addRoutes: (...args: any[]) => void;
123
+ [key: string]: any;
111
124
  };
112
125
  $ssrContext: any;
113
126