@lightsoft/js-sdk 1.2.0 → 1.2.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.
package/dist/index.d.ts CHANGED
@@ -219,6 +219,11 @@ declare function findTreeDataNode(data: ISectoralTable[], targetDeptCode: string
219
219
  * @param results 查找结果集
220
220
  */
221
221
  declare function findTreeDataNodeName(dept: ISectoralTable, queryString: string, results: ISectoralTable[]): void;
222
+ /**
223
+ *
224
+ * 数组对象根据某个值去重
225
+ */
226
+ declare function uniqueByProperty<T>(arr: T[], prop: keyof T): T[];
222
227
 
223
228
  declare class Mask {
224
229
  private task;
@@ -274,6 +279,14 @@ declare const countUp: (start: number, end: number, callback: (current: number)
274
279
 
275
280
  declare function hasRepeatArray(arr: any[], keys?: string[]): any[];
276
281
 
282
+ type TAddURLParamsReturn = {
283
+ url: string;
284
+ queryString: string;
285
+ };
286
+ declare function addURLParams(params: Record<string, any>, url?: string): TAddURLParamsReturn;
287
+ declare function getURLParams(url?: string): Record<string, any>;
288
+ declare function deleteURLParams(keys: string[], url?: string): URL;
289
+
277
290
  /**
278
291
  * 匹配中文字母数字
279
292
  */
@@ -299,5 +312,5 @@ declare const email: RegExp;
299
312
  */
300
313
  declare const url: RegExp;
301
314
 
302
- export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, RecordType, Request, RequestChain, Tour, countUp, createWebSocket, dataHandler, debounce, deepMerge, download, email, findTreeDataNode, findTreeDataNodeName, getState, hasRepeatArray, idCard, ip, isMobileDevice, isNull, objectArrayToString, phone, throttle, url, useClose, useCountDown, useDownload, useOnMessage, useSendMessage, zhLetterNumber };
315
+ export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, RecordType, Request, RequestChain, Tour, addURLParams, countUp, createWebSocket, dataHandler, debounce, deepMerge, deleteURLParams, download, email, findTreeDataNode, findTreeDataNodeName, getState, getURLParams, hasRepeatArray, idCard, ip, isMobileDevice, isNull, objectArrayToString, phone, throttle, uniqueByProperty, url, useClose, useCountDown, useDownload, useOnMessage, useSendMessage, zhLetterNumber };
303
316
  export type { ISectoralTable, Tag, typeIsNull };
package/dist/index.js CHANGED
@@ -2640,6 +2640,21 @@ function findTreeDataNodeName(dept, queryString, results) {
2640
2640
  }
2641
2641
  }
2642
2642
  }
2643
+ /**
2644
+ *
2645
+ * 数组对象根据某个值去重
2646
+ */
2647
+ function uniqueByProperty(arr, prop) {
2648
+ return arr.reduce(function (acc, current) {
2649
+ var x = acc.find(function (item) { return item[prop] === current[prop]; });
2650
+ if (!x) {
2651
+ return acc.concat([current]);
2652
+ }
2653
+ else {
2654
+ return acc;
2655
+ }
2656
+ }, []);
2657
+ }
2643
2658
 
2644
2659
  var Mask = /** @class */ (function () {
2645
2660
  function Mask(selectors, opacity) {
@@ -2865,6 +2880,31 @@ function hasRepeatArray(arr, keys) {
2865
2880
  return [false];
2866
2881
  }
2867
2882
 
2883
+ function addURLParams(params, url) {
2884
+ url = url || window.location.href;
2885
+ var urlParams = getURLParams(url);
2886
+ var queryString = new URLSearchParams(Object.entries(__assign(__assign({}, urlParams), params))).toString();
2887
+ return {
2888
+ url: "".concat(url, "?").concat(queryString),
2889
+ queryString: queryString,
2890
+ };
2891
+ }
2892
+ function getURLParams(url) {
2893
+ url = url || window.location.href;
2894
+ var urlString = url.split('?')[1];
2895
+ var urlSearchParams = new URLSearchParams(urlString);
2896
+ var result = Object.fromEntries(urlSearchParams.entries());
2897
+ return result;
2898
+ }
2899
+ function deleteURLParams(keys, url) {
2900
+ url = url || window.location.href;
2901
+ var newUrl = new URL(url);
2902
+ var params = new URLSearchParams(newUrl.search);
2903
+ keys.forEach(function (key) { return params.delete(key); });
2904
+ newUrl.search = params.toString();
2905
+ return newUrl;
2906
+ }
2907
+
2868
2908
  /**
2869
2909
  * 匹配中文字母数字
2870
2910
  */
@@ -2890,4 +2930,4 @@ var email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$
2890
2930
  */
2891
2931
  var url = /^https?:\/\/[^\s/$.?#].[^\s]*$/;
2892
2932
 
2893
- export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, RecordType, Request, RequestChain, Tour, countUp, dataHandler, debounce, deepMerge, download, email, findTreeDataNode, findTreeDataNodeName, hasRepeatArray, idCard, ip, isMobileDevice, isNull, objectArrayToString, phone, throttle, url, useCountDown, useDownload, zhLetterNumber };
2933
+ export { HAS_FEILD, InputLegalityValidate, InputLengthValidate, LENGTH_LIMIT, LOGIN_TYPE, Mask, RecordType, Request, RequestChain, Tour, addURLParams, countUp, dataHandler, debounce, deepMerge, deleteURLParams, download, email, findTreeDataNode, findTreeDataNodeName, getURLParams, hasRepeatArray, idCard, ip, isMobileDevice, isNull, objectArrayToString, phone, throttle, uniqueByProperty, url, useCountDown, useDownload, zhLetterNumber };
package/dist/index.umd.js CHANGED
@@ -738,6 +738,21 @@
738
738
  }
739
739
  }
740
740
  }
741
+ /**
742
+ *
743
+ * 数组对象根据某个值去重
744
+ */
745
+ function uniqueByProperty(arr, prop) {
746
+ return arr.reduce(function (acc, current) {
747
+ var x = acc.find(function (item) { return item[prop] === current[prop]; });
748
+ if (!x) {
749
+ return acc.concat([current]);
750
+ }
751
+ else {
752
+ return acc;
753
+ }
754
+ }, []);
755
+ }
741
756
 
742
757
  var Mask = /** @class */ (function () {
743
758
  function Mask(selectors, opacity) {
@@ -1059,6 +1074,31 @@
1059
1074
  return [false];
1060
1075
  }
1061
1076
 
1077
+ function addURLParams(params, url) {
1078
+ url = url || window.location.href;
1079
+ var urlParams = getURLParams(url);
1080
+ var queryString = new URLSearchParams(Object.entries(__assign(__assign({}, urlParams), params))).toString();
1081
+ return {
1082
+ url: "".concat(url, "?").concat(queryString),
1083
+ queryString: queryString,
1084
+ };
1085
+ }
1086
+ function getURLParams(url) {
1087
+ url = url || window.location.href;
1088
+ var urlString = url.split('?')[1];
1089
+ var urlSearchParams = new URLSearchParams(urlString);
1090
+ var result = Object.fromEntries(urlSearchParams.entries());
1091
+ return result;
1092
+ }
1093
+ function deleteURLParams(keys, url) {
1094
+ url = url || window.location.href;
1095
+ var newUrl = new URL(url);
1096
+ var params = new URLSearchParams(newUrl.search);
1097
+ keys.forEach(function (key) { return params.delete(key); });
1098
+ newUrl.search = params.toString();
1099
+ return newUrl;
1100
+ }
1101
+
1062
1102
  /**
1063
1103
  * 匹配中文字母数字
1064
1104
  */
@@ -1090,16 +1130,19 @@
1090
1130
  exports.Request = Request;
1091
1131
  exports.RequestChain = RequestChain;
1092
1132
  exports.Tour = Tour;
1133
+ exports.addURLParams = addURLParams;
1093
1134
  exports.countUp = countUp;
1094
1135
  exports.createWebSocket = createWebSocket;
1095
1136
  exports.dataHandler = dataHandler;
1096
1137
  exports.debounce = debounce;
1097
1138
  exports.deepMerge = deepMerge;
1139
+ exports.deleteURLParams = deleteURLParams;
1098
1140
  exports.download = download;
1099
1141
  exports.email = email;
1100
1142
  exports.findTreeDataNode = findTreeDataNode;
1101
1143
  exports.findTreeDataNodeName = findTreeDataNodeName;
1102
1144
  exports.getState = getState;
1145
+ exports.getURLParams = getURLParams;
1103
1146
  exports.hasRepeatArray = hasRepeatArray;
1104
1147
  exports.idCard = idCard;
1105
1148
  exports.ip = ip;
@@ -1108,6 +1151,7 @@
1108
1151
  exports.objectArrayToString = objectArrayToString;
1109
1152
  exports.phone = phone;
1110
1153
  exports.throttle = throttle;
1154
+ exports.uniqueByProperty = uniqueByProperty;
1111
1155
  exports.url = url;
1112
1156
  exports.useClose = useClose;
1113
1157
  exports.useCountDown = useCountDown;
@@ -99,4 +99,9 @@ export declare function findTreeDataNode(data: ISectoralTable[], targetDeptCode:
99
99
  * @param results 查找结果集
100
100
  */
101
101
  export declare function findTreeDataNodeName(dept: ISectoralTable, queryString: string, results: ISectoralTable[]): void;
102
+ /**
103
+ *
104
+ * 数组对象根据某个值去重
105
+ */
106
+ export declare function uniqueByProperty<T>(arr: T[], prop: keyof T): T[];
102
107
  export {};
@@ -7,3 +7,4 @@ export * from './ws';
7
7
  export * from './download';
8
8
  export * from './number';
9
9
  export * from './array';
10
+ export * from './url';
@@ -0,0 +1,8 @@
1
+ type TAddURLParamsReturn = {
2
+ url: string;
3
+ queryString: string;
4
+ };
5
+ export declare function addURLParams(params: Record<string, any>, url?: string): TAddURLParamsReturn;
6
+ export declare function getURLParams(url?: string): Record<string, any>;
7
+ export declare function deleteURLParams(keys: string[], url?: string): URL;
8
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsoft/js-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.js",