zmdms-utils 0.0.29 → 0.0.31

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.
@@ -0,0 +1 @@
1
+ export { convert, html, match, pinyin } from './node_modules/pinyin-pro/dist/index.js';
@@ -18,5 +18,9 @@ declare const emailValidate: {
18
18
  regex: RegExp;
19
19
  message: string;
20
20
  };
21
+ declare const isChineseValidate: {
22
+ regex: RegExp;
23
+ message: string;
24
+ };
21
25
 
22
- export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate };
26
+ export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate };
@@ -39,5 +39,9 @@ var emailValidate = {
39
39
  regex: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
40
40
  message: "请输入正确的邮箱!",
41
41
  };
42
+ var isChineseValidate = {
43
+ regex: /[\u4e00-\u9fa5]/,
44
+ message: "请输入中文!",
45
+ };
42
46
 
43
- export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate };
47
+ export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate };
package/dist/index.d.ts CHANGED
@@ -5,10 +5,11 @@ export { getToken, removeToken, setToken } from './es/auth.js';
5
5
  export { AxiosRequest, IOptions, IOtherOptions } from './es/request.js';
6
6
  export { getBaseUrl } from './es/baseUrl.js';
7
7
  export { Crypto, md5 } from './es/crypto.js';
8
- export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
8
+ export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
9
9
  export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
10
10
  export { validatePassword } from './es/passwordValidate.js';
11
- export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
11
+ export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
12
12
  export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile } from './es/file.js';
13
13
  export { calculateAge, parseTime } from './es/parseTime.js';
14
14
  export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from './es/constants.js';
15
+ export { convert, html, match, pinyin } from 'pinyin-pro';
package/dist/index.js CHANGED
@@ -5,10 +5,11 @@ export { getToken, removeToken, setToken } from './es/auth.js';
5
5
  export { AxiosRequest } from './es/request.js';
6
6
  export { getBaseUrl } from './es/baseUrl.js';
7
7
  export { Crypto, md5 } from './es/crypto.js';
8
- export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
8
+ export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
9
9
  export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
10
10
  export { validatePassword } from './es/passwordValidate.js';
11
- export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
11
+ export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
12
12
  export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile } from './es/file.js';
13
13
  export { calculateAge, parseTime } from './es/parseTime.js';
14
14
  export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from './es/constants.js';
15
+ export { convert, html, match, pinyin } from './es/node_modules/pinyin-pro/dist/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -15,12 +15,13 @@
15
15
  "peerDependencies": {
16
16
  "axios": "^1.4.0",
17
17
  "crypto-js": "^4.1.1",
18
- "qiankun": "^2.10.8",
19
- "dayjs": "^1.11.7"
18
+ "dayjs": "^1.11.7",
19
+ "qiankun": "^2.10.8"
20
20
  },
21
21
  "dependencies": {
22
22
  "decimal.js": "^10.4.3",
23
- "mitt": "^3.0.0"
23
+ "mitt": "^3.0.0",
24
+ "pinyin-pro": "^3.18.2"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@rollup/plugin-commonjs": "^24.0.1",
package/src/common.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // 基础函数
2
2
  import mitt from "mitt";
3
+ import { isChineseValidate } from "./validate";
3
4
  /**
4
5
  * 同步阻断
5
6
  * @param time 秒
@@ -74,21 +75,35 @@ export function parseQueryParams(url: string): { [key: string]: string } {
74
75
  return {};
75
76
  }
76
77
  const queryString = url.split("?")[1];
77
- const params = new URLSearchParams(queryString);
78
78
  const result: { [key: string]: string } = {};
79
- params.forEach((value, key) => {
80
- let val: any = decodeURIComponent(value);
81
- if (val.startsWith("{")) {
82
- try {
83
- val = JSON.parse(val);
84
- } catch (err) {
85
- console.log("解析失败", err);
79
+ if (typeof URLSearchParams === "function") {
80
+ const params = new URLSearchParams(queryString);
81
+ params.forEach((value, key) => {
82
+ let val: any = decodeURIComponent(value);
83
+ if (val.startsWith("{")) {
84
+ try {
85
+ val = JSON.parse(val);
86
+ } catch (err) {
87
+ console.log("解析失败", err);
88
+ }
89
+ } else if (val === "true" || val === "false") {
90
+ val = val === "true";
91
+ }
92
+ result[key] = val;
93
+ });
94
+ } else {
95
+ try {
96
+ if (queryString) {
97
+ const searchList = queryString.split("&");
98
+ for (let i = 0; i < searchList.length; i++) {
99
+ const [key, value] = searchList[i].split("=");
100
+ result[key] = value;
101
+ }
86
102
  }
87
- } else if (val === "true" || val === "false") {
88
- val = val === "true";
103
+ } catch (err) {
104
+ console.log(err);
89
105
  }
90
- result[key] = val;
91
- });
106
+ }
92
107
  return result;
93
108
  }
94
109
 
@@ -236,3 +251,15 @@ export function parseJoin(params?: any) {
236
251
  }
237
252
  return params;
238
253
  }
254
+
255
+ /**
256
+ * 判断字符串是否是中文文本
257
+ * @param char 字符
258
+ * @returns
259
+ */
260
+ export function isChinese(char?: string) {
261
+ if (!char) {
262
+ return false;
263
+ }
264
+ return isChineseValidate.regex.test(char);
265
+ }
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ export {
18
18
  specialString,
19
19
  isNonEmpty,
20
20
  parseJoin,
21
+ isChinese,
21
22
  } from "./common";
22
23
  export { plus, minus, times, divide, exactRound, formatUnit } from "./math";
23
24
  export { validatePassword } from "./passwordValidate";
@@ -27,6 +28,7 @@ export {
27
28
  morePhoneValidate,
28
29
  idCardValidate,
29
30
  emailValidate,
31
+ isChineseValidate,
30
32
  } from "./validate";
31
33
  /** 附件预览相关 */
32
34
  export {
@@ -49,3 +51,8 @@ export { parseTime, calculateAge } from "./parseTime";
49
51
  * 常量相关
50
52
  */
51
53
  export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from "./constants";
54
+
55
+ /**
56
+ * 中文处理
57
+ */
58
+ export { pinyin, match, convert, html } from "./pinyin";
package/src/pinyin.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { pinyin, match, convert, html } from "pinyin-pro";
2
+
3
+ export { pinyin, match, convert, html };
package/src/validate.ts CHANGED
@@ -43,3 +43,8 @@ export const emailValidate = {
43
43
  regex: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
44
44
  message: "请输入正确的邮箱!",
45
45
  };
46
+
47
+ export const isChineseValidate = {
48
+ regex: /[\u4e00-\u9fa5]/,
49
+ message: "请输入中文!",
50
+ };