zmdms-utils 0.0.18 → 0.0.20

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.
@@ -3,7 +3,7 @@ function getBaseUrl(processObj) {
3
3
  var ENV = processObj.REACT_APP_ENV; // 获取当前环境变量
4
4
  // api各个环境地址
5
5
  var apiBaseUrlObj = {
6
- dev: processObj.REACT_APP_API_DEV || "http://192.168.0.83:8000",
6
+ dev: processObj.REACT_APP_API_DEV || "http://192.168.0.134:8000",
7
7
  test: processObj.REACT_APP_API_TEST || window.location.origin,
8
8
  stage: processObj.REACT_APP_API_STAGE || window.location.origin,
9
9
  product: processObj.REACT_APP_API_PRODUCT || window.location.origin,
package/dist/es/common.js CHANGED
@@ -118,14 +118,14 @@ function dangerouslyXss(input) {
118
118
  return "";
119
119
  }
120
120
  var escapedChars = {
121
- lt: "",
122
- gt: "",
121
+ lt: "<",
122
+ gt: ">",
123
123
  nbsp: " ",
124
124
  amp: "&",
125
125
  quot: '"',
126
126
  };
127
- return input.replace(/&(amp|lt|gt|quot|nbsp);/g, function (match) {
128
- return escapedChars[match] || match;
127
+ return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, function (match, t) {
128
+ return escapedChars[t] || match;
129
129
  });
130
130
  }
131
131
  /**
@@ -179,7 +179,7 @@ function getFileExtension(fileName) {
179
179
  }
180
180
  var lastPointIndex = fileName.lastIndexOf("."); // 从最后取点
181
181
  var filePreName = fileName.substring(0, lastPointIndex); // 前面的名字
182
- var fileExtension = fileName.substring(lastPointIndex + 1); // 后面的文件后缀
182
+ var fileExtension = fileName.substring(lastPointIndex + 1).toLowerCase(); // 后面的文件后缀
183
183
  return [filePreName, fileExtension];
184
184
  }
185
185
  /**
@@ -0,0 +1,18 @@
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
+
18
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE };
@@ -0,0 +1,23 @@
1
+ // 薪酬中心-app name
2
+ var SALARY_CENTER_APPNAME = "cicohr-salary";
3
+ // 人事中心-app name
4
+ var PERSONNEL_CENTER_APPNAME = "cicohr-personnel";
5
+ // 发布订阅的常量 parent call children
6
+ /**
7
+ * 子应用 通知 父应用
8
+ */
9
+ var EMITTER_CCP_KEY = "emitter-ccp-key";
10
+ /**
11
+ * 父应用 通知 子应用订阅
12
+ */
13
+ var EMITTER_PCC_KEY = "emitter-pcc-key";
14
+ var EMITTER_TYPE = {
15
+ delTab: "delTab",
16
+ addTab: "addTab",
17
+ delTabs: "delTabs",
18
+ routes: "routes",
19
+ treeSearchWhitePath: "treeSearchWhitePath",
20
+ treeSearchSet: "treeSearchSet", // 父应用传递搜索树的值
21
+ };
22
+
23
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME };
package/dist/es/test.js CHANGED
@@ -1,2 +1,158 @@
1
- import './src/test.js';
2
- export { __exports as default } from './_virtual/test.js';
1
+ function unescapeString(input) {
2
+ if (!input) {
3
+ return "";
4
+ }
5
+
6
+ const escapedChars = {
7
+ "&amp;": "&",
8
+ "&lt;": "<",
9
+ "&gt;": ">",
10
+ "&quot;": '"',
11
+ "&#039;": "'",
12
+ };
13
+
14
+ return input.replace(/&(amp|lt|gt|quot|#039);/g, (match) => {
15
+ return escapedChars[match] || match;
16
+ });
17
+ }
18
+
19
+ function dangerouslySetXss(input) {
20
+ if (!input) {
21
+ return "";
22
+ }
23
+ const escapedChars = {
24
+ "&lt;": "<",
25
+ "&gt;": ">",
26
+ "&nbsp;": " ",
27
+ "&amp;": "&",
28
+ "&quot;": '"',
29
+ };
30
+
31
+ return input.replace(/&(amp|lt|gt|quot|nbsp);/g, (match) => {
32
+ return escapedChars[match] || match;
33
+ });
34
+ }
35
+
36
+ function dangerouslySetXss1(input) {
37
+ if (!input) {
38
+ return "";
39
+ }
40
+ const escapedChars = {
41
+ lt: "<",
42
+ gt: ">",
43
+ nbsp: " ",
44
+ amp: "&",
45
+ quot: '"',
46
+ };
47
+
48
+ return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
49
+ return escapedChars[t] || match;
50
+ });
51
+ }
52
+
53
+ console.log(unescapeString("&amp;&amp;&amp;啊你"));
54
+
55
+ console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
56
+
57
+ console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
58
+ console.log(unescapeString("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
59
+ console.log(dangerouslySetXss("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
60
+ console.log(dangerouslySetXss1("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
61
+
62
+ // functions and constants
63
+ // console.log("functions and constants");
64
+ // print(math.round(math.e, 3)); // 2.718
65
+ // print(math.atan2(3, -3) / math.pi); // 0.75
66
+ // print(math.log(10000, 10)); // 4
67
+ // print(math.sqrt(-4)); // 2i
68
+ // print(
69
+ // math.pow(
70
+ // [
71
+ // [-1, 2],
72
+ // [3, 1],
73
+ // ],
74
+ // 2
75
+ // )
76
+ // ); // [[7, 0], [0, 7]]
77
+ // print(math.derivative("x^2 + x", "x")); // 2 * x + 1
78
+ // console.log();
79
+
80
+ // // expressions
81
+ // console.log("expressions");
82
+ // print(math.evaluate("1.2 * (2 + 4.5)")); // 7.8
83
+ // print(math.evaluate("12.7 cm to inch")); // 5 inch
84
+ // print(math.evaluate("sin(45 deg) ^ 2")); // 0.5
85
+ // print(math.evaluate("9 / 3 + 2i")); // 3 + 2i
86
+ // print(math.evaluate("det([-1, 2; 3, 1])")); // -7
87
+ // print(math.evaluate("NaN + '0.2'")); // -7
88
+ // console.log();
89
+
90
+ // // chained operations
91
+ // console.log("chained operations");
92
+ // const a = math.chain(3).add(4).multiply(2).done();
93
+ // print(a); // 14
94
+ // console.log();
95
+
96
+ // // mixed use of different data types in functions
97
+ // console.log("mixed use of data types");
98
+ // print(math.add(4, [5, 6])); // number + Array, [9, 10]
99
+ // print(math.multiply(math.unit("5 mm"), 3)); // Unit * number, 15 mm
100
+ // print(math.subtract([2, 3, 4], 5)); // Array - number, [-3, -2, -1]
101
+ // print(math.add(math.matrix([2, 3]), [4, 5])); // Matrix + Array, [6, 8]
102
+ // console.log();
103
+
104
+ // /**
105
+ // * Helper function to output a value in the console. Value will be formatted.
106
+ // * @param {*} value
107
+ // */
108
+ // function print(value) {
109
+ // const precision = 14;
110
+ // console.log(math.format(value, precision));
111
+ // }
112
+
113
+ // const math = require("mathjs");
114
+ // function print(value) {
115
+ // const precision = 14;
116
+ // console.log(math.format(value, precision));
117
+ // }
118
+
119
+ // console.log(performance.now());
120
+ // console.log(math.add(0.1, 0.2));
121
+ // console.log(performance.now());
122
+ // console.log(performance.now());
123
+ // console.log(0.1 + 0.2);
124
+ // console.log(performance.now());
125
+ // const BigNumber = require("bignumber.js");
126
+ // console.log(performance.now());
127
+ // const num1 = new BigNumber(0.1);
128
+ // const num2 = new BigNumber(0.2);
129
+
130
+ // const result = num1.plus(num2);
131
+
132
+ // console.log(result.toString());
133
+
134
+ // console.log(performance.now());
135
+
136
+ // const Decimal = require("decimal.js");
137
+
138
+ // const num1 = new Decimal("0.1");
139
+
140
+ // console.log(num1.add(0.21).toNumber(), typeof num1.add(0.21).toNumber());
141
+
142
+ // console.log(num1.sub(0.21).toNumber(), typeof num1.sub(0.21).toNumber());
143
+
144
+ // console.log(num1.mul(0.21).toNumber(), typeof num1.mul(0.21).toNumber());
145
+ // Decimal.set({ precision: 5 });
146
+ // console.log(
147
+ // new Decimal(1).div(1.1).toNumber(),
148
+ // typeof new Decimal(1).div(1.1).toNumber()
149
+ // );
150
+ // console.log(
151
+ // new Decimal(1).dividedBy(1.1).toNumber(),
152
+ // typeof new Decimal(1).dividedBy(1.1).toNumber()
153
+ // );
154
+
155
+ // console.log(
156
+ // Number(new Decimal(1.1).toFixed(2)),
157
+ // typeof Number(new Decimal(1.1).toFixed(2)).toFixed(2)
158
+ // );
package/dist/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js
10
10
  export { validatePassword } from './es/passwordValidate.js';
11
11
  export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
12
12
  export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile } from './es/file.js';
13
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from './es/constants.js';
package/dist/index.js CHANGED
@@ -10,3 +10,4 @@ export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js
10
10
  export { validatePassword } from './es/passwordValidate.js';
11
11
  export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
12
12
  export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile } from './es/file.js';
13
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from './es/constants.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/baseUrl.ts CHANGED
@@ -4,7 +4,7 @@ export function getBaseUrl(processObj: any) {
4
4
 
5
5
  // api各个环境地址
6
6
  const apiBaseUrlObj: any = {
7
- dev: processObj.REACT_APP_API_DEV || "http://192.168.0.83:8000",
7
+ dev: processObj.REACT_APP_API_DEV || "http://192.168.0.134:8000",
8
8
  test: processObj.REACT_APP_API_TEST || window.location.origin,
9
9
  stage: processObj.REACT_APP_API_STAGE || window.location.origin,
10
10
  product: processObj.REACT_APP_API_PRODUCT || window.location.origin,
package/src/common.ts CHANGED
@@ -125,15 +125,15 @@ export function dangerouslyXss(input: string): string {
125
125
  return "";
126
126
  }
127
127
  const escapedChars: { [key: string]: string } = {
128
- lt: "",
129
- gt: "",
128
+ lt: "<",
129
+ gt: ">",
130
130
  nbsp: " ",
131
131
  amp: "&",
132
132
  quot: '"',
133
133
  };
134
134
 
135
- return input.replace(/&(amp|lt|gt|quot|nbsp);/g, (match) => {
136
- return escapedChars[match] || match;
135
+ return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
136
+ return escapedChars[t] || match;
137
137
  });
138
138
  }
139
139
 
@@ -186,7 +186,7 @@ export function getFileExtension(fileName: string): [string, string] {
186
186
  }
187
187
  const lastPointIndex = fileName.lastIndexOf("."); // 从最后取点
188
188
  const filePreName = fileName.substring(0, lastPointIndex); // 前面的名字
189
- const fileExtension = fileName.substring(lastPointIndex + 1); // 后面的文件后缀
189
+ const fileExtension = fileName.substring(lastPointIndex + 1).toLowerCase(); // 后面的文件后缀
190
190
  return [filePreName, fileExtension];
191
191
  }
192
192
 
@@ -0,0 +1,25 @@
1
+ // 薪酬中心-app name
2
+ export const SALARY_CENTER_APPNAME = "cicohr-salary";
3
+
4
+ // 人事中心-app name
5
+ export const PERSONNEL_CENTER_APPNAME = "cicohr-personnel";
6
+
7
+ // 发布订阅的常量 parent call children
8
+ /**
9
+ * 子应用 通知 父应用
10
+ */
11
+ export const EMITTER_CCP_KEY = "emitter-ccp-key";
12
+
13
+ /**
14
+ * 父应用 通知 子应用订阅
15
+ */
16
+ export const EMITTER_PCC_KEY = "emitter-pcc-key";
17
+
18
+ export const EMITTER_TYPE = {
19
+ delTab: "delTab", // 删除单个页签
20
+ addTab: "addTab", // 增加单个页签
21
+ delTabs: "delTabs", // 删除多个页签
22
+ routes: "routes", // 传递路由信息
23
+ treeSearchWhitePath: "treeSearchWhitePath", // 子应用传递搜索树的路由白名单
24
+ treeSearchSet: "treeSearchSet", // 父应用传递搜索树的值
25
+ };
package/src/index.ts CHANGED
@@ -39,3 +39,8 @@ export {
39
39
  createUploadFileLink,
40
40
  createDeleteFileLink,
41
41
  } from "./file";
42
+
43
+ /**
44
+ * 常量相关
45
+ */
46
+ export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from "./constants";
package/src/test.js CHANGED
@@ -21,8 +21,8 @@ function dangerouslySetXss(input) {
21
21
  return "";
22
22
  }
23
23
  const escapedChars = {
24
- "&lt;": "",
25
- "&gt;": "",
24
+ "&lt;": "<",
25
+ "&gt;": ">",
26
26
  "&nbsp;": " ",
27
27
  "&amp;": "&",
28
28
  "&quot;": '"',
@@ -33,25 +33,31 @@ function dangerouslySetXss(input) {
33
33
  });
34
34
  }
35
35
 
36
- function dangerouslySetXss1(str) {
37
- if (!str) {
38
- return str;
39
- }
40
- try {
41
- const arrEntities = { lt: "", gt: "", nbsp: " ", amp: "&", quot: '"' };
42
- return str?.replace?.(/&(lt|gt|nbsp|amp|quot);/gi, function (all, t) {
43
- return arrEntities[t];
44
- });
45
- } catch (err) {
46
- return str;
36
+ function dangerouslySetXss1(input) {
37
+ if (!input) {
38
+ return "";
47
39
  }
40
+ const escapedChars = {
41
+ lt: "<",
42
+ gt: ">",
43
+ nbsp: " ",
44
+ amp: "&",
45
+ quot: '"',
46
+ };
47
+
48
+ return input.replace(/&(amp|lt|gt|quot|nbsp);/gi, (match, t) => {
49
+ return escapedChars[t] || match;
50
+ });
48
51
  }
49
52
 
50
- // console.log(unescapeString("&amp;&amp;&amp;啊你"));
53
+ console.log(unescapeString("&amp;&amp;&amp;啊你"));
51
54
 
52
- // console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
55
+ console.log(dangerouslySetXss("&amp;&amp;&amp;啊你"));
53
56
 
54
- // console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
57
+ console.log(dangerouslySetXss1("&amp;&amp;&amp;啊你"));
58
+ console.log(unescapeString("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
59
+ console.log(dangerouslySetXss("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
60
+ console.log(dangerouslySetXss1("1、aa&gt;80%\n2、&gt;&lt;\n3、ss&lt;80%"));
55
61
 
56
62
  // functions and constants
57
63
  // console.log("functions and constants");
@@ -127,26 +133,26 @@ function dangerouslySetXss1(str) {
127
133
 
128
134
  // console.log(performance.now());
129
135
 
130
- const Decimal = require("decimal.js");
136
+ // const Decimal = require("decimal.js");
131
137
 
132
- const num1 = new Decimal("0.1");
138
+ // const num1 = new Decimal("0.1");
133
139
 
134
- console.log(num1.add(0.21).toNumber(), typeof num1.add(0.21).toNumber());
140
+ // console.log(num1.add(0.21).toNumber(), typeof num1.add(0.21).toNumber());
135
141
 
136
- console.log(num1.sub(0.21).toNumber(), typeof num1.sub(0.21).toNumber());
142
+ // console.log(num1.sub(0.21).toNumber(), typeof num1.sub(0.21).toNumber());
137
143
 
138
- console.log(num1.mul(0.21).toNumber(), typeof num1.mul(0.21).toNumber());
139
- Decimal.set({ precision: 5 });
140
- console.log(
141
- new Decimal(1).div(1.1).toNumber(),
142
- typeof new Decimal(1).div(1.1).toNumber()
143
- );
144
- console.log(
145
- new Decimal(1).dividedBy(1.1).toNumber(),
146
- typeof new Decimal(1).dividedBy(1.1).toNumber()
147
- );
144
+ // console.log(num1.mul(0.21).toNumber(), typeof num1.mul(0.21).toNumber());
145
+ // Decimal.set({ precision: 5 });
146
+ // console.log(
147
+ // new Decimal(1).div(1.1).toNumber(),
148
+ // typeof new Decimal(1).div(1.1).toNumber()
149
+ // );
150
+ // console.log(
151
+ // new Decimal(1).dividedBy(1.1).toNumber(),
152
+ // typeof new Decimal(1).dividedBy(1.1).toNumber()
153
+ // );
148
154
 
149
- console.log(
150
- Number(new Decimal(1.1).toFixed(2)),
151
- typeof Number(new Decimal(1.1).toFixed(2)).toFixed(2)
152
- );
155
+ // console.log(
156
+ // Number(new Decimal(1.1).toFixed(2)),
157
+ // typeof Number(new Decimal(1.1).toFixed(2)).toFixed(2)
158
+ // );
@@ -1,3 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
-
3
- export { commonjsGlobal };
@@ -1,7 +0,0 @@
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 };
@@ -1,3 +0,0 @@
1
- var test = {};
2
-
3
- export { test as __exports };