zmdms-utils 0.0.31 → 0.0.32

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.
@@ -14,5 +14,7 @@ declare const EMITTER_TYPE: {
14
14
  treeSearchWhitePath: string;
15
15
  treeSearchSet: string;
16
16
  };
17
+ declare const TOKEN_KEY = "Cicoms-Auth";
18
+ declare const BASIC_KEY = "cicoms";
17
19
 
18
- export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE };
20
+ export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY };
@@ -19,5 +19,11 @@ var EMITTER_TYPE = {
19
19
  treeSearchWhitePath: "treeSearchWhitePath",
20
20
  treeSearchSet: "treeSearchSet", // 父应用传递搜索树的值
21
21
  };
22
+ // token key 值
23
+ // export const TOKEN_KEY = "Zmdms-Auth";
24
+ var TOKEN_KEY = "Cicoms-Auth";
25
+ // 基础前缀
26
+ // export const BASIC_KEY = "zmdms";
27
+ var BASIC_KEY = "cicoms";
22
28
 
23
- export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME };
29
+ export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME, TOKEN_KEY };
package/dist/es/file.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getToken } from './auth.js';
2
2
  import { dangerouslyXss, specialString, getFileExtension, isImageExtension } from './common.js';
3
+ import { BASIC_KEY, TOKEN_KEY } from './constants.js';
3
4
 
4
5
  /**
5
6
  * 附件相关接口
@@ -21,10 +22,10 @@ function downloadFile(fileId, fileName, options) {
21
22
  // 获取请求基础数据
22
23
  var _a = getBasicInfo(API_BASEURL, authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
23
24
  if (open) {
24
- xhr.open("GET", "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/public/download-file/").concat(fileId), true);
25
+ xhr.open("GET", "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/public/download-file/").concat(fileId), true);
25
26
  }
26
27
  else {
27
- xhr.open("GET", "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/download-file/").concat(fileId, "?Zmdms-Auth=").concat(token, "&addWaterMark=").concat(waterMark), true);
28
+ 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);
28
29
  }
29
30
  xhr.responseType = "blob";
30
31
  xhr.onload = function () {
@@ -67,7 +68,7 @@ function batchDownloadFiles(fileList, options) {
67
68
  var xhr = new XMLHttpRequest();
68
69
  // 获取请求基础数据
69
70
  var _g = getBasicInfo(API_BASEURL, authToken), token = _g.token, apiBaseURL = _g.apiBaseURL;
70
- xhr.open("POST", "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/batch-download-file"), true);
71
+ xhr.open("POST", "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/batch-download-file"), true);
71
72
  xhr.responseType = "blob";
72
73
  xhr.onload = function () {
73
74
  if (xhr.status === 200 || xhr.status === 201) {
@@ -90,7 +91,7 @@ function batchDownloadFiles(fileList, options) {
90
91
  xhr.onerror = function (err) {
91
92
  reject(err);
92
93
  };
93
- xhr.setRequestHeader("Zmdms-Auth", token || "");
94
+ xhr.setRequestHeader(TOKEN_KEY, token || "");
94
95
  xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
95
96
  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, ",");
96
97
  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, ",");
@@ -138,12 +139,12 @@ function previewFile(fileId, fileName, options) {
138
139
  });
139
140
  var attachIds = imgFiles.map(function (item) { return item.attachId; }).join(",");
140
141
  // 批量图片预览
141
- window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&Zmdms-Auth=").concat(token) +
142
+ window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&").concat(TOKEN_KEY, "=").concat(token) +
142
143
  (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
143
144
  }
144
145
  else {
145
146
  // 普通预览
146
- window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=").concat(token, "&officePreviewType=pdf") +
147
+ window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
147
148
  (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
148
149
  }
149
150
  }
@@ -214,9 +215,9 @@ function createDownloadLink(fileId, options) {
214
215
  var API_BASEURL = options.API_BASEURL, authToken = options.authToken, open = options.open;
215
216
  var _a = getBasicInfo(API_BASEURL || "", authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
216
217
  if (open) {
217
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/public/download-file/").concat(fileId);
218
+ return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/public/download-file/").concat(fileId);
218
219
  }
219
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/download-file/").concat(fileId, "?Zmdms-Auth=").concat(token);
220
+ return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/download-file/").concat(fileId, "?").concat(TOKEN_KEY, "=").concat(token);
220
221
  }
221
222
  /**
222
223
  * 生成原始图片路径
@@ -246,7 +247,7 @@ function createOriginalLink(fileId, fileName, options) {
246
247
  // 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
247
248
  // 所以将文件名 与 文件id组合来生成不同的文件名
248
249
  previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
249
- return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=").concat(token, "&officePreviewType=pdf") +
250
+ return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
250
251
  (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
251
252
  }
252
253
  /**
@@ -263,7 +264,7 @@ function createOriginalLink(fileId, fileName, options) {
263
264
  function createThumbnailLink(fileId, fileName, options) {
264
265
  var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.scale, scale = _a === void 0 ? 0.5 : _a;
265
266
  var _b = getBasicInfo(API_BASEURL || "", authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
266
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/thumbnail/").concat(fileId, "?scale=").concat(scale, "&Zmdms-Auth=").concat(token);
267
+ return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/thumbnail/").concat(fileId, "?scale=").concat(scale, "&").concat(TOKEN_KEY, "=").concat(token);
267
268
  }
268
269
  /**
269
270
  * 生成图片上传地址
@@ -275,7 +276,7 @@ function createThumbnailLink(fileId, fileName, options) {
275
276
  function createUploadFileLink(options) {
276
277
  var API_BASEURL = options.API_BASEURL;
277
278
  var apiBaseURL = getBasicInfo(API_BASEURL || "").apiBaseURL;
278
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/put-file-attach");
279
+ return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/put-file-attach");
279
280
  }
280
281
  /**
281
282
  * 生成图片删除地址
@@ -287,7 +288,7 @@ function createUploadFileLink(options) {
287
288
  function createDeleteFileLink(options) {
288
289
  var API_BASEURL = options.API_BASEURL;
289
290
  var apiBaseURL = getBasicInfo(API_BASEURL || "").apiBaseURL;
290
- return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/remove-file");
291
+ return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/remove-file");
291
292
  }
292
293
  /**
293
294
  * 获取基础数据
@@ -1,6 +1,7 @@
1
1
  import { __rest, __assign } from './_virtual/_tslib.js';
2
2
  import axios from 'axios';
3
3
  import { removeToken, getToken } from './auth.js';
4
+ import { TOKEN_KEY } from './constants.js';
4
5
 
5
6
  var defaultOptions = {
6
7
  TenantId: "000000",
@@ -197,7 +198,7 @@ var AxiosRequest = /** @class */ (function () {
197
198
  }
198
199
  if (isAuth) {
199
200
  var token = getToken();
200
- newOptions.headers["Zmdms-Auth"] = "bearer ".concat(token);
201
+ newOptions.headers[TOKEN_KEY] = "bearer ".concat(token);
201
202
  }
202
203
  // 遍历params,将undefined值 转为null值
203
204
  if (newOptions.data) {
package/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { validatePassword } from './es/passwordValidate.js';
11
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
- export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from './es/constants.js';
14
+ export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY } from './es/constants.js';
15
15
  export { convert, html, match, pinyin } from 'pinyin-pro';
package/dist/index.js CHANGED
@@ -11,5 +11,5 @@ export { validatePassword } from './es/passwordValidate.js';
11
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
- export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from './es/constants.js';
14
+ export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, TOKEN_KEY } from './es/constants.js';
15
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.31",
3
+ "version": "0.0.32",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/constants.ts CHANGED
@@ -23,3 +23,11 @@ export const EMITTER_TYPE = {
23
23
  treeSearchWhitePath: "treeSearchWhitePath", // 子应用传递搜索树的路由白名单
24
24
  treeSearchSet: "treeSearchSet", // 父应用传递搜索树的值
25
25
  };
26
+
27
+ // token key 值
28
+ // export const TOKEN_KEY = "Zmdms-Auth";
29
+ export const TOKEN_KEY = "Cicoms-Auth";
30
+
31
+ // 基础前缀
32
+ // export const BASIC_KEY = "zmdms";
33
+ export const BASIC_KEY = "cicoms";
package/src/file.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  getFileExtension,
9
9
  isImageExtension,
10
10
  } from "./common";
11
+ import { TOKEN_KEY, BASIC_KEY } from "./constants";
11
12
  import { AxiosResponse } from "axios";
12
13
 
13
14
  /**
@@ -33,13 +34,13 @@ export function downloadFile(
33
34
  if (open) {
34
35
  xhr.open(
35
36
  "GET",
36
- `${apiBaseURL}/api/zmdms-resource/oss/endpoint/public/download-file/${fileId}`,
37
+ `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/public/download-file/${fileId}`,
37
38
  true
38
39
  );
39
40
  } else {
40
41
  xhr.open(
41
42
  "GET",
42
- `${apiBaseURL}/api/zmdms-resource/oss/endpoint/download-file/${fileId}?Zmdms-Auth=${token}&addWaterMark=${waterMark}`,
43
+ `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/download-file/${fileId}?${TOKEN_KEY}=${token}&addWaterMark=${waterMark}`,
43
44
  true
44
45
  );
45
46
  }
@@ -97,7 +98,7 @@ export function batchDownloadFiles(
97
98
  const { token, apiBaseURL } = getBasicInfo(API_BASEURL, authToken);
98
99
  xhr.open(
99
100
  "POST",
100
- `${apiBaseURL}/api/zmdms-resource/oss/endpoint/batch-download-file`,
101
+ `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/batch-download-file`,
101
102
  true
102
103
  );
103
104
  xhr.responseType = "blob";
@@ -126,7 +127,7 @@ export function batchDownloadFiles(
126
127
  xhr.onerror = function (err) {
127
128
  reject(err);
128
129
  };
129
- xhr.setRequestHeader("Zmdms-Auth", token || "");
130
+ xhr.setRequestHeader(TOKEN_KEY, token || "");
130
131
  xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
131
132
  const fileIds = fileList?.map?.((item) => item.attachId)?.join?.(",");
132
133
  const fileNames = fileList?.map?.((item) => item.attachName)?.join?.(",");
@@ -183,13 +184,13 @@ export function previewFile(
183
184
  window.open(
184
185
  `${apiBaseURL}/picturesAttchPreview?attachIds=${
185
186
  attachIds ? `${fileId},${attachIds}` : fileId
186
- }&Zmdms-Auth=${token}` +
187
+ }&${TOKEN_KEY}=${token}` +
187
188
  (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
188
189
  );
189
190
  } else {
190
191
  // 普通预览
191
192
  window.open(
192
- `${apiBaseURL}/attchPreview?attachId=${fileId}&Zmdms-Auth=${token}&officePreviewType=pdf` +
193
+ `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
193
194
  (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
194
195
  );
195
196
  }
@@ -262,9 +263,9 @@ export function createDownloadLink(
262
263
  const { API_BASEURL, authToken, open } = options;
263
264
  const { token, apiBaseURL } = getBasicInfo(API_BASEURL || "", authToken);
264
265
  if (open) {
265
- return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/public/download-file/${fileId}`;
266
+ return `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/public/download-file/${fileId}`;
266
267
  }
267
- return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/download-file/${fileId}?Zmdms-Auth=${token}`;
268
+ return `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/download-file/${fileId}?${TOKEN_KEY}=${token}`;
268
269
  }
269
270
 
270
271
  /**
@@ -298,7 +299,7 @@ export function createOriginalLink(
298
299
  // 所以将文件名 与 文件id组合来生成不同的文件名
299
300
  previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
300
301
  return (
301
- `${apiBaseURL}/attchPreview?attachId=${fileId}&Zmdms-Auth=${token}&officePreviewType=pdf` +
302
+ `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
302
303
  (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
303
304
  );
304
305
  }
@@ -321,7 +322,7 @@ export function createThumbnailLink(
321
322
  ) {
322
323
  const { API_BASEURL, authToken, scale = 0.5 } = options;
323
324
  const { token, apiBaseURL } = getBasicInfo(API_BASEURL || "", authToken);
324
- return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/thumbnail/${fileId}?scale=${scale}&Zmdms-Auth=${token}`;
325
+ return `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/thumbnail/${fileId}?scale=${scale}&${TOKEN_KEY}=${token}`;
325
326
  }
326
327
 
327
328
  /**
@@ -334,7 +335,7 @@ export function createThumbnailLink(
334
335
  export function createUploadFileLink(options: IOptions) {
335
336
  const { API_BASEURL } = options;
336
337
  const { apiBaseURL } = getBasicInfo(API_BASEURL || "");
337
- return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/put-file-attach`;
338
+ return `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/put-file-attach`;
338
339
  }
339
340
  /**
340
341
  * 生成图片删除地址
@@ -346,7 +347,7 @@ export function createUploadFileLink(options: IOptions) {
346
347
  export function createDeleteFileLink(options: IOptions) {
347
348
  const { API_BASEURL } = options;
348
349
  const { apiBaseURL } = getBasicInfo(API_BASEURL || "");
349
- return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/remove-file`;
350
+ return `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/remove-file`;
350
351
  }
351
352
 
352
353
  /**
package/src/index.ts CHANGED
@@ -50,7 +50,13 @@ export { parseTime, calculateAge } from "./parseTime";
50
50
  /**
51
51
  * 常量相关
52
52
  */
53
- export { EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE } from "./constants";
53
+ export {
54
+ EMITTER_CCP_KEY,
55
+ EMITTER_PCC_KEY,
56
+ EMITTER_TYPE,
57
+ TOKEN_KEY,
58
+ BASIC_KEY,
59
+ } from "./constants";
54
60
 
55
61
  /**
56
62
  * 中文处理
package/src/request.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import axios, { AxiosRequestConfig, AxiosResponse } from "axios";
3
3
  import { getToken, removeToken } from "./auth";
4
4
  import { Crypto } from "./crypto";
5
+ import { TOKEN_KEY } from "./constants";
5
6
 
6
7
  const defaultOptions: IOtherOptions = {
7
8
  TenantId: "000000",
@@ -245,7 +246,7 @@ export class AxiosRequest {
245
246
  }
246
247
  if (isAuth) {
247
248
  const token = getToken();
248
- newOptions.headers["Zmdms-Auth"] = `bearer ${token}`;
249
+ newOptions.headers[TOKEN_KEY] = `bearer ${token}`;
249
250
  }
250
251
 
251
252
  // 遍历params,将undefined值 转为null值