zmdms-utils 0.0.51 → 0.0.52
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/file.js +35 -24
- package/package.json +1 -1
- package/src/file.ts +37 -29
package/dist/es/file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getToken } from './auth.js';
|
|
2
|
-
import { dangerouslyXss, specialString, getFileExtension
|
|
2
|
+
import { dangerouslyXss, specialString, getFileExtension } from './common.js';
|
|
3
3
|
import { BASIC_KEY, TOKEN_KEY } from './constants.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -109,7 +109,7 @@ function batchDownloadFiles(fileList, options) {
|
|
|
109
109
|
* @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
|
|
110
110
|
*/
|
|
111
111
|
function previewFile(fileId, fileName, options) {
|
|
112
|
-
var API_BASEURL = options.API_BASEURL, authToken = options.authToken
|
|
112
|
+
var API_BASEURL = options.API_BASEURL, authToken = options.authToken; options.fileList;
|
|
113
113
|
// 获取请求基础数据
|
|
114
114
|
var _b = getBasicInfo(API_BASEURL, authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
|
|
115
115
|
// 处理附件名中的一些特殊字符
|
|
@@ -126,27 +126,34 @@ function previewFile(fileId, fileName, options) {
|
|
|
126
126
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
127
127
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
128
128
|
previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
|
|
129
|
+
// 2023-12-30 修改成数字中心预览
|
|
130
|
+
window.open("".concat(apiBaseURL, "/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token));
|
|
129
131
|
// 如果是图片 走批量预览接口
|
|
130
|
-
|
|
131
|
-
if (isImage) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
// const isImage = isImageExtension(fileExtension);
|
|
133
|
+
// if (isImage) {
|
|
134
|
+
// const imgFiles = fileList.filter((item) => {
|
|
135
|
+
// const { attachName, attachId } = item;
|
|
136
|
+
// const [, fileExtension] = getFileExtension(attachName);
|
|
137
|
+
// if (isImageExtension(fileExtension) && attachId !== fileId) {
|
|
138
|
+
// return true;
|
|
139
|
+
// }
|
|
140
|
+
// return false;
|
|
141
|
+
// });
|
|
142
|
+
// let attachIds = imgFiles.map((item) => item.attachId).join(",");
|
|
143
|
+
// // 批量图片预览
|
|
144
|
+
// window.open(
|
|
145
|
+
// `${apiBaseURL}/picturesAttchPreview?attachIds=${
|
|
146
|
+
// attachIds ? `${fileId},${attachIds}` : fileId
|
|
147
|
+
// }&${TOKEN_KEY}=${token}` +
|
|
148
|
+
// (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
149
|
+
// );
|
|
150
|
+
// } else {
|
|
151
|
+
// // 普通预览
|
|
152
|
+
// window.open(
|
|
153
|
+
// `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
|
|
154
|
+
// (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
155
|
+
// );
|
|
156
|
+
// }
|
|
150
157
|
}
|
|
151
158
|
/**
|
|
152
159
|
* 导出一个文件流
|
|
@@ -264,8 +271,12 @@ function createOriginalLink(fileId, fileName, options) {
|
|
|
264
271
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
265
272
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
266
273
|
previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
|
|
267
|
-
|
|
268
|
-
|
|
274
|
+
// 2023-12-30 替换成数字中心的 预览接口
|
|
275
|
+
return "".concat(apiBaseURL, "/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token);
|
|
276
|
+
// return (
|
|
277
|
+
// `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
|
|
278
|
+
// (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
279
|
+
// );
|
|
269
280
|
}
|
|
270
281
|
/**
|
|
271
282
|
* 生成缩略图路径
|
package/package.json
CHANGED
package/src/file.ts
CHANGED
|
@@ -168,32 +168,38 @@ export function previewFile(
|
|
|
168
168
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
169
169
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
170
170
|
previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
|
|
171
|
+
|
|
172
|
+
// 2023-12-30 修改成数字中心预览
|
|
173
|
+
window.open(
|
|
174
|
+
`${apiBaseURL}/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`
|
|
175
|
+
);
|
|
176
|
+
|
|
171
177
|
// 如果是图片 走批量预览接口
|
|
172
|
-
const isImage = isImageExtension(fileExtension);
|
|
173
|
-
if (isImage) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
178
|
+
// const isImage = isImageExtension(fileExtension);
|
|
179
|
+
// if (isImage) {
|
|
180
|
+
// const imgFiles = fileList.filter((item) => {
|
|
181
|
+
// const { attachName, attachId } = item;
|
|
182
|
+
// const [, fileExtension] = getFileExtension(attachName);
|
|
183
|
+
// if (isImageExtension(fileExtension) && attachId !== fileId) {
|
|
184
|
+
// return true;
|
|
185
|
+
// }
|
|
186
|
+
// return false;
|
|
187
|
+
// });
|
|
188
|
+
// let attachIds = imgFiles.map((item) => item.attachId).join(",");
|
|
189
|
+
// // 批量图片预览
|
|
190
|
+
// window.open(
|
|
191
|
+
// `${apiBaseURL}/picturesAttchPreview?attachIds=${
|
|
192
|
+
// attachIds ? `${fileId},${attachIds}` : fileId
|
|
193
|
+
// }&${TOKEN_KEY}=${token}` +
|
|
194
|
+
// (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
195
|
+
// );
|
|
196
|
+
// } else {
|
|
197
|
+
// // 普通预览
|
|
198
|
+
// window.open(
|
|
199
|
+
// `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
|
|
200
|
+
// (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
201
|
+
// );
|
|
202
|
+
// }
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
/**
|
|
@@ -316,10 +322,12 @@ export function createOriginalLink(
|
|
|
316
322
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
317
323
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
318
324
|
previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
325
|
+
// 2023-12-30 替换成数字中心的 预览接口
|
|
326
|
+
return `${apiBaseURL}/api/cicoms-cicohr-org/cicomscicohr/v1/common/filePreview?attachId=${fileId}&${TOKEN_KEY}=${token}`;
|
|
327
|
+
// return (
|
|
328
|
+
// `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
|
|
329
|
+
// (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
330
|
+
// );
|
|
323
331
|
}
|
|
324
332
|
|
|
325
333
|
/**
|