iv-npm 1.1.13 → 1.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iv-npm",
3
- "version": "1.1.13",
3
+ "version": "1.1.16",
4
4
  "description": "公共通用包",
5
5
  "author": "Mr.Cong",
6
6
  "license": "ISC",
@@ -25,7 +25,15 @@ declare function isPlainObject(obj: object): boolean;
25
25
  /**
26
26
  * 是否是一个对象
27
27
  * */
28
- declare const isObject: (val: unknown) => val is Record<any, any>;
28
+ declare const isObject: (val: unknown) => val is Record<any, any>;
29
+ /**
30
+ * 是否是一个时间对象
31
+ * */
32
+ declare function isDate(val: any): boolean;
33
+ /**
34
+ * 是否是一个URLSearchParams
35
+ * */
36
+ declare function isURLSearchParams(val: any): boolean;
29
37
 
30
38
  declare const assign: {
31
39
  <T extends {}, U>(target: T, source: U): T & U;
@@ -36,4 +44,6 @@ declare const assign: {
36
44
 
37
45
  declare function filterOptionHeadle(input: string, option: any): any;
38
46
 
39
- export { arrToTree, assign, filterOptionHeadle, findTree, isObject, isPlainObject, tranListToTreeData };
47
+ declare function buildURL(url: string, params: any): string;
48
+
49
+ export { arrToTree, assign, buildURL as buildUrl, filterOptionHeadle, findTree, isDate, isObject, isPlainObject, isURLSearchParams, tranListToTreeData };
@@ -59,6 +59,12 @@ function isPlainObject(obj) {
59
59
  return typeof Ctor === "function" && {}.hasOwnProperty.toString.call(Ctor) === {}.hasOwnProperty.toString.call(Object);
60
60
  }
61
61
  var isObject = (val) => val !== null && typeof val === "object";
62
+ function isDate(val) {
63
+ return toString.call(val) === "[object Date]";
64
+ }
65
+ function isURLSearchParams(val) {
66
+ return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
67
+ }
62
68
 
63
69
  // utils/obj/cache.ts
64
70
  var assign = Object.assign;
@@ -67,12 +73,56 @@ var assign = Object.assign;
67
73
  function filterOptionHeadle(input, option) {
68
74
  return option.label && option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
69
75
  }
76
+
77
+ // utils/buildUrl.ts
78
+ function encode(val) {
79
+ return encodeURIComponent(val).replace(/%40/g, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
80
+ }
81
+ function buildURL(url, params) {
82
+ if (!params) {
83
+ return url;
84
+ }
85
+ if (isURLSearchParams(params)) {
86
+ return url += (url.includes("?") ? "&" : "?") + params.toString();
87
+ }
88
+ const parts = [];
89
+ Object.keys(params).forEach((key) => {
90
+ const val = params[key];
91
+ if (val === null || typeof val === "undefined") {
92
+ return;
93
+ }
94
+ let tempVal = [];
95
+ if (Array.isArray(val)) {
96
+ tempVal = val;
97
+ key = key + "[]";
98
+ } else {
99
+ tempVal = [val];
100
+ }
101
+ tempVal.forEach((temp) => {
102
+ if (isDate(temp)) {
103
+ temp = val.toString();
104
+ } else if (isObject(temp)) {
105
+ temp = JSON.stringify(temp);
106
+ }
107
+ parts.push(`${encode(key)}=${encode(temp)}`);
108
+ });
109
+ });
110
+ const hashmarkIndex = url.indexOf("#");
111
+ if (hashmarkIndex !== -1) {
112
+ url = url.slice(0, hashmarkIndex);
113
+ }
114
+ url += (url.includes("?") ? "&" : "?") + parts.join("&");
115
+ return url;
116
+ }
70
117
  export {
71
118
  arrToTree,
72
119
  assign,
120
+ buildURL as buildUrl,
73
121
  filterOptionHeadle,
74
122
  findTree,
123
+ isDate,
75
124
  isObject,
76
125
  isPlainObject,
126
+ isURLSearchParams,
77
127
  tranListToTreeData
78
128
  };
@@ -1,5 +1,5 @@
1
1
  declare const _default: import("vue").DefineComponent<{
2
- data: {
2
+ dataTh: {
3
3
  type: null;
4
4
  required: true;
5
5
  };
@@ -30,7 +30,7 @@ declare const _default: import("vue").DefineComponent<{
30
30
  }, (_ctx: any, _cache: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
31
31
  [key: string]: any;
32
32
  }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("onPageChange" | "onShowSizeChange" | "upth")[], "onPageChange" | "onShowSizeChange" | "upth", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
33
- data: {
33
+ dataTh: {
34
34
  type: null;
35
35
  required: true;
36
36
  };