zmdms-utils 0.0.30 → 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.
- package/dist/es/common.js +28 -12
- package/dist/es/constants.d.ts +3 -1
- package/dist/es/constants.js +7 -1
- package/dist/es/file.js +13 -12
- package/dist/es/request.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/common.ts +26 -12
- package/src/constants.ts +8 -0
- package/src/file.ts +13 -12
- package/src/index.ts +7 -1
- package/src/request.ts +2 -1
package/dist/es/common.js
CHANGED
|
@@ -70,23 +70,39 @@ function parseQueryParams(url) {
|
|
|
70
70
|
return {};
|
|
71
71
|
}
|
|
72
72
|
var queryString = url.split("?")[1];
|
|
73
|
-
var params = new URLSearchParams(queryString);
|
|
74
73
|
var result = {};
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
if (typeof URLSearchParams === "function") {
|
|
75
|
+
var params = new URLSearchParams(queryString);
|
|
76
|
+
params.forEach(function (value, key) {
|
|
77
|
+
var val = decodeURIComponent(value);
|
|
78
|
+
if (val.startsWith("{")) {
|
|
79
|
+
try {
|
|
80
|
+
val = JSON.parse(val);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
console.log("解析失败", err);
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
else if (val === "true" || val === "false") {
|
|
87
|
+
val = val === "true";
|
|
88
|
+
}
|
|
89
|
+
result[key] = val;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
try {
|
|
94
|
+
if (queryString) {
|
|
95
|
+
var searchList = queryString.split("&");
|
|
96
|
+
for (var i = 0; i < searchList.length; i++) {
|
|
97
|
+
var _a = searchList[i].split("="), key = _a[0], value = _a[1];
|
|
98
|
+
result[key] = value;
|
|
99
|
+
}
|
|
83
100
|
}
|
|
84
101
|
}
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
catch (err) {
|
|
103
|
+
console.log(err);
|
|
87
104
|
}
|
|
88
|
-
|
|
89
|
-
});
|
|
105
|
+
}
|
|
90
106
|
return result;
|
|
91
107
|
}
|
|
92
108
|
/**
|
package/dist/es/constants.d.ts
CHANGED
|
@@ -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 };
|
package/dist/es/constants.js
CHANGED
|
@@ -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/
|
|
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/
|
|
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/
|
|
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(
|
|
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, "&
|
|
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, "&
|
|
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/
|
|
218
|
+
return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/public/download-file/").concat(fileId);
|
|
218
219
|
}
|
|
219
|
-
return "".concat(apiBaseURL, "/api/
|
|
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, "&
|
|
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/
|
|
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/
|
|
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/
|
|
291
|
+
return "".concat(apiBaseURL, "/api/").concat(BASIC_KEY, "-resource/oss/endpoint/remove-file");
|
|
291
292
|
}
|
|
292
293
|
/**
|
|
293
294
|
* 获取基础数据
|
package/dist/es/request.js
CHANGED
|
@@ -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[
|
|
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
package/src/common.ts
CHANGED
|
@@ -75,21 +75,35 @@ export function parseQueryParams(url: string): { [key: string]: string } {
|
|
|
75
75
|
return {};
|
|
76
76
|
}
|
|
77
77
|
const queryString = url.split("?")[1];
|
|
78
|
-
const params = new URLSearchParams(queryString);
|
|
79
78
|
const result: { [key: string]: string } = {};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if (typeof URLSearchParams === "function") {
|
|
80
|
+
const params = new URLSearchParams(queryString);
|
|
81
|
+
params.forEach((value, key) => {
|
|
82
|
+
let val: any = decodeURIComponent(value);
|
|
83
|
+
if (val.startsWith("{")) {
|
|
84
|
+
try {
|
|
85
|
+
val = JSON.parse(val);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.log("解析失败", err);
|
|
88
|
+
}
|
|
89
|
+
} else if (val === "true" || val === "false") {
|
|
90
|
+
val = val === "true";
|
|
91
|
+
}
|
|
92
|
+
result[key] = val;
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
try {
|
|
96
|
+
if (queryString) {
|
|
97
|
+
const searchList = queryString.split("&");
|
|
98
|
+
for (let i = 0; i < searchList.length; i++) {
|
|
99
|
+
const [key, value] = searchList[i].split("=");
|
|
100
|
+
result[key] = value;
|
|
101
|
+
}
|
|
87
102
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
103
|
+
} catch (err) {
|
|
104
|
+
console.log(err);
|
|
90
105
|
}
|
|
91
|
-
|
|
92
|
-
});
|
|
106
|
+
}
|
|
93
107
|
return result;
|
|
94
108
|
}
|
|
95
109
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
}
|
|
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}
|
|
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
|
|
266
|
+
return `${apiBaseURL}/api/${BASIC_KEY}-resource/oss/endpoint/public/download-file/${fileId}`;
|
|
266
267
|
}
|
|
267
|
-
return `${apiBaseURL}/api
|
|
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}
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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[
|
|
249
|
+
newOptions.headers[TOKEN_KEY] = `bearer ${token}`;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
// 遍历params,将undefined值 转为null值
|