zmdms-utils 0.0.75 → 0.0.77

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 (79) hide show
  1. package/dist/es/_virtual/_commonjsHelpers.js +3 -0
  2. package/dist/es/_virtual/_tslib.js +87 -0
  3. package/dist/es/_virtual/decimal.js +7 -0
  4. package/dist/es/_virtual/parseTimeTest.js +3 -0
  5. package/dist/es/_virtual/test.js +3 -0
  6. package/dist/es/auth.d.ts +9 -0
  7. package/dist/es/auth.js +49 -0
  8. package/dist/es/baseUrl.d.ts +23 -0
  9. package/dist/es/baseUrl.js +50 -0
  10. package/dist/es/canvas.d.ts +6 -0
  11. package/dist/es/canvas.js +14 -0
  12. package/dist/es/common.d.ts +81 -0
  13. package/dist/es/common.js +304 -0
  14. package/dist/es/constants.d.ts +20 -0
  15. package/dist/es/constants.js +33 -0
  16. package/dist/es/crypto.d.ts +51 -0
  17. package/dist/es/crypto.js +97 -0
  18. package/dist/es/file.d.ts +127 -0
  19. package/dist/es/file.js +373 -0
  20. package/dist/es/htmlToPdf.d.ts +44 -0
  21. package/dist/es/htmlToPdf.js +84 -0
  22. package/dist/es/locales/i18n.d.ts +15 -0
  23. package/dist/es/locales/t-in-non-react.d.ts +17 -0
  24. package/dist/es/locales/t-options.d.ts +7 -0
  25. package/dist/es/locales/use-translation.d.ts +42 -0
  26. package/dist/es/mainApp.d.ts +36 -0
  27. package/dist/es/mainApp.js +44 -0
  28. package/dist/es/math.d.ts +29 -0
  29. package/dist/es/math.js +147 -0
  30. package/dist/es/microAppCreator.d.ts +46 -0
  31. package/dist/es/microAppCreator.js +89 -0
  32. package/dist/es/node_modules/decimal.js/decimal.js +4896 -0
  33. package/dist/es/node_modules/decimal.js/decimal2.js +4930 -0
  34. package/dist/es/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js +5 -0
  35. package/dist/es/node_modules/i18next/dist/esm/i18next.js +2242 -0
  36. package/dist/es/node_modules/js-base64/base64.js +273 -0
  37. package/dist/es/node_modules/jwt-decode/build/jwt-decode.esm.js +3 -0
  38. package/dist/es/node_modules/mitt/dist/mitt.js +3 -0
  39. package/dist/es/node_modules/pinyin-pro/dist/index.js +12627 -0
  40. package/dist/es/node_modules/react-i18next/dist/es/Trans.js +47 -0
  41. package/dist/es/node_modules/react-i18next/dist/es/TransWithoutContext.js +312 -0
  42. package/dist/es/node_modules/react-i18next/dist/es/context.js +18 -0
  43. package/dist/es/node_modules/react-i18next/dist/es/defaults.js +21 -0
  44. package/dist/es/node_modules/react-i18next/dist/es/i18nInstance.js +7 -0
  45. package/dist/es/node_modules/react-i18next/dist/es/initReactI18next.js +12 -0
  46. package/dist/es/node_modules/react-i18next/dist/es/unescape.js +27 -0
  47. package/dist/es/node_modules/react-i18next/dist/es/useTranslation.js +112 -0
  48. package/dist/es/node_modules/react-i18next/dist/es/utils.js +63 -0
  49. package/dist/es/node_modules/void-elements/index.js +23 -0
  50. package/dist/es/parseTime.d.ts +29 -0
  51. package/dist/es/parseTime.js +189 -0
  52. package/dist/es/parseTimeTest.js +2 -0
  53. package/dist/es/passwordValidate.d.ts +9 -0
  54. package/dist/es/passwordValidate.js +169 -0
  55. package/dist/es/pdf.d.ts +49 -0
  56. package/dist/es/pdf.js +176 -0
  57. package/dist/es/pinyin.js +1 -0
  58. package/dist/es/print.d.ts +23 -0
  59. package/dist/es/print.js +43 -0
  60. package/dist/es/qiankunUtils.d.ts +13 -0
  61. package/dist/es/qiankunUtils.js +32 -0
  62. package/dist/es/request.d.ts +87 -0
  63. package/dist/es/request.js +308 -0
  64. package/dist/es/src/locales/i18n.js +16 -0
  65. package/dist/es/src/locales/t-in-non-react.js +54 -0
  66. package/dist/es/src/locales/t-options.js +20 -0
  67. package/dist/es/src/locales/use-translation.js +60 -0
  68. package/dist/es/src/parseTimeTest.js +288 -0
  69. package/dist/es/src/test.js +245 -0
  70. package/dist/es/test.js +2 -0
  71. package/dist/es/validate.d.ts +26 -0
  72. package/dist/es/validate.js +47 -0
  73. package/dist/es/water.d.ts +53 -0
  74. package/dist/es/water.js +88 -0
  75. package/dist/index.d.ts +26 -0
  76. package/dist/index.js +26 -0
  77. package/package.json +1 -1
  78. package/src/file.ts +1 -1
  79. package/src/math.ts +1 -1
@@ -0,0 +1,3 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ export { commonjsGlobal };
@@ -0,0 +1,87 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+
16
+ var __assign = function() {
17
+ __assign = Object.assign || function __assign(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+
27
+ function __rest(s, e) {
28
+ var t = {};
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
+ t[p] = s[p];
31
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
+ t[p[i]] = s[p[i]];
35
+ }
36
+ return t;
37
+ }
38
+
39
+ function __awaiter(thisArg, _arguments, P, generator) {
40
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
41
+ return new (P || (P = Promise))(function (resolve, reject) {
42
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
43
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
44
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
45
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
46
+ });
47
+ }
48
+
49
+ function __generator(thisArg, body) {
50
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
51
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
52
+ function verb(n) { return function (v) { return step([n, v]); }; }
53
+ function step(op) {
54
+ if (f) throw new TypeError("Generator is already executing.");
55
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
56
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
57
+ if (y = 0, t) op = [op[0] & 2, t.value];
58
+ switch (op[0]) {
59
+ case 0: case 1: t = op; break;
60
+ case 4: _.label++; return { value: op[1], done: false };
61
+ case 5: _.label++; y = op[1]; op = [0]; continue;
62
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
63
+ default:
64
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
65
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
66
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
67
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
68
+ if (t[2]) _.ops.pop();
69
+ _.trys.pop(); continue;
70
+ }
71
+ op = body.call(thisArg, _);
72
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
73
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
74
+ }
75
+ }
76
+
77
+ function __spreadArray(to, from, pack) {
78
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
79
+ if (ar || !(i in from)) {
80
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
81
+ ar[i] = from[i];
82
+ }
83
+ }
84
+ return to.concat(ar || Array.prototype.slice.call(from));
85
+ }
86
+
87
+ export { __assign, __awaiter, __generator, __rest, __spreadArray };
@@ -0,0 +1,7 @@
1
+ var decimalExports = {};
2
+ var decimal = {
3
+ get exports(){ return decimalExports; },
4
+ set exports(v){ decimalExports = v; },
5
+ };
6
+
7
+ export { decimal as __module, decimalExports as exports };
@@ -0,0 +1,3 @@
1
+ var parseTimeTest = {};
2
+
3
+ export { parseTimeTest as __exports };
@@ -0,0 +1,3 @@
1
+ var test = {};
2
+
3
+ export { test as __exports };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 权限相关
3
+ */
4
+ declare function getToken(): string | null;
5
+ declare function setToken(token: string): void;
6
+ declare function removeToken(): void;
7
+ declare function parseToken(token?: string): unknown;
8
+
9
+ export { getToken, parseToken, removeToken, setToken };
@@ -0,0 +1,49 @@
1
+ import o from './node_modules/jwt-decode/build/jwt-decode.esm.js';
2
+
3
+ /**
4
+ * 权限相关
5
+ */
6
+ function getToken() {
7
+ try {
8
+ return window.localStorage.getItem("system-token");
9
+ }
10
+ catch (err) {
11
+ console.error("获取token失败", err);
12
+ return "";
13
+ }
14
+ }
15
+ function setToken(token) {
16
+ try {
17
+ window.localStorage.setItem("system-token", token);
18
+ }
19
+ catch (err) {
20
+ console.error("设置token失败", err);
21
+ }
22
+ }
23
+ function removeToken() {
24
+ try {
25
+ window.localStorage.removeItem("system-token");
26
+ }
27
+ catch (err) {
28
+ console.error("设置token失败", err);
29
+ }
30
+ }
31
+ function parseToken(token) {
32
+ var t = token;
33
+ if (!t) {
34
+ t = getToken();
35
+ }
36
+ if (t) {
37
+ try {
38
+ return o(t);
39
+ }
40
+ catch (err) {
41
+ console.log("解析失败", err);
42
+ return null;
43
+ }
44
+ }
45
+ // 没有token
46
+ return null;
47
+ }
48
+
49
+ export { getToken, parseToken, removeToken, setToken };
@@ -0,0 +1,23 @@
1
+ interface IOptions {
2
+ /** 环境变量key值 */
3
+ envKey: string;
4
+ /** api地址的前缀key */
5
+ apiKey: string;
6
+ /** 附件服务器前缀key */
7
+ fileKey: string;
8
+ /** 退出登录默认的key */
9
+ logoutKey: string;
10
+ /** 数字中心各个环境key值 */
11
+ cicomsKey?: string;
12
+ /** 外网服务器前缀key值 */
13
+ outKey?: string;
14
+ }
15
+ declare function getBaseUrl(processObj: any, options?: IOptions): {
16
+ API_URL: any;
17
+ CICOMS_API_URL: any;
18
+ FILE_URL: any;
19
+ OUTHR_DOMAIN: any;
20
+ LOGOUT_URL: any;
21
+ };
22
+
23
+ export { getBaseUrl };
@@ -0,0 +1,50 @@
1
+ // 根据当前环境变量获取基础的URL
2
+ function getBaseUrl(processObj, options) {
3
+ var _a = options || {}, _b = _a.envKey, envKey = _b === void 0 ? "REACT_APP_ENV" : _b, _c = _a.apiKey, apiKey = _c === void 0 ? "REACT_APP_API" : _c, _d = _a.fileKey, fileKey = _d === void 0 ? "REACT_APP_FILE" : _d, _e = _a.logoutKey, logoutKey = _e === void 0 ? "REACT_APP_LOGOUT" : _e, _f = _a.cicomsKey, cicomsKey = _f === void 0 ? "REACT_APP_CICOMS_API" : _f, _g = _a.outKey, outKey = _g === void 0 ? "REACT_APP_OUTHR_API" : _g;
4
+ var ENV = processObj[envKey]; // 获取当前环境变量
5
+ // api各个环境地址
6
+ var apiBaseUrlObj = {
7
+ dev: processObj["".concat(apiKey, "_DEV")] || window.location.origin,
8
+ test: processObj["".concat(apiKey, "_TEST")] || window.location.origin,
9
+ stage: processObj["".concat(apiKey, "_STAGE")] || window.location.origin,
10
+ prod: processObj["".concat(apiKey, "_PROD")] || window.location.origin,
11
+ };
12
+ // 数字中心各个环境地址
13
+ var cicomsApiBaseUrlObj = {
14
+ dev: processObj["".concat(cicomsKey, "_DEV")] || window.location.origin,
15
+ test: processObj["".concat(cicomsKey, "_TEST")] || window.location.origin,
16
+ stage: processObj["".concat(cicomsKey, "_STAGE")] || window.location.origin,
17
+ prod: processObj["".concat(cicomsKey, "_PROD")] || window.location.origin,
18
+ };
19
+ // file 服务器
20
+ var fileBaseUrlObj = {
21
+ dev: processObj["".concat(fileKey, "_DEV")] || window.location.origin,
22
+ test: processObj["".concat(fileKey, "_TEST")] || window.location.origin,
23
+ stage: processObj["".concat(fileKey, "_STAGE")] || window.location.origin,
24
+ prod: processObj["".concat(fileKey, "_PROD")] || window.location.origin,
25
+ };
26
+ // 外网项目各个环境地址
27
+ var outHrDomain = {
28
+ dev: processObj["".concat(outKey, "_DEV")] || "http://192.168.0.134:18886",
29
+ test: processObj["".concat(outKey, "_TEST")] || "http://hr-out.cico.com.cn:30601",
30
+ stage: processObj["".concat(outKey, "_STAGE")] || "http://10.100.234.36:18886",
31
+ prod: processObj["".concat(outKey, "_PROD")] || "https://dhr.cncico.com:18443",
32
+ };
33
+ // 退出登录地址
34
+ var logoutUrl = {
35
+ dev: processObj["".concat(logoutKey, "_DEV")] || "/login",
36
+ test: processObj["".concat(logoutKey, "_TEST")] || "/login",
37
+ stage: processObj["".concat(logoutKey, "_STAGE")] || "http://testportal.cncico.com:8099/",
38
+ prod: processObj["".concat(logoutKey, "_PROD")] || "http://newportal.cncico.com/",
39
+ };
40
+ var currentKey = ENV.toLowerCase() || "prod";
41
+ return {
42
+ API_URL: apiBaseUrlObj[currentKey] || apiBaseUrlObj["prod"],
43
+ CICOMS_API_URL: cicomsApiBaseUrlObj[currentKey] || cicomsApiBaseUrlObj["prod"],
44
+ FILE_URL: fileBaseUrlObj[currentKey] || fileBaseUrlObj["prod"],
45
+ OUTHR_DOMAIN: outHrDomain[currentKey] || outHrDomain["prod"],
46
+ LOGOUT_URL: logoutUrl[currentKey] || logoutUrl["prod"],
47
+ };
48
+ }
49
+
50
+ export { getBaseUrl };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * dom 转 canvas
3
+ */
4
+ declare function domToCanvas(dom: HTMLElement): Promise<HTMLCanvasElement>;
5
+
6
+ export { domToCanvas };
@@ -0,0 +1,14 @@
1
+ import html2canvas from 'html2canvas';
2
+
3
+ /**
4
+ * dom 转 canvas
5
+ */
6
+ function domToCanvas(dom) {
7
+ return html2canvas(dom, {
8
+ useCORS: true,
9
+ allowTaint: true,
10
+ scale: 2, // 用于渲染的比例。默认为浏览器设备像素比 如果dom区域较大,下载会出现部分灰色区域,需要加scale解决
11
+ });
12
+ }
13
+
14
+ export { domToCanvas };
@@ -0,0 +1,81 @@
1
+ import * as mitt from 'mitt';
2
+
3
+ /**
4
+ * 同步阻断
5
+ * @param time 秒
6
+ */
7
+ declare function delay(time: number): void;
8
+ /**
9
+ * 发布订阅实例
10
+ */
11
+ declare const emitter: mitt.Emitter<Record<mitt.EventType, unknown>>;
12
+ /**
13
+ * 添加位数分割符
14
+ * @param n 需要分割的字符
15
+ * @param digit 多少位分割
16
+ * @param symbol 添加的符号
17
+ * @returns
18
+ */
19
+ declare function addThousedSeparator(n: any, digit?: number, symbol?: string): any;
20
+ /**
21
+ * 获取地址栏参数
22
+ * @returns 地址栏参数对象
23
+ */
24
+ declare function parseQueryParams(url: string): {
25
+ [key: string]: string;
26
+ };
27
+ /**
28
+ * 将一些转义字符转换成原先的字符
29
+ * @param input 需要转换的内容
30
+ * @returns 转换过后的结果
31
+ */
32
+ declare function unescapeString(input: string): string;
33
+ /**
34
+ * 将一些危险字符替换成后台能识别的字符
35
+ * @param input 需要转换的内容
36
+ * @returns 转换过后的结果
37
+ */
38
+ declare function dangerouslyXss(input: string): string;
39
+ /**
40
+ * 去除特殊字符。这个方法在附件预览的场景中有用到
41
+ */
42
+ declare function specialString(input: string): string;
43
+ /**
44
+ * 将内容复制到粘贴板中
45
+ * @param text 需要复制的内容
46
+ */
47
+ declare function copyToClipboard(text: string, callback?: any): void;
48
+ /**
49
+ * 获取文件名中的后缀 返回文件名 + 后缀
50
+ * @param fileName 文件名
51
+ * @returns
52
+ */
53
+ declare function getFileExtension(fileName: string): [string, string];
54
+ /**
55
+ * 判断后缀是否符合图片格式
56
+ * @param extension 后缀
57
+ * @returns
58
+ */
59
+ declare function isImageExtension(extension: string): boolean;
60
+ /**
61
+ * 判断值是否为非空
62
+ * @param number 传入一个值
63
+ * @returns
64
+ */
65
+ declare function isNonEmpty(number: any): boolean;
66
+ /**
67
+ * 遍历一个对象,将值是数组的项,用逗号拼接起来
68
+ */
69
+ declare function parseJoin(params?: any): any;
70
+ /**
71
+ * 判断字符串是否是中文文本
72
+ * @param char 字符
73
+ * @returns
74
+ */
75
+ declare function isChinese(char?: string): boolean;
76
+ /**
77
+ * 往地址后面追加参数
78
+ */
79
+ declare function appendQueryParamsToUrl(url: string, params: any): string;
80
+
81
+ export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString };
@@ -0,0 +1,304 @@
1
+ import { __assign } from './_virtual/_tslib.js';
2
+ import mitt from './node_modules/mitt/dist/mitt.js';
3
+ import { isChineseValidate } from './validate.js';
4
+
5
+ /**
6
+ * 同步阻断
7
+ * @param time 秒
8
+ */
9
+ function delay(time) {
10
+ }
11
+ /**
12
+ * 发布订阅实例
13
+ */
14
+ var emitter = mitt();
15
+ /**
16
+ * 添加位数分割符
17
+ * @param n 需要分割的字符
18
+ * @param digit 多少位分割
19
+ * @param symbol 添加的符号
20
+ * @returns
21
+ */
22
+ function addThousedSeparator(n, digit, symbol) {
23
+ if (digit === void 0) { digit = 3; }
24
+ if (symbol === void 0) { symbol = ","; }
25
+ if (n != null) {
26
+ var _n = n.toString();
27
+ var pointBeforeNum = "";
28
+ var pointAfterNum = "";
29
+ if (_n.startsWith("-")) {
30
+ pointBeforeNum = "-";
31
+ _n = _n.slice(1);
32
+ }
33
+ var pointIndex = _n.indexOf(".");
34
+ if (pointIndex !== -1) {
35
+ n = _n.slice(0, pointIndex);
36
+ pointAfterNum = _n.slice(pointIndex);
37
+ }
38
+ else {
39
+ n = _n;
40
+ }
41
+ var res = "";
42
+ var s = n.toString();
43
+ var length_1 = s.length;
44
+ for (var i = length_1 - 1; i >= 0; i--) {
45
+ var j = length_1 - i;
46
+ if (j % digit === 0) {
47
+ if (i === 0) {
48
+ res = s[i] + res;
49
+ }
50
+ else {
51
+ res = symbol + s[i] + res;
52
+ }
53
+ }
54
+ else {
55
+ res = s[i] + res;
56
+ }
57
+ }
58
+ return pointBeforeNum + res + pointAfterNum;
59
+ }
60
+ else {
61
+ return n;
62
+ }
63
+ }
64
+ /**
65
+ * 获取地址栏参数
66
+ * @returns 地址栏参数对象
67
+ */
68
+ function parseQueryParams(url) {
69
+ if (!url) {
70
+ return {};
71
+ }
72
+ var queryString = url.split("?")[1];
73
+ var result = {};
74
+ try {
75
+ if (queryString) {
76
+ var searchList = queryString.split("&");
77
+ for (var i = 0; i < searchList.length; i++) {
78
+ var _a = searchList[i].split("="), key = _a[0], value = _a[1];
79
+ var val = decodeURIComponent(value);
80
+ if (val.startsWith("{")) {
81
+ try {
82
+ val = JSON.parse(val);
83
+ }
84
+ catch (err) {
85
+ console.log("解析失败", err);
86
+ }
87
+ }
88
+ else if (val === "true" || val === "false") {
89
+ val = val === "true";
90
+ }
91
+ result[key] = val;
92
+ }
93
+ }
94
+ }
95
+ catch (err) {
96
+ console.log(err);
97
+ }
98
+ // URLSearchParams 这个方法 会把 + 号给你去掉 坑爹啊 太鸡巴坑了
99
+ // if (typeof URLSearchParams === "function") {
100
+ // const params = new URLSearchParams(queryString);
101
+ // params.forEach((value, key) => {
102
+ // let val: any = decodeURIComponent(value);
103
+ // if (val.startsWith("{")) {
104
+ // try {
105
+ // val = JSON.parse(val);
106
+ // } catch (err) {
107
+ // console.log("解析失败", err);
108
+ // }
109
+ // } else if (val === "true" || val === "false") {
110
+ // val = val === "true";
111
+ // }
112
+ // result[key] = val;
113
+ // });
114
+ // } else {
115
+ // try {
116
+ // if (queryString) {
117
+ // const searchList = queryString.split("&");
118
+ // for (let i = 0; i < searchList.length; i++) {
119
+ // const [key, value] = searchList[i].split("=");
120
+ // result[key] = value;
121
+ // }
122
+ // }
123
+ // } catch (err) {
124
+ // console.log(err);
125
+ // }
126
+ // }
127
+ return result;
128
+ }
129
+ /**
130
+ * 将一些转义字符转换成原先的字符
131
+ * @param input 需要转换的内容
132
+ * @returns 转换过后的结果
133
+ */
134
+ function unescapeString(input) {
135
+ if (!input) {
136
+ return "";
137
+ }
138
+ var escapedChars = {
139
+ "&amp;": "&",
140
+ "&lt;": "<",
141
+ "&gt;": ">",
142
+ "&quot;": '"',
143
+ "&#039;": "'",
144
+ };
145
+ return input.replace(/&(amp|lt|gt|quot|#039);/g, function (match) {
146
+ return escapedChars[match] || match;
147
+ });
148
+ }
149
+ /**
150
+ * 将一些危险字符替换成后台能识别的字符
151
+ * @param input 需要转换的内容
152
+ * @returns 转换过后的结果
153
+ */
154
+ function dangerouslyXss(input) {
155
+ if (!input) {
156
+ return "";
157
+ }
158
+ var escapedChars = {
159
+ lt: "<",
160
+ gt: ">",
161
+ nbsp: " ",
162
+ amp: "&",
163
+ quot: '"',
164
+ };
165
+ return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, function (match, t) {
166
+ return escapedChars[t] || match;
167
+ });
168
+ }
169
+ /**
170
+ * 去除特殊字符。这个方法在附件预览的场景中有用到
171
+ */
172
+ function specialString(input) {
173
+ if (!input) {
174
+ return "";
175
+ }
176
+ return input.replace(/[~!@#$%^&*{}|]/g, "");
177
+ }
178
+ /**
179
+ * 将内容复制到粘贴板中
180
+ * @param text 需要复制的内容
181
+ */
182
+ function copyToClipboard(text, callback) {
183
+ var _a, _b;
184
+ try {
185
+ if ((navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) && window.isSecureContext) {
186
+ (_b = (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(text)) === null || _b === void 0 ? void 0 : _b.then(function () {
187
+ callback && callback(1);
188
+ });
189
+ }
190
+ else {
191
+ var textarea = document.createElement("textarea");
192
+ textarea.value = text;
193
+ document.body.appendChild(textarea);
194
+ textarea.select();
195
+ if (document.execCommand) {
196
+ callback && callback(1);
197
+ document.execCommand("copy");
198
+ }
199
+ else {
200
+ callback && callback(0);
201
+ }
202
+ document.body.removeChild(textarea);
203
+ }
204
+ }
205
+ catch (err) {
206
+ callback && callback(0);
207
+ }
208
+ }
209
+ /**
210
+ * 获取文件名中的后缀 返回文件名 + 后缀
211
+ * @param fileName 文件名
212
+ * @returns
213
+ */
214
+ function getFileExtension(fileName) {
215
+ if (!fileName) {
216
+ return ["", ""];
217
+ }
218
+ var lastPointIndex = fileName.lastIndexOf("."); // 从最后取点
219
+ if (lastPointIndex === -1) {
220
+ return [fileName, ""];
221
+ }
222
+ var filePreName = fileName.substring(0, lastPointIndex); // 前面的名字
223
+ var fileExtension = fileName.substring(lastPointIndex + 1).toLowerCase(); // 后面的文件后缀
224
+ return [filePreName, fileExtension];
225
+ }
226
+ /**
227
+ * 判断后缀是否符合图片格式
228
+ * @param extension 后缀
229
+ * @returns
230
+ */
231
+ function isImageExtension(extension) {
232
+ var imageExtensions = [
233
+ "jpg",
234
+ "png",
235
+ "jpeg",
236
+ "gif",
237
+ "tif",
238
+ "tga",
239
+ "bmp",
240
+ "dds",
241
+ "svg",
242
+ "webp",
243
+ ];
244
+ return imageExtensions.includes(extension.toLowerCase());
245
+ }
246
+ /**
247
+ * 判断值是否为非空
248
+ * @param number 传入一个值
249
+ * @returns
250
+ */
251
+ function isNonEmpty(number) {
252
+ return number !== null && number !== undefined;
253
+ }
254
+ /**
255
+ * 遍历一个对象,将值是数组的项,用逗号拼接起来
256
+ */
257
+ function parseJoin(params) {
258
+ if (params) {
259
+ var newParams = __assign({}, params);
260
+ for (var key in newParams) {
261
+ if (Array.isArray(newParams[key])) {
262
+ newParams[key] = newParams[key].join(",");
263
+ }
264
+ }
265
+ return newParams;
266
+ }
267
+ return params;
268
+ }
269
+ /**
270
+ * 判断字符串是否是中文文本
271
+ * @param char 字符
272
+ * @returns
273
+ */
274
+ function isChinese(char) {
275
+ if (!char) {
276
+ return false;
277
+ }
278
+ return isChineseValidate.regex.test(char);
279
+ }
280
+ /**
281
+ * 往地址后面追加参数
282
+ */
283
+ function appendQueryParamsToUrl(url, params) {
284
+ // 检查 URL 中是否已经有查询字符串
285
+ var hasQuery = url.indexOf("?") !== -1;
286
+ var newUrl = url;
287
+ // 遍历参数并追加到 URL
288
+ Object.keys(params).forEach(function (key, index) {
289
+ // 对于第一个参数,如果 URL 已经有查询字符串,则追加 '&'
290
+ // 如果没有,则追加 '?'
291
+ var prefix = hasQuery || index > 0 ? "&" : "?";
292
+ newUrl +=
293
+ prefix + encodeURIComponent(key) + "=" + encodeURIComponent(params[key]);
294
+ });
295
+ return newUrl;
296
+ }
297
+ /**
298
+ * 获取数据类型
299
+ */
300
+ function getDataType(data) {
301
+ return Object.prototype.toString.call(data);
302
+ }
303
+
304
+ export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getDataType, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 子应用 通知 父应用
3
+ */
4
+ declare const EMITTER_CCP_KEY = "emitter-ccp-key";
5
+ /**
6
+ * 父应用 通知 子应用订阅
7
+ */
8
+ declare const EMITTER_PCC_KEY = "emitter-pcc-key";
9
+ declare const EMITTER_TYPE: {
10
+ delTab: string;
11
+ addTab: string;
12
+ delTabs: string;
13
+ routes: string;
14
+ treeSearchWhitePath: string;
15
+ treeSearchSet: string;
16
+ };
17
+ declare const TOKEN_KEY: any;
18
+ declare const BASIC_KEY: any;
19
+
20
+ export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY };