zmdms-utils 0.0.73 → 0.0.75

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 (67) hide show
  1. package/package.json +4 -2
  2. package/publish.py +12 -0
  3. package/src/index.ts +3 -0
  4. package/src/locales/i18n.ts +18 -0
  5. package/src/locales/index.ts +8 -0
  6. package/src/locales/t-in-non-react.ts +65 -0
  7. package/src/locales/t-options.ts +24 -0
  8. package/src/locales/use-translation.ts +76 -0
  9. package/src/locales//345/244/232/350/257/255/350/250/200.md +1 -0
  10. package/src/math.ts +6 -1
  11. package/src/microAppCreator.ts +47 -8
  12. package/dist/es/_virtual/_commonjsHelpers.js +0 -3
  13. package/dist/es/_virtual/_tslib.js +0 -87
  14. package/dist/es/_virtual/decimal.js +0 -7
  15. package/dist/es/_virtual/parseTimeTest.js +0 -3
  16. package/dist/es/_virtual/test.js +0 -3
  17. package/dist/es/auth.d.ts +0 -9
  18. package/dist/es/auth.js +0 -49
  19. package/dist/es/baseUrl.d.ts +0 -23
  20. package/dist/es/baseUrl.js +0 -50
  21. package/dist/es/canvas.d.ts +0 -6
  22. package/dist/es/canvas.js +0 -14
  23. package/dist/es/common.d.ts +0 -81
  24. package/dist/es/common.js +0 -304
  25. package/dist/es/constants.d.ts +0 -20
  26. package/dist/es/constants.js +0 -33
  27. package/dist/es/crypto.d.ts +0 -51
  28. package/dist/es/crypto.js +0 -97
  29. package/dist/es/file.d.ts +0 -127
  30. package/dist/es/file.js +0 -373
  31. package/dist/es/htmlToPdf.d.ts +0 -44
  32. package/dist/es/htmlToPdf.js +0 -84
  33. package/dist/es/mainApp.d.ts +0 -36
  34. package/dist/es/mainApp.js +0 -44
  35. package/dist/es/math.d.ts +0 -29
  36. package/dist/es/math.js +0 -142
  37. package/dist/es/microAppCreator.d.ts +0 -23
  38. package/dist/es/microAppCreator.js +0 -67
  39. package/dist/es/node_modules/decimal.js/decimal.js +0 -4896
  40. package/dist/es/node_modules/decimal.js/decimal2.js +0 -4930
  41. package/dist/es/node_modules/js-base64/base64.js +0 -273
  42. package/dist/es/node_modules/jwt-decode/build/jwt-decode.esm.js +0 -3
  43. package/dist/es/node_modules/mitt/dist/mitt.js +0 -3
  44. package/dist/es/node_modules/pinyin-pro/dist/index.js +0 -12627
  45. package/dist/es/parseTime.d.ts +0 -29
  46. package/dist/es/parseTime.js +0 -189
  47. package/dist/es/parseTimeTest.js +0 -2
  48. package/dist/es/passwordValidate.d.ts +0 -9
  49. package/dist/es/passwordValidate.js +0 -169
  50. package/dist/es/pdf.d.ts +0 -49
  51. package/dist/es/pdf.js +0 -176
  52. package/dist/es/pinyin.js +0 -1
  53. package/dist/es/print.d.ts +0 -23
  54. package/dist/es/print.js +0 -43
  55. package/dist/es/qiankunUtils.d.ts +0 -13
  56. package/dist/es/qiankunUtils.js +0 -32
  57. package/dist/es/request.d.ts +0 -87
  58. package/dist/es/request.js +0 -308
  59. package/dist/es/src/parseTimeTest.js +0 -288
  60. package/dist/es/src/test.js +0 -245
  61. package/dist/es/test.js +0 -2
  62. package/dist/es/validate.d.ts +0 -26
  63. package/dist/es/validate.js +0 -47
  64. package/dist/es/water.d.ts +0 -53
  65. package/dist/es/water.js +0 -88
  66. package/dist/index.d.ts +0 -21
  67. package/dist/index.js +0 -21
package/dist/es/file.d.ts DELETED
@@ -1,127 +0,0 @@
1
- import { AxiosResponse } from 'axios';
2
-
3
- /**
4
- * 附件下载方法
5
- * @param fileId 附件id
6
- * @param fileName 附件名称
7
- * @param options
8
- * @param options.API_BASEURL {string} 接口请求的前缀地址 必传
9
- * @param options.authToken {string} token 非必传
10
- * @param options.waterMark {boolean | string} 是否添加水印 是否指定水印名称 非必传
11
- * @param options.open boolean 是否不需要登录信息
12
- */
13
- declare function downloadFile(fileId: string, fileName: string, options: IDownloadOptions): Promise<unknown>;
14
- /**
15
- * 附件批量下载方法
16
- * @param fileList 附件列表
17
- * @param options.API_BASEURL {string} 接口请求的前缀地址 必传
18
- * @param options.authToken {string} token 非必传
19
- * @param options.waterMark {boolean | string} 是否添加水印 是否指定水印名称 非必传
20
- * @param options.zipName string zip名字
21
- * @returns
22
- */
23
- declare function batchDownloadFiles(fileList: {
24
- attachId: string;
25
- attachName: string;
26
- [props: string]: string;
27
- }[], options: IBatchDownloadOptions): Promise<unknown>;
28
- /**
29
- * 附件预览。如果传入的附件是图片,那么实现批量预览
30
- * 预览使用文件服务器baseURL
31
- * @param fileId 附件id
32
- * @param fileName 附件名称
33
- * @param options
34
- * @param options.API_BASEURL {string} 接口请求的前缀地址 必传(文件服务器baseURL)
35
- * @param options.authToken {string} token 非必传
36
- * @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
37
- */
38
- declare function previewFile(fileId: string, fileName: string, options: IPreviewOptions): void;
39
- /**
40
- * 导出一个文件流
41
- * @param response 需要导出的文件流
42
- * @param fileName 文件名称 可以传后缀名,传后缀名会直接用这个后缀名 如果不传的或者与文件类型的后缀名不同 会取接口中提供的后缀名
43
- */
44
- declare function exportBolb(response: AxiosResponse, fileName?: string): Promise<unknown>;
45
- /**
46
- * 生成附件下载链接
47
- * @param fileId 附件id
48
- * @param options
49
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
50
- * @param options.authToken {string} token 非必传
51
- * @returns
52
- */
53
- declare function createDownloadLink(fileId: string, options?: IDownloadLinkOptions): string;
54
- /**
55
- * 生成原始图片路径
56
- * 预览使用文件服务器baseURL
57
- * @param fileId 附件id
58
- * @param fileName 附件名称
59
- * @param options
60
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传(文件服务器baseURL)
61
- * @param options.authToken {string} token 非必传
62
- * @returns
63
- */
64
- declare function createOriginalLink(fileId: string, fileName: string, options?: IOriginLinkOptions): string;
65
- /**
66
- * 生成缩略图路径
67
- * @param fileId 附件id
68
- * @param fileName 附件名称
69
- * @param options
70
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
71
- * @param options.authToken {string} token 非必传
72
- * @param options.scale {number} 缩略比
73
- * @returns
74
- * createThumbnailLink('1', 'z', { API_BASEURL: 1 })
75
- */
76
- declare function createThumbnailLink(fileId: string, fileName: string, options: IThumbnailLinkOptions): string;
77
- /**
78
- * 生成图片上传地址
79
- * @param options
80
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
81
- * @param options.authToken {string} token 非必传
82
- * @returns
83
- */
84
- declare function createUploadFileLink(options: IOptions): string;
85
- /**
86
- * 生成图片删除地址
87
- * @param options
88
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
89
- * @param options.authToken {string} token 非必传
90
- * @returns
91
- */
92
- declare function createDeleteFileLink(options: IOptions): string;
93
- interface IOptions {
94
- API_BASEURL: string;
95
- authToken?: string;
96
- }
97
- interface IDownloadOptions extends IOptions {
98
- /** 是否添加水印 */
99
- waterMark?: boolean | string;
100
- /** 是否开发不需要登录信息 */
101
- open?: boolean;
102
- }
103
- interface IBatchDownloadOptions extends IOptions {
104
- zipName: string;
105
- /** 是否添加水印 */
106
- waterMark?: boolean | string;
107
- }
108
- interface IDownloadLinkOptions extends Partial<IOptions> {
109
- /** 不需要登录信息的附件下载链接 */
110
- open?: boolean;
111
- }
112
- interface IPreviewOptions extends IOptions {
113
- /** 附件列表 */
114
- fileList?: {
115
- attachId: string;
116
- attachName: string;
117
- [props: string]: string;
118
- }[];
119
- }
120
- interface IOriginLinkOptions extends Partial<IOptions> {
121
- }
122
- interface IThumbnailLinkOptions extends Partial<IOptions> {
123
- /** 缩放比例 */
124
- scale?: number;
125
- }
126
-
127
- export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, exportBolb, previewFile };
package/dist/es/file.js DELETED
@@ -1,373 +0,0 @@
1
- import { getToken } from './auth.js';
2
- import { dangerouslyXss, specialString, getFileExtension, isImageExtension } from './common.js';
3
- import { BASIC_KEY, TOKEN_KEY, FILE_SERVICE, FILE_PRVIEW_SERVICE_URL } from './constants.js';
4
- import { Crypto } from './crypto.js';
5
-
6
- /**
7
- * 附件相关接口
8
- */
9
- // 是否是中拓的附件服务
10
- var isZmdmsFileService = FILE_SERVICE === "zmdms";
11
- /**
12
- * 附件下载方法
13
- * @param fileId 附件id
14
- * @param fileName 附件名称
15
- * @param options
16
- * @param options.API_BASEURL {string} 接口请求的前缀地址 必传
17
- * @param options.authToken {string} token 非必传
18
- * @param options.waterMark {boolean | string} 是否添加水印 是否指定水印名称 非必传
19
- * @param options.open boolean 是否不需要登录信息
20
- */
21
- function downloadFile(fileId, fileName, options) {
22
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.waterMark, waterMark = _a === void 0 ? true : _a, open = options.open;
23
- if (isZmdmsFileService) {
24
- fileId = encodeFileId(fileId, 2);
25
- }
26
- return new Promise(function (resolve, reject) {
27
- var xhr = new XMLHttpRequest();
28
- // 获取请求基础数据
29
- var _a = getBasicInfo(API_BASEURL, authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
30
- if (open) {
31
- xhr.open("GET", "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/public/download-file/").concat(fileId), true);
32
- }
33
- else {
34
- xhr.open("GET", "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/download-file/").concat(fileId, "?").concat(TOKEN_KEY, "=").concat(token, "&addWaterMark=").concat(waterMark), true);
35
- }
36
- xhr.responseType = "blob";
37
- xhr.onload = function () {
38
- if (xhr.status === 200 || xhr.status === 201) {
39
- var link = document.createElement("a");
40
- var body = document.querySelector("body");
41
- link.href = window.URL.createObjectURL(xhr.response);
42
- link.download = dangerouslyXss(fileName);
43
- // fix Firefox
44
- link.style.display = "none";
45
- body.appendChild(link);
46
- link.click();
47
- body.removeChild(link);
48
- window.URL.revokeObjectURL(link.href);
49
- resolve({ msg: "文件下载成功!" });
50
- }
51
- else {
52
- reject(xhr.response);
53
- }
54
- };
55
- xhr.onerror = function (err) {
56
- reject(err);
57
- };
58
- xhr.send();
59
- });
60
- }
61
- /**
62
- * 附件批量下载方法
63
- * @param fileList 附件列表
64
- * @param options.API_BASEURL {string} 接口请求的前缀地址 必传
65
- * @param options.authToken {string} token 非必传
66
- * @param options.waterMark {boolean | string} 是否添加水印 是否指定水印名称 非必传
67
- * @param options.zipName string zip名字
68
- * @returns
69
- */
70
- function batchDownloadFiles(fileList, options) {
71
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken, zipName = options.zipName, _a = options.waterMark, waterMark = _a === void 0 ? true : _a;
72
- return new Promise(function (resolve, reject) {
73
- var _a, _b, _c, _d, _e, _f;
74
- var xhr = new XMLHttpRequest();
75
- // 获取请求基础数据
76
- var _g = getBasicInfo(API_BASEURL, authToken), token = _g.token, apiBaseURL = _g.apiBaseURL;
77
- xhr.open("POST", "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/batch-download-file"), true);
78
- xhr.responseType = "blob";
79
- xhr.onload = function () {
80
- if (xhr.status === 200 || xhr.status === 201) {
81
- var link = document.createElement("a");
82
- var body = document.querySelector("body");
83
- link.href = window.URL.createObjectURL(xhr.response);
84
- link.download = zipName;
85
- // fix Firefox
86
- link.style.display = "none";
87
- body.appendChild(link);
88
- link.click();
89
- body.removeChild(link);
90
- window.URL.revokeObjectURL(link.href);
91
- resolve({ msg: "文件下载成功!" });
92
- }
93
- else {
94
- reject(xhr.response);
95
- }
96
- };
97
- xhr.onerror = function (err) {
98
- reject(err);
99
- };
100
- xhr.setRequestHeader(TOKEN_KEY, token || "");
101
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
102
- var fileIds = (_c = (_b = (_a = fileList === null || fileList === void 0 ? void 0 : fileList.map) === null || _a === void 0 ? void 0 : _a.call(fileList, function (item) { return item.attachId; })) === null || _b === void 0 ? void 0 : _b.join) === null || _c === void 0 ? void 0 : _c.call(_b, ",");
103
- var fileNames = (_f = (_e = (_d = fileList === null || fileList === void 0 ? void 0 : fileList.map) === null || _d === void 0 ? void 0 : _d.call(fileList, function (item) { return item.attachName; })) === null || _e === void 0 ? void 0 : _e.join) === null || _f === void 0 ? void 0 : _f.call(_e, ",");
104
- if (isZmdmsFileService) {
105
- fileIds = encodeFileId(fileIds, 2);
106
- }
107
- xhr.send("attachIds=".concat(fileIds, "&fileNames=").concat(fileNames, "&zipName=").concat(zipName, "&addWaterMark=").concat(waterMark));
108
- });
109
- }
110
- /**
111
- * 附件预览。如果传入的附件是图片,那么实现批量预览
112
- * 预览使用文件服务器baseURL
113
- * @param fileId 附件id
114
- * @param fileName 附件名称
115
- * @param options
116
- * @param options.API_BASEURL {string} 接口请求的前缀地址 必传(文件服务器baseURL)
117
- * @param options.authToken {string} token 非必传
118
- * @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
119
- */
120
- function previewFile(fileId, fileName, options) {
121
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.fileList, fileList = _a === void 0 ? [] : _a;
122
- // 获取请求基础数据
123
- var _b = getBasicInfo(FILE_PRVIEW_SERVICE_URL || API_BASEURL, authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
124
- // 处理附件名中的一些特殊字符
125
- var previewFileName = dangerouslyXss(fileName);
126
- try {
127
- previewFileName = specialString(previewFileName);
128
- }
129
- catch (err) {
130
- console.log(err);
131
- }
132
- // 获取文件后缀
133
- var _c = getFileExtension(previewFileName), filePreName = _c[0], fileExtension = _c[1];
134
- // 由于预览使用了文件名地址作为iframe的路径
135
- // 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
136
- // 所以将文件名 与 文件id组合来生成不同的文件名
137
- previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
138
- if (!isZmdmsFileService) {
139
- // 2023-12-30 修改成数字中心预览
140
- window.open("".concat(apiBaseURL, "/api/cicoms-resource/attach/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token));
141
- return;
142
- }
143
- // 如果是图片 走批量预览接口
144
- var isImage = isImageExtension(fileExtension);
145
- if (isImage) {
146
- var imgFiles = fileList.filter(function (item) {
147
- var attachName = item.attachName, attachId = item.attachId;
148
- var _a = getFileExtension(attachName), fileExtension = _a[1];
149
- if (isImageExtension(fileExtension) && attachId !== fileId) {
150
- return true;
151
- }
152
- return false;
153
- });
154
- var attachIds = imgFiles.map(function (item) { return item.attachId; }).join(",");
155
- var fileIds = attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId;
156
- if (isZmdmsFileService) {
157
- fileIds = encodeFileId(fileIds, 1);
158
- }
159
- // 批量图片预览
160
- window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(fileIds, "&").concat(TOKEN_KEY, "=").concat(token) +
161
- (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
162
- }
163
- else {
164
- if (isZmdmsFileService) {
165
- fileId = encodeFileId(fileId, 1);
166
- }
167
- // 普通预览
168
- window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
169
- (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
170
- }
171
- }
172
- /**
173
- * 导出一个文件流
174
- * @param response 需要导出的文件流
175
- * @param fileName 文件名称 可以传后缀名,传后缀名会直接用这个后缀名 如果不传的或者与文件类型的后缀名不同 会取接口中提供的后缀名
176
- */
177
- function exportBolb(response, fileName) {
178
- return new Promise(function (resolve, reject) {
179
- try {
180
- var content = response.data;
181
- var blob = new Blob([content], {
182
- type: response.headers["content-type"],
183
- });
184
- // 判断是否支持下载
185
- if ("download" in document.createElement("a")) {
186
- // 非IE下载
187
- var elink = document.createElement("a");
188
- // 获取系统返回的名称
189
- var copyName = response.headers["content-disposition"]
190
- .split(";")[1]
191
- .split("=")[1];
192
- // 去除前后引号
193
- if (copyName.startsWith('"') || copyName.startsWith("'")) {
194
- copyName = copyName.slice(1);
195
- }
196
- if (copyName.endsWith('"') || copyName.endsWith("'")) {
197
- copyName = copyName.slice(0, -1);
198
- }
199
- // 可以自定义名称
200
- if (fileName) {
201
- var _a = getFileExtension(fileName), name_1 = _a[0], extension = _a[1];
202
- if (copyName) {
203
- var _b = getFileExtension(decodeURIComponent(copyName)), copyExtension = _b[1];
204
- elink.download =
205
- extension === copyExtension
206
- ? fileName
207
- : "".concat(name_1, ".").concat(copyExtension);
208
- }
209
- else {
210
- elink.download = fileName;
211
- }
212
- }
213
- else if (copyName) {
214
- // Content-disposition
215
- elink.download = decodeURIComponent(copyName);
216
- }
217
- elink.style.display = "none";
218
- elink.href = URL.createObjectURL(blob);
219
- document.body.appendChild(elink);
220
- elink.click();
221
- URL.revokeObjectURL(elink.href); // 释放URL 对象
222
- document.body.removeChild(elink);
223
- resolve({
224
- result: true,
225
- msg: "下载成功",
226
- });
227
- }
228
- else {
229
- reject({
230
- result: false,
231
- msg: "浏览器不支持下载!请更换谷歌浏览器或者升级版本",
232
- });
233
- }
234
- }
235
- catch (err) {
236
- reject({
237
- result: false,
238
- msg: "数据不是Bolb类型,无法导出!请检查传入的response",
239
- });
240
- }
241
- });
242
- }
243
- /**
244
- * 生成附件下载链接
245
- * @param fileId 附件id
246
- * @param options
247
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
248
- * @param options.authToken {string} token 非必传
249
- * @returns
250
- */
251
- function createDownloadLink(fileId, options) {
252
- if (options === void 0) { options = {}; }
253
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken, open = options.open;
254
- var _a = getBasicInfo(API_BASEURL || "", authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
255
- if (isZmdmsFileService) {
256
- fileId = encodeFileId(fileId, 2);
257
- }
258
- if (open) {
259
- return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/public/download-file/").concat(fileId);
260
- }
261
- return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/download-file/").concat(fileId, "?").concat(TOKEN_KEY, "=").concat(token);
262
- }
263
- /**
264
- * 生成原始图片路径
265
- * 预览使用文件服务器baseURL
266
- * @param fileId 附件id
267
- * @param fileName 附件名称
268
- * @param options
269
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传(文件服务器baseURL)
270
- * @param options.authToken {string} token 非必传
271
- * @returns
272
- */
273
- function createOriginalLink(fileId, fileName, options) {
274
- if (options === void 0) { options = {}; }
275
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken;
276
- var _a = getBasicInfo(FILE_PRVIEW_SERVICE_URL || API_BASEURL || "", authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
277
- // 处理附件名中的一些特殊字符
278
- var previewFileName = dangerouslyXss(fileName);
279
- try {
280
- previewFileName = specialString(previewFileName);
281
- }
282
- catch (err) {
283
- console.log(err);
284
- }
285
- // 获取文件后缀
286
- var _b = getFileExtension(previewFileName), filePreName = _b[0], fileExtension = _b[1];
287
- // 由于预览使用了文件名地址作为iframe的路径
288
- // 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
289
- // 所以将文件名 与 文件id组合来生成不同的文件名
290
- previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
291
- // 2023-12-30 替换成数字中心的 预览接口
292
- if (!isZmdmsFileService) {
293
- return "".concat(apiBaseURL, "/api/cicoms-resource/attach/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token);
294
- }
295
- if (isZmdmsFileService) {
296
- fileId = encodeFileId(fileId, 2);
297
- }
298
- return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
299
- (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
300
- }
301
- /**
302
- * 生成缩略图路径
303
- * @param fileId 附件id
304
- * @param fileName 附件名称
305
- * @param options
306
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
307
- * @param options.authToken {string} token 非必传
308
- * @param options.scale {number} 缩略比
309
- * @returns
310
- * createThumbnailLink('1', 'z', { API_BASEURL: 1 })
311
- */
312
- function createThumbnailLink(fileId, fileName, options) {
313
- var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.scale, scale = _a === void 0 ? 0.5 : _a;
314
- var _b = getBasicInfo(API_BASEURL || "", authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
315
- return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/thumbnail/").concat(fileId, "?scale=").concat(scale, "&").concat(TOKEN_KEY, "=").concat(token);
316
- }
317
- /**
318
- * 生成图片上传地址
319
- * @param options
320
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
321
- * @param options.authToken {string} token 非必传
322
- * @returns
323
- */
324
- function createUploadFileLink(options) {
325
- var API_BASEURL = options.API_BASEURL;
326
- var apiBaseURL = getBasicInfo(API_BASEURL || "").apiBaseURL;
327
- return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/put-file-attach");
328
- }
329
- /**
330
- * 生成图片删除地址
331
- * @param options
332
- * @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
333
- * @param options.authToken {string} token 非必传
334
- * @returns
335
- */
336
- function createDeleteFileLink(options) {
337
- var API_BASEURL = options.API_BASEURL;
338
- var apiBaseURL = getBasicInfo(API_BASEURL || "").apiBaseURL;
339
- return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/remove-file");
340
- }
341
- /**
342
- * 获取基础数据
343
- * @param baseURL 基础URL
344
- * @param token token
345
- * @returns
346
- */
347
- function getBasicInfo(baseURL, token) {
348
- var _a;
349
- return {
350
- token: token || getToken(),
351
- apiBaseURL: ((_a = baseURL === null || baseURL === void 0 ? void 0 : baseURL.endsWith) === null || _a === void 0 ? void 0 : _a.call(baseURL, "/"))
352
- ? baseURL.slice(0, baseURL.length - 1)
353
- : baseURL,
354
- };
355
- }
356
- /**
357
- * 加密附件ID
358
- * @param fileId 附件ID
359
- * @description 加密方式
360
- * 1. 都会通过encrypt加密一次
361
- * 2. 如果参数是通过地址栏传输的,附件预览:encode一次;附件下载:encode两次;
362
- * 3. 如果参数是通过body传输的,只需要encode一次
363
- */
364
- function encodeFileId(fileId, encodeNum) {
365
- if (encodeNum === void 0) { encodeNum = 1; }
366
- var crypto = new Crypto(window.__CRYPTO_AES_KEY__, window.__CRYPTO_DES_KEY__);
367
- if (encodeNum === 1) {
368
- return encodeURIComponent(crypto.encrypt(fileId));
369
- }
370
- return encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
371
- }
372
-
373
- export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, encodeFileId, exportBolb, previewFile };
@@ -1,44 +0,0 @@
1
- import { IImgToPdfConfig } from './pdf.js';
2
-
3
- interface IConfig {
4
- /** 容器,从哪个容器里面找需要转换的元素 */
5
- container?: HTMLElement;
6
- /**
7
- * 需要转换的dom 可以是一个字符串
8
- * 如果是字符串的话 那么就是通过querySelectorAll的形式查找
9
- * 如果是一个dom实例
10
- * 如果是多个dom实例
11
- **/
12
- pageDom?: string | HTMLElement | HTMLElement[];
13
- /**
14
- * 是否使用canvas直接转
15
- */
16
- useCanvas?: boolean;
17
- /**
18
- * 是否生成多份PDF
19
- */
20
- isMultiple?: boolean;
21
- /**
22
- * pdf名称 默认取dom元素配置的 data-title属性
23
- */
24
- pdfName?: string;
25
- /**
26
- * pdf相关配置
27
- */
28
- pdfConfig?: IImgToPdfConfig["pdfConfig"];
29
- /**
30
- * 生成PDF的左边距
31
- */
32
- leftPadding?: number;
33
- /**
34
- * 是否下载pdf
35
- */
36
- isDownload?: boolean;
37
- /**
38
- * 水印相关
39
- */
40
- waterConfig?: IImgToPdfConfig["waterConfig"];
41
- }
42
- declare function htmlToPdf(config: IConfig): Promise<unknown>;
43
-
44
- export { htmlToPdf };
@@ -1,84 +0,0 @@
1
- import { __awaiter, __generator } from './_virtual/_tslib.js';
2
- import dayjs from 'dayjs';
3
- import { imgToPdf } from './pdf.js';
4
- import { domToCanvas } from './canvas.js';
5
-
6
- function htmlToPdf(config) {
7
- var _this = this;
8
- var container = config.container, pageDom = config.pageDom, _a = config.useCanvas, useCanvas = _a === void 0 ? true : _a, isMultiple = config.isMultiple, pdfConfig = config.pdfConfig, pdfName = config.pdfName, isDownload = config.isDownload, waterConfig = config.waterConfig, leftPadding = config.leftPadding;
9
- // 找到需要转换的dom
10
- var domList;
11
- if (typeof pageDom === "string") {
12
- domList = container
13
- ? container.querySelectorAll(pageDom)
14
- : document.body.querySelectorAll(pageDom);
15
- domList = Array.from(domList);
16
- }
17
- else {
18
- domList = Array.isArray(pageDom) ? pageDom : [pageDom];
19
- }
20
- if (domList.length === 0) {
21
- return Promise.reject("没有可以导出的元素!");
22
- }
23
- if (!useCanvas) {
24
- // 直接导出html 待实现
25
- return Promise.resolve();
26
- }
27
- // 通过html => canvas => pdf 的形式导出
28
- // 多份导出
29
- if (isMultiple) {
30
- var promiseArr_1 = [];
31
- domList.forEach(function (domItem, index) {
32
- var dataTitle = domItem.dataset.title || "".concat(dayjs().format("YYYY-MM-DD"), "-").concat(index + 1);
33
- var item = domToCanvas(domItem).then(function (canvas) { return __awaiter(_this, void 0, void 0, function () {
34
- var canvasWidth, canvasHeight, pdf;
35
- return __generator(this, function (_a) {
36
- switch (_a.label) {
37
- case 0:
38
- canvasWidth = canvas.width;
39
- canvasHeight = canvas.height;
40
- return [4 /*yield*/, imgToPdf({
41
- images: {
42
- image: canvas,
43
- width: canvasWidth,
44
- height: canvasHeight,
45
- },
46
- pdfConfig: pdfConfig,
47
- leftPadding: leftPadding,
48
- pdfDownloadConfig: {
49
- isDownload: isDownload,
50
- pdfName: pdfName ? pdfName : dataTitle,
51
- },
52
- waterConfig: waterConfig,
53
- })];
54
- case 1:
55
- pdf = _a.sent();
56
- return [2 /*return*/, pdf];
57
- }
58
- });
59
- }); });
60
- promiseArr_1.push(item);
61
- });
62
- return Promise.all(promiseArr_1);
63
- }
64
- else {
65
- // 创建canvas组
66
- var promiseArr = domList.map(function (domItem, index) {
67
- return domToCanvas(domItem);
68
- });
69
- var dataTitle = domList[0].dataset.title || "".concat(dayjs().format("YYYY-MM-DD"));
70
- // 合并成一个pdf导出
71
- return imgToPdf({
72
- images: promiseArr,
73
- pdfConfig: pdfConfig,
74
- pdfDownloadConfig: {
75
- isDownload: isDownload,
76
- pdfName: pdfName ? pdfName : dataTitle,
77
- },
78
- waterConfig: waterConfig,
79
- leftPadding: leftPadding,
80
- });
81
- }
82
- }
83
-
84
- export { htmlToPdf };
@@ -1,36 +0,0 @@
1
- interface IEntry {
2
- scripts?: string[];
3
- styles?: string[];
4
- html?: string;
5
- }
6
- type IActiveRule = (location: Location) => boolean;
7
- interface IMicroApp {
8
- name: string;
9
- entry: string | IEntry;
10
- container: string | HTMLElement;
11
- activeRule: string | string[] | IActiveRule | IActiveRule[];
12
- loader?: (loading: boolean) => void;
13
- props?: object;
14
- }
15
- interface IOtherOptions {
16
- /** 过滤掉的一些资源的关键词,必须保证不过滤掉一些不该过滤的东西 */
17
- whiteWords?: string[];
18
- /** loading 发生变化触发事件 */
19
- loader?: (loading: boolean) => void;
20
- startOptions?: any;
21
- }
22
- /**
23
- * 主应用初始化逻辑
24
- * @param microApps 子应用列表
25
- * @param defaultAppLink 设置主应用启动后默认进入的微应用
26
- * @param otherOptions
27
- */
28
- declare function initMainApp(microApps: IMicroApp[], defaultAppLink: string, otherOptions?: IOtherOptions): void;
29
- /**
30
- * 全局错误处理
31
- * @param handle 错误函数
32
- * @returns 清空监听
33
- */
34
- declare function initGlobalError(handle: (event: any) => void): () => void;
35
-
36
- export { IMicroApp, initGlobalError, initMainApp };