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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getToken } from './auth.js';
2
- import { dangerouslyXss, specialString, getFileExtension, isImageExtension } from './common.js';
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, _a = options.fileList, fileList = _a === void 0 ? [] : _a;
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
- var isImage = isImageExtension(fileExtension);
131
- if (isImage) {
132
- var imgFiles = fileList.filter(function (item) {
133
- var attachName = item.attachName, attachId = item.attachId;
134
- var _a = getFileExtension(attachName), fileExtension = _a[1];
135
- if (isImageExtension(fileExtension) && attachId !== fileId) {
136
- return true;
137
- }
138
- return false;
139
- });
140
- var attachIds = imgFiles.map(function (item) { return item.attachId; }).join(",");
141
- // 批量图片预览
142
- window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&").concat(TOKEN_KEY, "=").concat(token) +
143
- (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
144
- }
145
- else {
146
- // 普通预览
147
- window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
148
- (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
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
- return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&").concat(TOKEN_KEY, "=").concat(token, "&officePreviewType=pdf") +
268
- (fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
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
- const imgFiles = fileList.filter((item) => {
175
- const { attachName, attachId } = item;
176
- const [, fileExtension] = getFileExtension(attachName);
177
- if (isImageExtension(fileExtension) && attachId !== fileId) {
178
- return true;
179
- }
180
- return false;
181
- });
182
- let attachIds = imgFiles.map((item) => item.attachId).join(",");
183
- // 批量图片预览
184
- window.open(
185
- `${apiBaseURL}/picturesAttchPreview?attachIds=${
186
- attachIds ? `${fileId},${attachIds}` : fileId
187
- }&${TOKEN_KEY}=${token}` +
188
- (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
189
- );
190
- } else {
191
- // 普通预览
192
- window.open(
193
- `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
194
- (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
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
- return (
320
- `${apiBaseURL}/attchPreview?attachId=${fileId}&${TOKEN_KEY}=${token}&officePreviewType=pdf` +
321
- (fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
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
  /**