zmdms-utils 0.0.11 → 0.0.13
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.d.ts +4 -2
- package/dist/es/file.js +11 -14
- package/package.json +1 -1
- package/src/file.ts +13 -14
package/dist/es/file.d.ts
CHANGED
|
@@ -25,10 +25,11 @@ declare function batchDownloadFiles(fileList: {
|
|
|
25
25
|
}[], options: IBatchDownloadOptions): Promise<unknown>;
|
|
26
26
|
/**
|
|
27
27
|
* 附件预览。如果传入的附件是图片,那么实现批量预览
|
|
28
|
+
* 预览使用文件服务器baseURL
|
|
28
29
|
* @param fileId 附件id
|
|
29
30
|
* @param fileName 附件名称
|
|
30
31
|
* @param options
|
|
31
|
-
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传
|
|
32
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传(文件服务器baseURL)
|
|
32
33
|
* @param options.authToken {string} token 非必传
|
|
33
34
|
* @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
|
|
34
35
|
*/
|
|
@@ -44,10 +45,11 @@ declare function previewFile(fileId: string, fileName: string, options: IPreview
|
|
|
44
45
|
declare function createDownloadLink(fileId: string, options?: IDownloadLinkOptions): string;
|
|
45
46
|
/**
|
|
46
47
|
* 生成原始图片路径
|
|
48
|
+
* 预览使用文件服务器baseURL
|
|
47
49
|
* @param fileId 附件id
|
|
48
50
|
* @param fileName 附件名称
|
|
49
51
|
* @param options
|
|
50
|
-
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
52
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传(文件服务器baseURL)
|
|
51
53
|
* @param options.authToken {string} token 非必传
|
|
52
54
|
* @returns
|
|
53
55
|
*/
|
package/dist/es/file.js
CHANGED
|
@@ -42,7 +42,7 @@ function downloadFile(fileId, fileName, options) {
|
|
|
42
42
|
resolve({ msg: "文件下载成功!" });
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
reject();
|
|
45
|
+
reject(xhr.response);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
xhr.onerror = function (err) {
|
|
@@ -84,7 +84,7 @@ function batchDownloadFiles(fileList, options) {
|
|
|
84
84
|
resolve({ msg: "文件下载成功!" });
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
reject();
|
|
87
|
+
reject(xhr.response);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
xhr.onerror = function (err) {
|
|
@@ -99,10 +99,11 @@ function batchDownloadFiles(fileList, options) {
|
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* 附件预览。如果传入的附件是图片,那么实现批量预览
|
|
102
|
+
* 预览使用文件服务器baseURL
|
|
102
103
|
* @param fileId 附件id
|
|
103
104
|
* @param fileName 附件名称
|
|
104
105
|
* @param options
|
|
105
|
-
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传
|
|
106
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传(文件服务器baseURL)
|
|
106
107
|
* @param options.authToken {string} token 非必传
|
|
107
108
|
* @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
|
|
108
109
|
*/
|
|
@@ -137,16 +138,13 @@ function previewFile(fileId, fileName, options) {
|
|
|
137
138
|
});
|
|
138
139
|
var attachIds = imgFiles.map(function (item) { return item.attachId; }).join(",");
|
|
139
140
|
// 批量图片预览
|
|
140
|
-
window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&Zmdms-Auth=bearer ").concat(token) +
|
|
141
|
-
? "&titleName=".concat(encodeURIComponent(previewFileName))
|
|
142
|
-
: "");
|
|
141
|
+
window.open("".concat(apiBaseURL, "/picturesAttchPreview?attachIds=").concat(attachIds ? "".concat(fileId, ",").concat(attachIds) : fileId, "&Zmdms-Auth=bearer ").concat(token) +
|
|
142
|
+
(fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
145
145
|
// 普通预览
|
|
146
146
|
window.open("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=bearer ").concat(token, "&officePreviewType=pdf") +
|
|
147
|
-
fileName
|
|
148
|
-
? "&titleName=".concat(encodeURIComponent(previewFileName))
|
|
149
|
-
: "");
|
|
147
|
+
(fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
|
|
150
148
|
}
|
|
151
149
|
}
|
|
152
150
|
/**
|
|
@@ -168,10 +166,11 @@ function createDownloadLink(fileId, options) {
|
|
|
168
166
|
}
|
|
169
167
|
/**
|
|
170
168
|
* 生成原始图片路径
|
|
169
|
+
* 预览使用文件服务器baseURL
|
|
171
170
|
* @param fileId 附件id
|
|
172
171
|
* @param fileName 附件名称
|
|
173
172
|
* @param options
|
|
174
|
-
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
173
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传(文件服务器baseURL)
|
|
175
174
|
* @param options.authToken {string} token 非必传
|
|
176
175
|
* @returns
|
|
177
176
|
*/
|
|
@@ -193,10 +192,8 @@ function createOriginalLink(fileId, fileName, options) {
|
|
|
193
192
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
194
193
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
195
194
|
previewFileName = "".concat(filePreName, "-").concat(fileId, ".").concat(fileExtension);
|
|
196
|
-
return "".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=bearer ").concat(token, "&officePreviewType=pdf") +
|
|
197
|
-
fileName
|
|
198
|
-
? "&titleName=".concat(encodeURIComponent(previewFileName))
|
|
199
|
-
: "";
|
|
195
|
+
return ("".concat(apiBaseURL, "/attchPreview?attachId=").concat(fileId, "&Zmdms-Auth=bearer ").concat(token, "&officePreviewType=pdf") +
|
|
196
|
+
(fileName ? "&titleName=".concat(encodeURIComponent(previewFileName)) : ""));
|
|
200
197
|
}
|
|
201
198
|
/**
|
|
202
199
|
* 生成缩略图路径
|
package/package.json
CHANGED
package/src/file.ts
CHANGED
|
@@ -62,7 +62,7 @@ export function downloadFile(
|
|
|
62
62
|
|
|
63
63
|
resolve({ msg: "文件下载成功!" });
|
|
64
64
|
} else {
|
|
65
|
-
reject();
|
|
65
|
+
reject(xhr.response);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
xhr.onerror = function (err) {
|
|
@@ -119,7 +119,7 @@ export function batchDownloadFiles(
|
|
|
119
119
|
|
|
120
120
|
resolve({ msg: "文件下载成功!" });
|
|
121
121
|
} else {
|
|
122
|
-
reject();
|
|
122
|
+
reject(xhr.response);
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
xhr.onerror = function (err) {
|
|
@@ -137,10 +137,11 @@ export function batchDownloadFiles(
|
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* 附件预览。如果传入的附件是图片,那么实现批量预览
|
|
140
|
+
* 预览使用文件服务器baseURL
|
|
140
141
|
* @param fileId 附件id
|
|
141
142
|
* @param fileName 附件名称
|
|
142
143
|
* @param options
|
|
143
|
-
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传
|
|
144
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 必传(文件服务器baseURL)
|
|
144
145
|
* @param options.authToken {string} token 非必传
|
|
145
146
|
* @param options.fileList { attachId: string, attachName: string ... }[] 附件列表。批量预览时有用
|
|
146
147
|
*/
|
|
@@ -181,17 +182,14 @@ export function previewFile(
|
|
|
181
182
|
window.open(
|
|
182
183
|
`${apiBaseURL}/picturesAttchPreview?attachIds=${
|
|
183
184
|
attachIds ? `${fileId},${attachIds}` : fileId
|
|
184
|
-
}&Zmdms-Auth=bearer ${token}` +
|
|
185
|
-
? `&titleName=${encodeURIComponent(previewFileName)}`
|
|
186
|
-
: ""
|
|
185
|
+
}&Zmdms-Auth=bearer ${token}` +
|
|
186
|
+
(fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
187
187
|
);
|
|
188
188
|
} else {
|
|
189
189
|
// 普通预览
|
|
190
190
|
window.open(
|
|
191
191
|
`${apiBaseURL}/attchPreview?attachId=${fileId}&Zmdms-Auth=bearer ${token}&officePreviewType=pdf` +
|
|
192
|
-
fileName
|
|
193
|
-
? `&titleName=${encodeURIComponent(previewFileName)}`
|
|
194
|
-
: ""
|
|
192
|
+
(fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
195
193
|
);
|
|
196
194
|
}
|
|
197
195
|
}
|
|
@@ -218,10 +216,11 @@ export function createDownloadLink(
|
|
|
218
216
|
|
|
219
217
|
/**
|
|
220
218
|
* 生成原始图片路径
|
|
219
|
+
* 预览使用文件服务器baseURL
|
|
221
220
|
* @param fileId 附件id
|
|
222
221
|
* @param fileName 附件名称
|
|
223
222
|
* @param options
|
|
224
|
-
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
223
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传(文件服务器baseURL)
|
|
225
224
|
* @param options.authToken {string} token 非必传
|
|
226
225
|
* @returns
|
|
227
226
|
*/
|
|
@@ -245,10 +244,10 @@ export function createOriginalLink(
|
|
|
245
244
|
// 如果文件名没变,文件内容改变。这样就会导致再次预览时 内容不会更新
|
|
246
245
|
// 所以将文件名 与 文件id组合来生成不同的文件名
|
|
247
246
|
previewFileName = `${filePreName}-${fileId}.${fileExtension}`;
|
|
248
|
-
return
|
|
249
|
-
|
|
250
|
-
? `&titleName=${encodeURIComponent(previewFileName)}`
|
|
251
|
-
|
|
247
|
+
return (
|
|
248
|
+
`${apiBaseURL}/attchPreview?attachId=${fileId}&Zmdms-Auth=bearer ${token}&officePreviewType=pdf` +
|
|
249
|
+
(fileName ? `&titleName=${encodeURIComponent(previewFileName)}` : "")
|
|
250
|
+
);
|
|
252
251
|
}
|
|
253
252
|
|
|
254
253
|
/**
|