sculp-js 1.4.0 → 1.5.0

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.
Files changed (52) hide show
  1. package/README.md +12 -1
  2. package/lib/cjs/array.js +1 -1
  3. package/lib/cjs/async.js +1 -1
  4. package/lib/cjs/clipboard.js +1 -1
  5. package/lib/cjs/cookie.js +1 -1
  6. package/lib/cjs/date.js +1 -1
  7. package/lib/cjs/dom.js +32 -1
  8. package/lib/cjs/download.js +35 -5
  9. package/lib/cjs/easing.js +1 -1
  10. package/lib/cjs/file.js +1 -1
  11. package/lib/cjs/func.js +1 -1
  12. package/lib/cjs/index.js +5 -3
  13. package/lib/cjs/number.js +1 -1
  14. package/lib/cjs/object.js +1 -1
  15. package/lib/cjs/path.js +1 -1
  16. package/lib/cjs/qs.js +1 -1
  17. package/lib/cjs/random.js +1 -1
  18. package/lib/cjs/string.js +17 -29
  19. package/lib/cjs/tooltip.js +5 -5
  20. package/lib/cjs/tree.js +1 -1
  21. package/lib/cjs/type.js +16 -1
  22. package/lib/cjs/unique.js +1 -1
  23. package/lib/cjs/url.js +1 -1
  24. package/lib/cjs/watermark.js +1 -1
  25. package/lib/cjs/we-decode.js +44 -45
  26. package/lib/es/array.js +1 -1
  27. package/lib/es/async.js +1 -1
  28. package/lib/es/clipboard.js +1 -1
  29. package/lib/es/cookie.js +1 -1
  30. package/lib/es/date.js +1 -1
  31. package/lib/es/dom.js +33 -3
  32. package/lib/es/download.js +35 -6
  33. package/lib/es/easing.js +1 -1
  34. package/lib/es/file.js +1 -1
  35. package/lib/es/func.js +1 -1
  36. package/lib/es/index.js +6 -6
  37. package/lib/es/number.js +1 -1
  38. package/lib/es/object.js +1 -1
  39. package/lib/es/path.js +1 -1
  40. package/lib/es/qs.js +1 -1
  41. package/lib/es/random.js +1 -1
  42. package/lib/es/string.js +17 -29
  43. package/lib/es/tooltip.js +2 -2
  44. package/lib/es/tree.js +1 -1
  45. package/lib/es/type.js +16 -2
  46. package/lib/es/unique.js +1 -1
  47. package/lib/es/url.js +1 -1
  48. package/lib/es/watermark.js +1 -1
  49. package/lib/es/we-decode.js +45 -45
  50. package/lib/index.d.ts +30 -10
  51. package/lib/umd/index.js +138 -74
  52. package/package.json +1 -1
package/lib/es/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -8,7 +8,7 @@ import { arrayEach } from './array.js';
8
8
  import { easingFunctional } from './easing.js';
9
9
  import { objectEach, objectAssign } from './object.js';
10
10
  import { stringKebabCase } from './string.js';
11
- import { isObject } from './type.js';
11
+ import { isObject, isString } from './type.js';
12
12
 
13
13
  /**
14
14
  * 判断元素是否包含某个样式名
@@ -152,5 +152,35 @@ function getComputedCssVal(el, property, reNumber = true) {
152
152
  const originVal = getComputedStyle(el).getPropertyValue(property) ?? '';
153
153
  return reNumber ? Number(originVal.replace(/([0-9]*)(.*)/g, '$1')) : originVal;
154
154
  }
155
+ /**
156
+ * 字符串的像素宽度
157
+ * @param {string} str 目标字符串
158
+ * @param {number} fontSize 字符串字体大小
159
+ * @param {boolean} isRemoveDom 计算后是否移除中间dom元素
160
+ * @returns {*}
161
+ */
162
+ function getStrWidthPx(str, fontSize = 14, isRemoveDom = false) {
163
+ let strWidth = 0;
164
+ console.assert(isString(str), `${str} 不是有效的字符串`);
165
+ if (isString(str) && str.length > 0) {
166
+ let getEle = document.querySelector('#getStrWidth1494304949567');
167
+ if (!getEle) {
168
+ const _ele = document.createElement('span');
169
+ _ele.id = 'getStrWidth1494304949567';
170
+ _ele.style.fontSize = fontSize + 'px';
171
+ _ele.style.whiteSpace = 'nowrap';
172
+ _ele.style.visibility = 'hidden';
173
+ _ele.textContent = str;
174
+ document.body.appendChild(_ele);
175
+ getEle = _ele;
176
+ }
177
+ getEle.textContent = str;
178
+ strWidth = getEle.offsetWidth;
179
+ if (isRemoveDom) {
180
+ document.body.appendChild(getEle);
181
+ }
182
+ }
183
+ return strWidth;
184
+ }
155
185
 
156
- export { addClass, getComputedCssVal, getStyle, hasClass, isDomReady, onDomReady, removeClass, setStyle, smoothScroll };
186
+ export { addClass, getComputedCssVal, getStrWidthPx, getStyle, hasClass, isDomReady, onDomReady, removeClass, setStyle, smoothScroll };
@@ -1,9 +1,10 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
+ import { isFunction } from './type.js';
7
8
  import { urlSetParams } from './url.js';
8
9
 
9
10
  /**
@@ -18,25 +19,53 @@ function downloadURL(url, params) {
18
19
  * 通过 A 链接的方式下载
19
20
  * @param {string} href
20
21
  * @param {string} filename
22
+ * @param {Function} callback
21
23
  */
22
- function downloadHref(href, filename) {
24
+ function downloadHref(href, filename, callback) {
23
25
  const eleLink = document.createElement('a');
24
26
  eleLink.download = filename;
25
27
  eleLink.style.display = 'none';
26
28
  eleLink.href = href;
27
29
  document.body.appendChild(eleLink);
28
30
  eleLink.click();
29
- setTimeout(() => document.body.removeChild(eleLink));
31
+ setTimeout(() => {
32
+ document.body.removeChild(eleLink);
33
+ if (isFunction(callback)) {
34
+ callback();
35
+ }
36
+ });
30
37
  }
31
38
  /**
32
39
  * 将大文件对象通过 A 链接的方式下载
33
40
  * @param {Blob} blob
34
41
  * @param {string} filename
42
+ * @param {Function} callback
35
43
  */
36
- function downloadBlob(blob, filename) {
44
+ function downloadBlob(blob, filename, callback) {
37
45
  const objURL = URL.createObjectURL(blob);
38
46
  downloadHref(objURL, filename);
39
- setTimeout(() => URL.revokeObjectURL(objURL));
47
+ setTimeout(() => {
48
+ URL.revokeObjectURL(objURL);
49
+ if (isFunction(callback)) {
50
+ callback();
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * 根据URL下载文件(解决跨域a.download不生效问题)
56
+ * @param {string} url
57
+ * @param {string} filename
58
+ * @param {Function} callback
59
+ */
60
+ function crossDomainDownload(url, filename, callback) {
61
+ const xhr = new XMLHttpRequest();
62
+ xhr.open('GET', url, true);
63
+ xhr.responseType = 'blob';
64
+ xhr.onload = function () {
65
+ if (xhr.status === 200)
66
+ downloadBlob(xhr.response, filename, callback);
67
+ };
68
+ xhr.send();
40
69
  }
41
70
  /**
42
71
  * 将指定数据格式通过 A 链接的方式下载
@@ -74,4 +103,4 @@ function downloadData(data, fileType, filename, headers) {
74
103
  }
75
104
  }
76
105
 
77
- export { downloadBlob, downloadData, downloadHref, downloadURL };
106
+ export { crossDomainDownload, downloadBlob, downloadData, downloadHref, downloadURL };
package/lib/es/easing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/file.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/func.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -8,13 +8,13 @@ export { arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove }
8
8
  export { copyText } from './clipboard.js';
9
9
  export { cookieDel, cookieGet, cookieSet } from './cookie.js';
10
10
  export { calculateDate, calculateDateTime, dateParse, dateToEnd, dateToStart, formatDate, isValidDate } from './date.js';
11
- export { addClass, getComputedCssVal, getStyle, hasClass, isDomReady, onDomReady, removeClass, setStyle, smoothScroll } from './dom.js';
12
- export { downloadBlob, downloadData, downloadHref, downloadURL } from './download.js';
11
+ export { addClass, getComputedCssVal, getStrWidthPx, getStyle, hasClass, isDomReady, onDomReady, removeClass, setStyle, smoothScroll } from './dom.js';
12
+ export { crossDomainDownload, downloadBlob, downloadData, downloadHref, downloadURL } from './download.js';
13
13
  export { cloneDeep, isPlainObject, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick } from './object.js';
14
14
  export { pathJoin, pathNormalize } from './path.js';
15
15
  export { qsParse, qsStringify } from './qs.js';
16
- export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, getStrWidthPx, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase } from './string.js';
17
- export { isArray, isBigInt, isBoolean, isDate, isError, isFunction, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, typeIs } from './type.js';
16
+ export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, parseQueryParams, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase } from './string.js';
17
+ export { isArray, isBigInt, isBoolean, isDate, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, typeIs } from './type.js';
18
18
  export { urlDelParams, urlParse, urlSetParams, urlStringify } from './url.js';
19
19
  export { asyncMap, wait } from './async.js';
20
20
  export { chooseLocalFile, compressImg, supportCanvas } from './file.js';
@@ -25,4 +25,4 @@ export { HEX_POOL, formatNumber, numberAbbr, numberToHex } from './number.js';
25
25
  export { UNIQUE_NUMBER_SAFE_LENGTH, uniqueNumber, uniqueString } from './unique.js';
26
26
  export { tooltipEvent } from './tooltip.js';
27
27
  export { buildTree, flatTree, forEachDeep, forEachMap, formatTree, fuzzySearchTree, searchTreeById } from './tree.js';
28
- export { weAppJwtDecode, weAtob, weBtoa } from './we-decode.js';
28
+ export { weAtob, weBtoa } from './we-decode.js';
package/lib/es/number.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/object.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/path.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/qs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/random.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/string.js CHANGED
@@ -1,11 +1,9 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
- import { isString } from './type.js';
8
-
9
7
  /**
10
8
  * 将字符串转换为驼峰格式
11
9
  * @param {string} string
@@ -123,34 +121,24 @@ const stringEscapeHtml = (html) => {
123
121
  */
124
122
  const stringFill = (length, value = ' ') => new Array(length).fill(value).join('');
125
123
  /**
126
- * 字符串的像素宽度
127
- * @param {string} str 目标字符串
128
- * @param {number} fontSize 字符串字体大小
129
- * @param {boolean} isRemoveDom 计算后是否移除中间dom元素
130
- * @returns {*}
124
+ * 解析URL查询参数
125
+ * @param {string} searchStr
126
+ * @return {Record<string, string | string[]>}
131
127
  */
132
- function getStrWidthPx(str, fontSize = 14, isRemoveDom = false) {
133
- let strWidth = 0;
134
- console.assert(isString(str), `${str} 不是有效的字符串`);
135
- if (isString(str) && str.length > 0) {
136
- let getEle = document.querySelector('#getStrWidth1494304949567');
137
- if (!getEle) {
138
- const _ele = document.createElement('span');
139
- _ele.id = 'getStrWidth1494304949567';
140
- _ele.style.fontSize = fontSize + 'px';
141
- _ele.style.whiteSpace = 'nowrap';
142
- _ele.style.visibility = 'hidden';
143
- _ele.textContent = str;
144
- document.body.appendChild(_ele);
145
- getEle = _ele;
128
+ function parseQueryParams(searchStr = location.search) {
129
+ const queryObj = {};
130
+ Array.from(searchStr.matchAll(/[&?]?([^=&]+)=?([^=&]*)/g)).forEach((item, i) => {
131
+ if (!queryObj[item[1]]) {
132
+ queryObj[item[1]] = item[2];
146
133
  }
147
- getEle.textContent = str;
148
- strWidth = getEle.offsetWidth;
149
- if (isRemoveDom) {
150
- document.body.appendChild(getEle);
134
+ else if (typeof queryObj[item[1]] === 'string') {
135
+ queryObj[item[1]] = [queryObj[item[1]], item[2]];
151
136
  }
152
- }
153
- return strWidth;
137
+ else {
138
+ queryObj[item[1]].push(item[2]);
139
+ }
140
+ });
141
+ return queryObj;
154
142
  }
155
143
 
156
- export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, getStrWidthPx, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase };
144
+ export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, parseQueryParams, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase };
package/lib/es/tooltip.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
- import { getStrWidthPx } from './string.js';
7
+ import { getStrWidthPx } from './dom.js';
8
8
 
9
9
  /**
10
10
  * @title tooltip
package/lib/es/tree.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/type.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -36,5 +36,19 @@ const isNaN = (any) => Number.isNaN(any);
36
36
  const isDate = (any) => typeIs(any) === 'Date';
37
37
  const isError = (any) => typeIs(any) === 'Error';
38
38
  const isRegExp = (any) => typeIs(any) === 'RegExp';
39
+ /**
40
+ * 判断一个字符串是否为有效的 JSON, 若有效则返回有效的JSON对象,否则false
41
+ * @param {string} str
42
+ * @return {Object | boolean}
43
+ */
44
+ function isJsonString(str) {
45
+ try {
46
+ const parsed = JSON.parse(str);
47
+ return typeof parsed === 'object' && parsed !== null ? parsed : false;
48
+ }
49
+ catch (e) {
50
+ return false;
51
+ }
52
+ }
39
53
 
40
- export { typeIs as default, isArray, isBigInt, isBoolean, isDate, isError, isFunction, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, typeIs };
54
+ export { typeIs as default, isArray, isBigInt, isBoolean, isDate, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, typeIs };
package/lib/es/unique.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/url.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.4.0
2
+ * sculp-js v1.4.1
3
3
  * (c) 2023-2024 chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -56,48 +56,48 @@ function weAtob(string) {
56
56
  }
57
57
  return result;
58
58
  }
59
- function b64DecodeUnicode(str) {
60
- return decodeURIComponent(exports.weAtob(str).replace(/(.)/g, function (p) {
61
- let code = p.charCodeAt(0).toString(16).toUpperCase();
62
- if (code.length < 2) {
63
- code = '0' + code;
64
- }
65
- return '%' + code;
66
- }));
67
- }
68
- function base64_url_decode(str) {
69
- let output = str.replace(/-/g, '+').replace(/_/g, '/');
70
- switch (output.length % 4) {
71
- case 0:
72
- break;
73
- case 2:
74
- output += '==';
75
- break;
76
- case 3:
77
- output += '=';
78
- break;
79
- default:
80
- throw new Error('Illegal base64url string!');
81
- }
82
- try {
83
- return b64DecodeUnicode(output);
84
- }
85
- catch (err) {
86
- return exports.weAtob(output);
87
- }
88
- }
89
- function weAppJwtDecode(token, options) {
90
- if (typeof token !== 'string') {
91
- throw new Error('Invalid token specified');
92
- }
93
- options = options || {};
94
- const pos = options.header === true ? 0 : 1;
95
- try {
96
- return JSON.parse(base64_url_decode(token.split('.')[pos]));
97
- }
98
- catch (e) {
99
- throw new Error('Invalid token specified: ' + e.message);
100
- }
101
- }
59
+ // function b64DecodeUnicode(str) {
60
+ // return decodeURIComponent(
61
+ // exports.weAtob(str).replace(/(.)/g, function (p) {
62
+ // let code = p.charCodeAt(0).toString(16).toUpperCase();
63
+ // if (code.length < 2) {
64
+ // code = '0' + code;
65
+ // }
66
+ // return '%' + code;
67
+ // })
68
+ // );
69
+ // }
70
+ // function base64_url_decode(str) {
71
+ // let output = str.replace(/-/g, '+').replace(/_/g, '/');
72
+ // switch (output.length % 4) {
73
+ // case 0:
74
+ // break;
75
+ // case 2:
76
+ // output += '==';
77
+ // break;
78
+ // case 3:
79
+ // output += '=';
80
+ // break;
81
+ // default:
82
+ // throw new Error('Illegal base64url string!');
83
+ // }
84
+ // try {
85
+ // return b64DecodeUnicode(output);
86
+ // } catch (err) {
87
+ // return exports.weAtob(output);
88
+ // }
89
+ // }
90
+ // export function weAppJwtDecode(token, options) {
91
+ // if (typeof token !== 'string') {
92
+ // throw new Error('Invalid token specified');
93
+ // }
94
+ // options = options || {};
95
+ // const pos = options.header === true ? 0 : 1;
96
+ // try {
97
+ // return JSON.parse(base64_url_decode(token.split('.')[pos]));
98
+ // } catch (e) {
99
+ // throw new Error('Invalid token specified: ' + (e as Error).message);
100
+ // }
101
+ // }
102
102
 
103
- export { weAppJwtDecode, weAtob, weBtoa };
103
+ export { weAtob, weBtoa };
package/lib/index.d.ts CHANGED
@@ -36,6 +36,12 @@ declare const isNaN: (any: unknown) => any is number;
36
36
  declare const isDate: (any: unknown) => any is Date;
37
37
  declare const isError: (any: unknown) => any is Error;
38
38
  declare const isRegExp: (any: unknown) => any is RegExp;
39
+ /**
40
+ * 判断一个字符串是否为有效的 JSON, 若有效则返回有效的JSON对象,否则false
41
+ * @param {string} str
42
+ * @return {Object | boolean}
43
+ */
44
+ declare function isJsonString(str: string): Object | boolean;
39
45
 
40
46
  /**
41
47
  * 判断一个对象是否为类数组
@@ -237,6 +243,14 @@ declare function onDomReady(callback: ReadyCallback): void;
237
243
  * @returns {string|number}
238
244
  */
239
245
  declare function getComputedCssVal(el: HTMLElement, property: string, reNumber?: boolean): string | number;
246
+ /**
247
+ * 字符串的像素宽度
248
+ * @param {string} str 目标字符串
249
+ * @param {number} fontSize 字符串字体大小
250
+ * @param {boolean} isRemoveDom 计算后是否移除中间dom元素
251
+ * @returns {*}
252
+ */
253
+ declare function getStrWidthPx(str: string, fontSize?: number, isRemoveDom?: boolean): number;
240
254
 
241
255
  interface Params<T = string | number> {
242
256
  [key: string]: T | Array<T>;
@@ -270,14 +284,23 @@ declare function downloadURL(url: string, params?: LooseParams): void;
270
284
  * 通过 A 链接的方式下载
271
285
  * @param {string} href
272
286
  * @param {string} filename
287
+ * @param {Function} callback
273
288
  */
274
- declare function downloadHref(href: string, filename: string): void;
289
+ declare function downloadHref(href: string, filename: string, callback?: Function): void;
275
290
  /**
276
291
  * 将大文件对象通过 A 链接的方式下载
277
292
  * @param {Blob} blob
278
293
  * @param {string} filename
294
+ * @param {Function} callback
279
295
  */
280
- declare function downloadBlob(blob: Blob, filename: string): void;
296
+ declare function downloadBlob(blob: Blob, filename: string, callback?: Function): void;
297
+ /**
298
+ * 根据URL下载文件(解决跨域a.download不生效问题)
299
+ * @param {string} url
300
+ * @param {string} filename
301
+ * @param {Function} callback
302
+ */
303
+ declare function crossDomainDownload(url: string, filename: string, callback?: Function): void;
281
304
  type FileType = 'json' | 'csv' | 'xls' | 'xlsx';
282
305
  /**
283
306
  * 将指定数据格式通过 A 链接的方式下载
@@ -438,13 +461,11 @@ declare const stringEscapeHtml: (html: string) => string;
438
461
  */
439
462
  declare const stringFill: (length: number, value?: string) => string;
440
463
  /**
441
- * 字符串的像素宽度
442
- * @param {string} str 目标字符串
443
- * @param {number} fontSize 字符串字体大小
444
- * @param {boolean} isRemoveDom 计算后是否移除中间dom元素
445
- * @returns {*}
464
+ * 解析URL查询参数
465
+ * @param {string} searchStr
466
+ * @return {Record<string, string | string[]>}
446
467
  */
447
- declare function getStrWidthPx(str: string, fontSize?: number, isRemoveDom?: boolean): number;
468
+ declare function parseQueryParams(searchStr?: string): Record<string, string | string[]>;
448
469
 
449
470
  interface Url {
450
471
  protocol: string;
@@ -820,6 +841,5 @@ declare function weBtoa(string: string): string;
820
841
  * @return {string}
821
842
  */
822
843
  declare function weAtob(string: string): string;
823
- declare function weAppJwtDecode(token: any, options: any): any;
824
844
 
825
- export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, type FileType, HEX_POOL, type ICanvasWM, type ICompressOptions, type IFieldOptions, type ISearchTreeOpts, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, type UniqueString, type Url, type WithChildren, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, buildTree, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, compressImg, cookieDel, cookieGet, cookieSet, copyText, dateParse, dateToEnd, dateToStart, debounce, downloadBlob, downloadData, downloadHref, downloadURL, flatTree, forEachDeep, forEachMap, formatDate, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isError, isFunction, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isValidDate, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, searchTreeById, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, supportCanvas, throttle, tooltipEvent, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait, weAppJwtDecode, weAtob, weBtoa };
845
+ export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, type FileType, HEX_POOL, type ICanvasWM, type ICompressOptions, type IFieldOptions, type ISearchTreeOpts, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, type UniqueString, type Url, type WithChildren, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, buildTree, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, compressImg, cookieDel, cookieGet, cookieSet, copyText, crossDomainDownload, dateParse, dateToEnd, dateToStart, debounce, downloadBlob, downloadData, downloadHref, downloadURL, flatTree, forEachDeep, forEachMap, formatDate, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isValidDate, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, parseQueryParams, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, searchTreeById, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, supportCanvas, throttle, tooltipEvent, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait, weAtob, weBtoa };