zmdms-utils 0.0.75 → 0.0.76
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/es/_virtual/_commonjsHelpers.js +3 -0
- package/dist/es/_virtual/_tslib.js +87 -0
- package/dist/es/_virtual/decimal.js +7 -0
- package/dist/es/_virtual/parseTimeTest.js +3 -0
- package/dist/es/_virtual/test.js +3 -0
- package/dist/es/auth.d.ts +9 -0
- package/dist/es/auth.js +49 -0
- package/dist/es/baseUrl.d.ts +23 -0
- package/dist/es/baseUrl.js +50 -0
- package/dist/es/canvas.d.ts +6 -0
- package/dist/es/canvas.js +14 -0
- package/dist/es/common.d.ts +81 -0
- package/dist/es/common.js +304 -0
- package/dist/es/constants.d.ts +20 -0
- package/dist/es/constants.js +33 -0
- package/dist/es/crypto.d.ts +51 -0
- package/dist/es/crypto.js +97 -0
- package/dist/es/file.d.ts +127 -0
- package/dist/es/file.js +373 -0
- package/dist/es/htmlToPdf.d.ts +44 -0
- package/dist/es/htmlToPdf.js +84 -0
- package/dist/es/locales/i18n.d.ts +15 -0
- package/dist/es/locales/t-in-non-react.d.ts +17 -0
- package/dist/es/locales/t-options.d.ts +7 -0
- package/dist/es/locales/use-translation.d.ts +42 -0
- package/dist/es/mainApp.d.ts +36 -0
- package/dist/es/mainApp.js +44 -0
- package/dist/es/math.d.ts +29 -0
- package/dist/es/math.js +147 -0
- package/dist/es/microAppCreator.d.ts +46 -0
- package/dist/es/microAppCreator.js +89 -0
- package/dist/es/node_modules/decimal.js/decimal.js +4896 -0
- package/dist/es/node_modules/decimal.js/decimal2.js +4930 -0
- package/dist/es/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js +5 -0
- package/dist/es/node_modules/i18next/dist/esm/i18next.js +2242 -0
- package/dist/es/node_modules/js-base64/base64.js +273 -0
- package/dist/es/node_modules/jwt-decode/build/jwt-decode.esm.js +3 -0
- package/dist/es/node_modules/mitt/dist/mitt.js +3 -0
- package/dist/es/node_modules/pinyin-pro/dist/index.js +12627 -0
- package/dist/es/node_modules/react-i18next/dist/es/Trans.js +47 -0
- package/dist/es/node_modules/react-i18next/dist/es/TransWithoutContext.js +312 -0
- package/dist/es/node_modules/react-i18next/dist/es/context.js +18 -0
- package/dist/es/node_modules/react-i18next/dist/es/defaults.js +21 -0
- package/dist/es/node_modules/react-i18next/dist/es/i18nInstance.js +7 -0
- package/dist/es/node_modules/react-i18next/dist/es/initReactI18next.js +12 -0
- package/dist/es/node_modules/react-i18next/dist/es/unescape.js +27 -0
- package/dist/es/node_modules/react-i18next/dist/es/useTranslation.js +112 -0
- package/dist/es/node_modules/react-i18next/dist/es/utils.js +63 -0
- package/dist/es/node_modules/void-elements/index.js +23 -0
- package/dist/es/parseTime.d.ts +29 -0
- package/dist/es/parseTime.js +189 -0
- package/dist/es/parseTimeTest.js +2 -0
- package/dist/es/passwordValidate.d.ts +9 -0
- package/dist/es/passwordValidate.js +169 -0
- package/dist/es/pdf.d.ts +49 -0
- package/dist/es/pdf.js +176 -0
- package/dist/es/pinyin.js +1 -0
- package/dist/es/print.d.ts +23 -0
- package/dist/es/print.js +43 -0
- package/dist/es/qiankunUtils.d.ts +13 -0
- package/dist/es/qiankunUtils.js +32 -0
- package/dist/es/request.d.ts +87 -0
- package/dist/es/request.js +308 -0
- package/dist/es/src/locales/i18n.js +16 -0
- package/dist/es/src/locales/t-in-non-react.js +54 -0
- package/dist/es/src/locales/t-options.js +20 -0
- package/dist/es/src/locales/use-translation.js +60 -0
- package/dist/es/src/parseTimeTest.js +288 -0
- package/dist/es/src/test.js +245 -0
- package/dist/es/test.js +2 -0
- package/dist/es/validate.d.ts +26 -0
- package/dist/es/validate.js +47 -0
- package/dist/es/water.d.ts +53 -0
- package/dist/es/water.js +88 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/package.json +1 -1
- package/src/math.ts +1 -1
package/dist/es/water.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { parseToken } from './auth.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 创建水印
|
|
6
|
+
*/
|
|
7
|
+
function createWater(config) {
|
|
8
|
+
var _a = mergeWaterConfig(config), width = _a.width, height = _a.height, rotate = _a.rotate, content = _a.content, font = _a.font, lineSpacing = _a.lineSpacing;
|
|
9
|
+
// 创建canvas元素
|
|
10
|
+
var canvas = document.createElement("canvas");
|
|
11
|
+
canvas.width = width * 2;
|
|
12
|
+
canvas.height = height * 2;
|
|
13
|
+
var ctx = canvas.getContext("2d");
|
|
14
|
+
if (ctx) {
|
|
15
|
+
// 设置字体样式
|
|
16
|
+
ctx.font = "".concat(font.fontStyle, " ").concat(font.fontWeight, " ").concat(font.fontSize, "px ").concat(font.fontFamily);
|
|
17
|
+
ctx.fillStyle = font.color;
|
|
18
|
+
ctx.textAlign = font.textAlign;
|
|
19
|
+
// 绘制水印文本的函数
|
|
20
|
+
var drawText = function (textLines, x, y) {
|
|
21
|
+
ctx.save();
|
|
22
|
+
ctx.translate(x, y);
|
|
23
|
+
ctx.rotate((Math.PI / 180) * rotate);
|
|
24
|
+
if (Array.isArray(textLines)) {
|
|
25
|
+
// 多行文本
|
|
26
|
+
textLines.forEach(function (line, index) {
|
|
27
|
+
ctx.fillText(line, 0, index * (font.fontSize + lineSpacing));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// 单行文本
|
|
32
|
+
ctx.fillText(textLines, 0, 0);
|
|
33
|
+
}
|
|
34
|
+
ctx.restore();
|
|
35
|
+
};
|
|
36
|
+
// 绘制两个重叠的水印文本
|
|
37
|
+
drawText(content, width / 2, height / 2); // 中心对齐第一个文本
|
|
38
|
+
drawText(content, (width * 3) / 2, (height * 3) / 2); // 中心对齐第二个文本
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
imgBase64: canvas.toDataURL("image/png"),
|
|
42
|
+
canvasWidth: canvas.width,
|
|
43
|
+
canvasHeight: canvas.height,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 默认配置
|
|
48
|
+
*/
|
|
49
|
+
function mergeWaterConfig(waterConfig) {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f;
|
|
51
|
+
var defaultContent = getDefaultContent();
|
|
52
|
+
return {
|
|
53
|
+
width: (waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.width) || 200,
|
|
54
|
+
height: (waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.height) || 200,
|
|
55
|
+
rotate: (waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.rotate) || -20,
|
|
56
|
+
zIndex: (waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.zIndex) || 10,
|
|
57
|
+
content: (waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.content) || defaultContent,
|
|
58
|
+
lineSpacing: 4,
|
|
59
|
+
font: {
|
|
60
|
+
color: ((_a = waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.font) === null || _a === void 0 ? void 0 : _a.color) || "rgba(0, 0, 0, 0.2)",
|
|
61
|
+
fontSize: ((_b = waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.font) === null || _b === void 0 ? void 0 : _b.fontSize) || 14,
|
|
62
|
+
fontWeight: ((_c = waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.font) === null || _c === void 0 ? void 0 : _c.fontWeight) || "normal",
|
|
63
|
+
fontStyle: ((_d = waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.font) === null || _d === void 0 ? void 0 : _d.fontStyle) || "normal",
|
|
64
|
+
fontFamily: ((_e = waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.font) === null || _e === void 0 ? void 0 : _e.fontFamily) || "微软雅黑",
|
|
65
|
+
textAlign: ((_f = waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.font) === null || _f === void 0 ? void 0 : _f.textAlign) || "center",
|
|
66
|
+
},
|
|
67
|
+
image: waterConfig === null || waterConfig === void 0 ? void 0 : waterConfig.image,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function getDefaultContent() {
|
|
71
|
+
var jwtInfo = parseToken();
|
|
72
|
+
if (typeof jwtInfo === "object" && jwtInfo != null) {
|
|
73
|
+
var username = jwtInfo.real_name || jwtInfo.realName || "";
|
|
74
|
+
var phone = jwtInfo.phone || "";
|
|
75
|
+
var phoneLen = phone.length;
|
|
76
|
+
if (phoneLen <= 4) {
|
|
77
|
+
phone = phone;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
phone = phone.slice(phoneLen - 4);
|
|
81
|
+
}
|
|
82
|
+
var time = dayjs().format("YYMMDD");
|
|
83
|
+
return ["".concat(username, " ").concat(phone), time];
|
|
84
|
+
}
|
|
85
|
+
return "浙江交通集团";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { createWater, getDefaultContent, mergeWaterConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { initMicroApp } from './es/microAppCreator.js';
|
|
2
|
+
export { getMicroUrl, isQiankun } from './es/qiankunUtils.js';
|
|
3
|
+
export { initGlobalError, initMainApp } from './es/mainApp.js';
|
|
4
|
+
export { getToken, parseToken, removeToken, setToken } from './es/auth.js';
|
|
5
|
+
export { AxiosRequest, IOptions, IOtherOptions } from './es/request.js';
|
|
6
|
+
export { getBaseUrl } from './es/baseUrl.js';
|
|
7
|
+
export { Crypto, md5 } from './es/crypto.js';
|
|
8
|
+
export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
|
|
9
|
+
export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
|
|
10
|
+
export { validatePassword } from './es/passwordValidate.js';
|
|
11
|
+
export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
|
|
12
|
+
export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile } from './es/file.js';
|
|
13
|
+
export { calculateAge, parseTime } from './es/parseTime.js';
|
|
14
|
+
export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY } from './es/constants.js';
|
|
15
|
+
export { convert, html, match, pinyin } from 'pinyin-pro';
|
|
16
|
+
export { domToCanvas } from './es/canvas.js';
|
|
17
|
+
export { imgToPdf } from './es/pdf.js';
|
|
18
|
+
export { htmlToPdf } from './es/htmlToPdf.js';
|
|
19
|
+
export { htmlPrint, imgPrint, pdfPrint, windowPrint } from './es/print.js';
|
|
20
|
+
export { createWater, getDefaultContent, mergeWaterConfig } from './es/water.js';
|
|
21
|
+
export { initLocale } from './es/locales/i18n.js';
|
|
22
|
+
export { useTranslation } from './es/locales/use-translation.js';
|
|
23
|
+
export { safeT } from './es/locales/t-in-non-react.js';
|
|
24
|
+
export { Base64 } from 'js-base64';
|
|
25
|
+
export { default as i18n } from 'i18next';
|
|
26
|
+
export { Trans } from 'react-i18next';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { initMicroApp } from './es/microAppCreator.js';
|
|
2
|
+
export { getMicroUrl, isQiankun } from './es/qiankunUtils.js';
|
|
3
|
+
export { initGlobalError, initMainApp } from './es/mainApp.js';
|
|
4
|
+
export { getToken, parseToken, removeToken, setToken } from './es/auth.js';
|
|
5
|
+
export { AxiosRequest } from './es/request.js';
|
|
6
|
+
export { getBaseUrl } from './es/baseUrl.js';
|
|
7
|
+
export { Crypto, md5 } from './es/crypto.js';
|
|
8
|
+
export { addThousedSeparator, appendQueryParamsToUrl, copyToClipboard, dangerouslyXss, delay, emitter, getFileExtension, isChinese, isImageExtension, isNonEmpty, parseJoin, parseQueryParams, specialString, unescapeString } from './es/common.js';
|
|
9
|
+
export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
|
|
10
|
+
export { validatePassword } from './es/passwordValidate.js';
|
|
11
|
+
export { emailValidate, idCardValidate, isChineseValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
|
|
12
|
+
export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile } from './es/file.js';
|
|
13
|
+
export { calculateAge, parseTime } from './es/parseTime.js';
|
|
14
|
+
export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY } from './es/constants.js';
|
|
15
|
+
export { convert, html, match, pinyin } from './es/node_modules/pinyin-pro/dist/index.js';
|
|
16
|
+
export { domToCanvas } from './es/canvas.js';
|
|
17
|
+
export { imgToPdf } from './es/pdf.js';
|
|
18
|
+
export { htmlToPdf } from './es/htmlToPdf.js';
|
|
19
|
+
export { htmlPrint, imgPrint, pdfPrint, windowPrint } from './es/print.js';
|
|
20
|
+
export { createWater, getDefaultContent, mergeWaterConfig } from './es/water.js';
|
|
21
|
+
export { initLocale } from './es/src/locales/i18n.js';
|
|
22
|
+
export { useTranslation } from './es/src/locales/use-translation.js';
|
|
23
|
+
export { safeT } from './es/src/locales/t-in-non-react.js';
|
|
24
|
+
export { Base64 } from './es/node_modules/js-base64/base64.js';
|
|
25
|
+
export { default as i18n } from './es/node_modules/i18next/dist/esm/i18next.js';
|
|
26
|
+
export { Trans } from './es/node_modules/react-i18next/dist/es/Trans.js';
|
package/package.json
CHANGED
package/src/math.ts
CHANGED
|
@@ -113,7 +113,7 @@ export function exactRound(num: numType, ratio: number) {
|
|
|
113
113
|
return 0;
|
|
114
114
|
// return (0).toFixed(ratio);
|
|
115
115
|
}
|
|
116
|
-
let value = new Decimal(num).toFixed(ratio);
|
|
116
|
+
let value: numType = new Decimal(num).toFixed(ratio);
|
|
117
117
|
// 设置exactRound去掉小数位后面的0
|
|
118
118
|
if ((window as any).__EXACT_ROUND_TYPE__ === "TRIM_ZEROS") {
|
|
119
119
|
value = Number(value);
|