zmdms-utils 0.0.67 → 0.0.69
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/baseUrl.js +2 -2
- package/dist/es/constants.js +3 -1
- package/dist/es/file.js +5 -5
- package/package.json +1 -1
- package/src/baseUrl.ts +2 -2
- package/src/constants.ts +4 -0
- package/src/file.ts +16 -5
package/dist/es/baseUrl.js
CHANGED
|
@@ -4,7 +4,7 @@ function getBaseUrl(processObj, options) {
|
|
|
4
4
|
var ENV = processObj[envKey]; // 获取当前环境变量
|
|
5
5
|
// api各个环境地址
|
|
6
6
|
var apiBaseUrlObj = {
|
|
7
|
-
dev: processObj["".concat(apiKey, "_DEV")] ||
|
|
7
|
+
dev: processObj["".concat(apiKey, "_DEV")] || window.location.origin,
|
|
8
8
|
test: processObj["".concat(apiKey, "_TEST")] || window.location.origin,
|
|
9
9
|
stage: processObj["".concat(apiKey, "_STAGE")] || window.location.origin,
|
|
10
10
|
prod: processObj["".concat(apiKey, "_PROD")] || window.location.origin,
|
|
@@ -18,7 +18,7 @@ function getBaseUrl(processObj, options) {
|
|
|
18
18
|
};
|
|
19
19
|
// file 服务器
|
|
20
20
|
var fileBaseUrlObj = {
|
|
21
|
-
dev: processObj["".concat(fileKey, "_DEV")] ||
|
|
21
|
+
dev: processObj["".concat(fileKey, "_DEV")] || window.location.origin,
|
|
22
22
|
test: processObj["".concat(fileKey, "_TEST")] || window.location.origin,
|
|
23
23
|
stage: processObj["".concat(fileKey, "_STAGE")] || window.location.origin,
|
|
24
24
|
prod: processObj["".concat(fileKey, "_PROD")] || window.location.origin,
|
package/dist/es/constants.js
CHANGED
|
@@ -27,5 +27,7 @@ var TOKEN_KEY = window.__TOKEN_KEY__ || "Cicoms-Auth";
|
|
|
27
27
|
var BASIC_KEY = window.__BASIC_KEY__ || "cicoms";
|
|
28
28
|
// 附件相关服务
|
|
29
29
|
var FILE_SERVICE = window.__FILE_SERVICE__ || "cicoms";
|
|
30
|
+
// 默认的附件预览服务地址
|
|
31
|
+
var FILE_PRVIEW_SERVICE_URL = window.__FILE_PRVIEW_SERVICE_URL__ || "";
|
|
30
32
|
|
|
31
|
-
export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, FILE_SERVICE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME, TOKEN_KEY };
|
|
33
|
+
export { BASIC_KEY, EMITTER_CCP_KEY, EMITTER_PCC_KEY, EMITTER_TYPE, FILE_PRVIEW_SERVICE_URL, FILE_SERVICE, PERSONNEL_CENTER_APPNAME, SALARY_CENTER_APPNAME, TOKEN_KEY };
|
package/dist/es/file.js
CHANGED
|
@@ -1,6 +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, FILE_SERVICE } from './constants.js';
|
|
3
|
+
import { BASIC_KEY, TOKEN_KEY, FILE_SERVICE, FILE_PRVIEW_SERVICE_URL } from './constants.js';
|
|
4
4
|
import { Crypto } from './crypto.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -120,7 +120,7 @@ function batchDownloadFiles(fileList, options) {
|
|
|
120
120
|
function previewFile(fileId, fileName, options) {
|
|
121
121
|
var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.fileList, fileList = _a === void 0 ? [] : _a;
|
|
122
122
|
// 获取请求基础数据
|
|
123
|
-
var _b = getBasicInfo(API_BASEURL, authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
|
|
123
|
+
var _b = getBasicInfo(FILE_PRVIEW_SERVICE_URL || API_BASEURL, authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
|
|
124
124
|
// 处理附件名中的一些特殊字符
|
|
125
125
|
var previewFileName = dangerouslyXss(fileName);
|
|
126
126
|
try {
|
|
@@ -137,7 +137,7 @@ function previewFile(fileId, fileName, options) {
|
|
|
137
137
|
previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
|
|
138
138
|
if (!isZmdmsFileService) {
|
|
139
139
|
// 2023-12-30 修改成数字中心预览
|
|
140
|
-
window.open("".concat(apiBaseURL, "/api/cicoms-
|
|
140
|
+
window.open("".concat(apiBaseURL, "/api/cicoms-resource/attach/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token));
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
// 如果是图片 走批量预览接口
|
|
@@ -273,7 +273,7 @@ function createDownloadLink(fileId, options) {
|
|
|
273
273
|
function createOriginalLink(fileId, fileName, options) {
|
|
274
274
|
if (options === void 0) { options = {}; }
|
|
275
275
|
var API_BASEURL = options.API_BASEURL, authToken = options.authToken;
|
|
276
|
-
var _a = getBasicInfo(API_BASEURL || "", authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
|
|
276
|
+
var _a = getBasicInfo(FILE_PRVIEW_SERVICE_URL || API_BASEURL || "", authToken), token = _a.token, apiBaseURL = _a.apiBaseURL;
|
|
277
277
|
// 处理附件名中的一些特殊字符
|
|
278
278
|
var previewFileName = dangerouslyXss(fileName);
|
|
279
279
|
try {
|
|
@@ -290,7 +290,7 @@ function createOriginalLink(fileId, fileName, options) {
|
|
|
290
290
|
previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
|
|
291
291
|
// 2023-12-30 替换成数字中心的 预览接口
|
|
292
292
|
if (!isZmdmsFileService) {
|
|
293
|
-
return "".concat(apiBaseURL, "/api/cicoms-
|
|
293
|
+
return "".concat(apiBaseURL, "/api/cicoms-resource/attach/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token);
|
|
294
294
|
}
|
|
295
295
|
if (isZmdmsFileService) {
|
|
296
296
|
fileId = encodeFileId(fileId, 2);
|
package/package.json
CHANGED
package/src/baseUrl.ts
CHANGED
|
@@ -28,7 +28,7 @@ export function getBaseUrl(processObj: any, options?: IOptions) {
|
|
|
28
28
|
|
|
29
29
|
// api各个环境地址
|
|
30
30
|
const apiBaseUrlObj: any = {
|
|
31
|
-
dev: processObj[`${apiKey}_DEV`] ||
|
|
31
|
+
dev: processObj[`${apiKey}_DEV`] || window.location.origin,
|
|
32
32
|
test: processObj[`${apiKey}_TEST`] || window.location.origin,
|
|
33
33
|
stage: processObj[`${apiKey}_STAGE`] || window.location.origin,
|
|
34
34
|
prod: processObj[`${apiKey}_PROD`] || window.location.origin,
|
|
@@ -44,7 +44,7 @@ export function getBaseUrl(processObj: any, options?: IOptions) {
|
|
|
44
44
|
|
|
45
45
|
// file 服务器
|
|
46
46
|
const fileBaseUrlObj: any = {
|
|
47
|
-
dev: processObj[`${fileKey}_DEV`] ||
|
|
47
|
+
dev: processObj[`${fileKey}_DEV`] || window.location.origin,
|
|
48
48
|
test: processObj[`${fileKey}_TEST`] || window.location.origin,
|
|
49
49
|
stage: processObj[`${fileKey}_STAGE`] || window.location.origin,
|
|
50
50
|
prod: processObj[`${fileKey}_PROD`] || window.location.origin,
|
package/src/constants.ts
CHANGED
|
@@ -34,3 +34,7 @@ export const BASIC_KEY = (window as any).__BASIC_KEY__ || "cicoms";
|
|
|
34
34
|
|
|
35
35
|
// 附件相关服务
|
|
36
36
|
export const FILE_SERVICE = (window as any).__FILE_SERVICE__ || "cicoms";
|
|
37
|
+
|
|
38
|
+
// 默认的附件预览服务地址
|
|
39
|
+
export const FILE_PRVIEW_SERVICE_URL =
|
|
40
|
+
(window as any).__FILE_PRVIEW_SERVICE_URL__ || "";
|
package/src/file.ts
CHANGED
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
getFileExtension,
|
|
9
9
|
isImageExtension,
|
|
10
10
|
} from "./common";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
TOKEN_KEY,
|
|
13
|
+
BASIC_KEY,
|
|
14
|
+
FILE_SERVICE,
|
|
15
|
+
FILE_PRVIEW_SERVICE_URL,
|
|
16
|
+
} from "./constants";
|
|
12
17
|
import { AxiosResponse } from "axios";
|
|
13
18
|
import { Crypto } from "./crypto";
|
|
14
19
|
|
|
@@ -164,7 +169,10 @@ export function previewFile(
|
|
|
164
169
|
) {
|
|
165
170
|
const { API_BASEURL, authToken, fileList = [] } = options;
|
|
166
171
|
// 获取请求基础数据
|
|
167
|
-
const { token, apiBaseURL } = getBasicInfo(
|
|
172
|
+
const { token, apiBaseURL } = getBasicInfo(
|
|
173
|
+
FILE_PRVIEW_SERVICE_URL || API_BASEURL,
|
|
174
|
+
authToken
|
|
175
|
+
);
|
|
168
176
|
// 处理附件名中的一些特殊字符
|
|
169
177
|
let previewFileName = dangerouslyXss(fileName);
|
|
170
178
|
try {
|
|
@@ -182,7 +190,7 @@ export function previewFile(
|
|
|
182
190
|
if (!isZmdmsFileService) {
|
|
183
191
|
// 2023-12-30 修改成数字中心预览
|
|
184
192
|
window.open(
|
|
185
|
-
`${apiBaseURL}/api/cicoms-
|
|
193
|
+
`${apiBaseURL}/api/cicoms-resource/attach/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`
|
|
186
194
|
);
|
|
187
195
|
return;
|
|
188
196
|
}
|
|
@@ -330,7 +338,10 @@ export function createOriginalLink(
|
|
|
330
338
|
options: IOriginLinkOptions = {}
|
|
331
339
|
) {
|
|
332
340
|
const { API_BASEURL, authToken } = options;
|
|
333
|
-
const { token, apiBaseURL } = getBasicInfo(
|
|
341
|
+
const { token, apiBaseURL } = getBasicInfo(
|
|
342
|
+
FILE_PRVIEW_SERVICE_URL || API_BASEURL || "",
|
|
343
|
+
authToken
|
|
344
|
+
);
|
|
334
345
|
// 处理附件名中的一些特殊字符
|
|
335
346
|
let previewFileName = dangerouslyXss(fileName);
|
|
336
347
|
try {
|
|
@@ -346,7 +357,7 @@ export function createOriginalLink(
|
|
|
346
357
|
previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
|
|
347
358
|
// 2023-12-30 替换成数字中心的 预览接口
|
|
348
359
|
if (!isZmdmsFileService) {
|
|
349
|
-
return `${apiBaseURL}/api/cicoms-
|
|
360
|
+
return `${apiBaseURL}/api/cicoms-resource/attach/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`;
|
|
350
361
|
}
|
|
351
362
|
if (isZmdmsFileService) {
|
|
352
363
|
fileId = encodeFileId(fileId, 2);
|