ztxkutils 2.6.10 → 2.7.0

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.
@@ -7,7 +7,10 @@ import { g as getToken } from './authority-fad2028d.js';
7
7
  function downloadFile(apiUrl, fileId, fileName, authToken) {
8
8
  var xhr = new XMLHttpRequest();
9
9
  var token = getToken() || authToken;
10
- xhr.open('GET', apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token, true);
10
+ var _apiUrl = apiUrl.endsWith('/')
11
+ ? apiUrl.slice(0, apiUrl.length - 1)
12
+ : apiUrl;
13
+ xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token, true);
11
14
  xhr.responseType = 'blob';
12
15
  xhr.onload = function () {
13
16
  if (xhr.status === 200 || xhr.status === 201) {
@@ -29,7 +32,10 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
29
32
  var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter;
30
33
  var xhr = new XMLHttpRequest();
31
34
  var token = getToken() || authToken;
32
- xhr.open('GET', apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token, true);
35
+ var _apiUrl = apiUrl.endsWith('/')
36
+ ? apiUrl.slice(0, apiUrl.length - 1)
37
+ : apiUrl;
38
+ xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token, true);
33
39
  xhr.responseType = 'blob';
34
40
  xhr.onload = function () {
35
41
  if (xhr.status === 200 || xhr.status === 201) {
@@ -57,7 +63,10 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
57
63
  function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
58
64
  var callbackAfter = (otherOption || {}).callbackAfter;
59
65
  var xhr = new XMLHttpRequest();
60
- xhr.open('GET', apiUrl + "/api/zmdms-resource/oss/endpoint/public/download-file/" + fileId, true);
66
+ var _apiUrl = apiUrl.endsWith('/')
67
+ ? apiUrl.slice(0, apiUrl.length - 1)
68
+ : apiUrl;
69
+ xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/public/download-file/" + fileId, true);
61
70
  xhr.responseType = 'blob';
62
71
  xhr.onload = function () {
63
72
  if (xhr.status === 200 || xhr.status === 201) {
@@ -83,7 +92,10 @@ function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
83
92
  */
84
93
  function createDownloadUrl(apiUrl, fileId, authToken) {
85
94
  var token = getToken() || authToken;
86
- return apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token;
95
+ var _apiUrl = apiUrl.endsWith('/')
96
+ ? apiUrl.slice(0, apiUrl.length - 1)
97
+ : apiUrl;
98
+ return _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token;
87
99
  }
88
100
  /**
89
101
  * @description 生成公共文件下载路径
@@ -91,7 +103,10 @@ function createDownloadUrl(apiUrl, fileId, authToken) {
91
103
  * @param {string} fileId 文件id
92
104
  */
93
105
  function createPublicDownloadUrl(apiUrl, fileId) {
94
- return apiUrl + "/api/zmdms-resource/oss/endpoint/public/download-file/" + fileId;
106
+ var _apiUrl = apiUrl.endsWith('/')
107
+ ? apiUrl.slice(0, apiUrl.length - 1)
108
+ : apiUrl;
109
+ return _apiUrl + "/api/zmdms-resource/oss/endpoint/public/download-file/" + fileId;
95
110
  }
96
111
  /**
97
112
  * @description 文件预览方法
@@ -109,8 +124,11 @@ function previewFile(fileUrl, fileId, otherOption) {
109
124
  token = getToken() || otherOption;
110
125
  }
111
126
  var titleName = otherOption === null || otherOption === void 0 ? void 0 : otherOption.titleName;
127
+ var _fileUrl = fileUrl.endsWith('/')
128
+ ? fileUrl.slice(0, fileUrl.length - 1)
129
+ : fileUrl;
112
130
  if (titleName) {
113
- window.open(fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token + "&titleName=" + encodeURIComponent(titleName));
131
+ window.open(_fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token + "&titleName=" + encodeURIComponent(titleName));
114
132
  }
115
133
  else {
116
134
  window.open(fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token);
@@ -125,11 +143,14 @@ function previewFile(fileUrl, fileId, otherOption) {
125
143
  function createOriginalUrl(fileUrl, fileId, otherOption) {
126
144
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
127
145
  var titleName = otherOption === null || otherOption === void 0 ? void 0 : otherOption.titleName;
146
+ var _fileUrl = fileUrl.endsWith('/')
147
+ ? fileUrl.slice(0, fileUrl.length - 1)
148
+ : fileUrl;
128
149
  if (titleName) {
129
- return fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token + "&titleName=" + encodeURIComponent(titleName);
150
+ return _fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token + "&titleName=" + encodeURIComponent(titleName);
130
151
  }
131
152
  else {
132
- return fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token;
153
+ return _fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token;
133
154
  }
134
155
  }
135
156
  /**
@@ -139,8 +160,11 @@ function createOriginalUrl(fileUrl, fileId, otherOption) {
139
160
  * @param {string} scale 缩略倍数
140
161
  */
141
162
  function createThumbnailUrl(apiUrl, fileId, scale, otherOption) {
163
+ var _apiUrl = apiUrl.endsWith('/')
164
+ ? apiUrl.slice(0, apiUrl.length - 1)
165
+ : apiUrl;
142
166
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
143
- return apiUrl + "/api/zmdms-resource/oss/endpoint/thumbnail/" + fileId + "?scale=" + scale + "&Zmdms-Auth=bearer " + token;
167
+ return _apiUrl + "/api/zmdms-resource/oss/endpoint/thumbnail/" + fileId + "?scale=" + scale + "&Zmdms-Auth=bearer " + token;
144
168
  }
145
169
 
146
170
  export { createDownloadUrl, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, previewFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.6.10",
3
+ "version": "2.7.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",