@freelog/tools-lib 0.1.144 → 0.1.145
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/service-API/contracts.d.ts +18 -0
- package/dist/tools-lib.cjs.development.js +60 -42
- package/dist/tools-lib.cjs.development.js.map +1 -1
- package/dist/tools-lib.cjs.production.min.js +1 -1
- package/dist/tools-lib.cjs.production.min.js.map +1 -1
- package/dist/tools-lib.esm.js +60 -42
- package/dist/tools-lib.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/I18nNext.ts +2 -1
- package/src/service-API/contracts.ts +36 -0
- package/src/service-API/resources.ts +533 -533
- package/src/service-API/storages.ts +21 -21
- package/src/utils/axios.ts +51 -55
- package/src/utils/linkTo.ts +401 -401
|
@@ -9,7 +9,7 @@ export interface CreateBucketParamsType {
|
|
|
9
9
|
export function createBucket(params: CreateBucketParamsType) {
|
|
10
10
|
return FUtil.Request({
|
|
11
11
|
method: 'POST',
|
|
12
|
-
url: `/
|
|
12
|
+
url: `/v2/storages/buckets`,
|
|
13
13
|
data: params,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ interface BucketListParamsType {
|
|
|
22
22
|
export function bucketList(params: BucketListParamsType) {
|
|
23
23
|
return FUtil.Request({
|
|
24
24
|
method: 'GET',
|
|
25
|
-
url: `/
|
|
25
|
+
url: `/v2/storages/buckets`,
|
|
26
26
|
params: params,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -34,7 +34,7 @@ interface SpaceStatisticsParamsType {
|
|
|
34
34
|
export function spaceStatistics(params: SpaceStatisticsParamsType = {}) {
|
|
35
35
|
return FUtil.Request({
|
|
36
36
|
method: 'GET',
|
|
37
|
-
url: `/
|
|
37
|
+
url: `/v2/storages/buckets/spaceStatistics`,
|
|
38
38
|
params: params,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -47,7 +47,7 @@ interface DeleteBucketParamsType {
|
|
|
47
47
|
export function deleteBucket(params: DeleteBucketParamsType) {
|
|
48
48
|
return FUtil.Request({
|
|
49
49
|
method: 'DELETE',
|
|
50
|
-
url: `/
|
|
50
|
+
url: `/v2/storages/buckets/${params.bucketName}`,
|
|
51
51
|
// params: params,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
@@ -60,7 +60,7 @@ interface BucketDetailsParamsType {
|
|
|
60
60
|
export function bucketDetails({bucketName}: BucketDetailsParamsType) {
|
|
61
61
|
return FUtil.Request({
|
|
62
62
|
method: 'GET',
|
|
63
|
-
url: `/
|
|
63
|
+
url: `/v2/storages/buckets/${bucketName}`,
|
|
64
64
|
// params: params,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -81,7 +81,7 @@ interface ObjectListParamsType {
|
|
|
81
81
|
export function objectList({bucketName, ...params}: ObjectListParamsType) {
|
|
82
82
|
return FUtil.Request({
|
|
83
83
|
method: 'GET',
|
|
84
|
-
url: `/
|
|
84
|
+
url: `/v2/storages/buckets/${bucketName}/objects`,
|
|
85
85
|
params: params,
|
|
86
86
|
});
|
|
87
87
|
}
|
|
@@ -111,7 +111,7 @@ interface CreateObjectParamsType {
|
|
|
111
111
|
export function createObject({bucketName, ...params}: CreateObjectParamsType) {
|
|
112
112
|
return FUtil.Request({
|
|
113
113
|
method: 'POST',
|
|
114
|
-
url: `/
|
|
114
|
+
url: `/v2/storages/buckets/${bucketName}/objects`,
|
|
115
115
|
data: params,
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -130,13 +130,13 @@ export function objectDetails(params: ObjectDetailsParamsType1 | ObjectDetailsPa
|
|
|
130
130
|
if ((params as ObjectDetailsParamsType2).objectIdOrName) {
|
|
131
131
|
return FUtil.Request({
|
|
132
132
|
method: 'GET',
|
|
133
|
-
url: `/
|
|
133
|
+
url: `/v2/storages/objects/${encodeURIComponent((params as ObjectDetailsParamsType2).objectIdOrName)}`,
|
|
134
134
|
params: params,
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
return FUtil.Request({
|
|
138
138
|
method: 'GET',
|
|
139
|
-
url: `/
|
|
139
|
+
url: `/v2/storages/buckets/${(params as ObjectDetailsParamsType1).bucketName}/objects/${(params as ObjectDetailsParamsType1).objectId}`,
|
|
140
140
|
params: params,
|
|
141
141
|
});
|
|
142
142
|
}
|
|
@@ -150,7 +150,7 @@ interface DeleteObjectsParamsType {
|
|
|
150
150
|
export function deleteObjects(params: DeleteObjectsParamsType) {
|
|
151
151
|
return FUtil.Request({
|
|
152
152
|
method: 'DELETE',
|
|
153
|
-
url: `/
|
|
153
|
+
url: `/v2/storages/buckets/${params.bucketName}/objects/${params.objectIds}`,
|
|
154
154
|
data: params,
|
|
155
155
|
});
|
|
156
156
|
}
|
|
@@ -163,7 +163,7 @@ interface BucketIsExistParamsType {
|
|
|
163
163
|
export function bucketIsExist({bucketName}: BucketIsExistParamsType) {
|
|
164
164
|
return FUtil.Request({
|
|
165
165
|
method: 'GET',
|
|
166
|
-
url: `/
|
|
166
|
+
url: `/v2/storages/buckets/${bucketName}/isExist`,
|
|
167
167
|
// params: params,
|
|
168
168
|
});
|
|
169
169
|
}
|
|
@@ -174,7 +174,7 @@ interface DownloadObjectParamsType {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
export function downloadObject(params: DownloadObjectParamsType) {
|
|
177
|
-
return window.location.href = FUtil.Format.completeUrlByDomain('qi') + `/
|
|
177
|
+
return window.location.href = FUtil.Format.completeUrlByDomain('qi') + `/v2/storages/objects/${params.objectIdOrName}/file`;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// 根据sha1查询文件是否存在
|
|
@@ -185,7 +185,7 @@ interface FileIsExistParamsType {
|
|
|
185
185
|
export function fileIsExist(params: FileIsExistParamsType) {
|
|
186
186
|
return FUtil.Request({
|
|
187
187
|
method: 'GET',
|
|
188
|
-
url: `/
|
|
188
|
+
url: `/v2/storages/files/fileIsExist`,
|
|
189
189
|
params: params,
|
|
190
190
|
});
|
|
191
191
|
}
|
|
@@ -205,17 +205,17 @@ export function uploadFile(params: UploadFileParamsType, config?: AxiosRequestCo
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
if (!returnCancel) {
|
|
208
|
-
// return FUtil.Axios.post('/
|
|
208
|
+
// return FUtil.Axios.post('/v2/storages/files/upload', formData, config);
|
|
209
209
|
return FUtil.Request({
|
|
210
210
|
method: 'POST',
|
|
211
|
-
url: `/
|
|
211
|
+
url: `/v2/storages/files/upload`,
|
|
212
212
|
data: formData,
|
|
213
213
|
...config,
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
let cancel: any = null;
|
|
218
|
-
// const promise = FUtil.Axios.post('/
|
|
218
|
+
// const promise = FUtil.Axios.post('/v2/storages/files/upload', formData, {
|
|
219
219
|
// cancelToken: new FUtil.Axios.CancelToken((c) => {
|
|
220
220
|
// cancel = c;
|
|
221
221
|
// }),
|
|
@@ -223,7 +223,7 @@ export function uploadFile(params: UploadFileParamsType, config?: AxiosRequestCo
|
|
|
223
223
|
|
|
224
224
|
const promise = FUtil.Request({
|
|
225
225
|
method: 'POST',
|
|
226
|
-
url: `/
|
|
226
|
+
url: `/v2/storages/files/upload`,
|
|
227
227
|
data: formData,
|
|
228
228
|
cancelToken: new FUtil.Axios.CancelToken((c) => {
|
|
229
229
|
cancel = c;
|
|
@@ -251,7 +251,7 @@ export function uploadImage(params: UploadImageParamsType, config?: AxiosRequest
|
|
|
251
251
|
}
|
|
252
252
|
return FUtil.Request({
|
|
253
253
|
method: 'POST',
|
|
254
|
-
url: `/
|
|
254
|
+
url: `/v2/storages/files/uploadImage`,
|
|
255
255
|
data: formData,
|
|
256
256
|
...config,
|
|
257
257
|
});
|
|
@@ -293,7 +293,7 @@ interface BatchObjectListParamsType {
|
|
|
293
293
|
export function batchObjectList(params: BatchObjectListParamsType) {
|
|
294
294
|
return FUtil.Request({
|
|
295
295
|
method: 'GET',
|
|
296
|
-
url: `/
|
|
296
|
+
url: `/v2/storages/objects/list`,
|
|
297
297
|
params: params,
|
|
298
298
|
});
|
|
299
299
|
}
|
|
@@ -307,7 +307,7 @@ interface FilePropertyParamsType {
|
|
|
307
307
|
export function fileProperty({sha1, ...params}: FilePropertyParamsType) {
|
|
308
308
|
return FUtil.Request({
|
|
309
309
|
method: 'GET',
|
|
310
|
-
url: `/
|
|
310
|
+
url: `/v2/storages/files/${sha1}/property`,
|
|
311
311
|
params: params,
|
|
312
312
|
});
|
|
313
313
|
}
|
|
@@ -325,7 +325,7 @@ interface CycleDependencyCheckParamsType {
|
|
|
325
325
|
export function cycleDependencyCheck({objectIdOrName, ...params}: CycleDependencyCheckParamsType) {
|
|
326
326
|
return FUtil.Request({
|
|
327
327
|
method: 'POST',
|
|
328
|
-
url: `/
|
|
328
|
+
url: `/v2/storages/objects/${objectIdOrName}/cycleDependencyCheck`,
|
|
329
329
|
data: params,
|
|
330
330
|
});
|
|
331
331
|
}
|
package/src/utils/axios.ts
CHANGED
|
@@ -56,58 +56,63 @@ if (window.location.hostname.includes('.com')) {
|
|
|
56
56
|
// };
|
|
57
57
|
//
|
|
58
58
|
// // Add a request interceptor
|
|
59
|
-
axios.interceptors.request.use(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
axios.interceptors.request.use(
|
|
60
|
+
(config) => {
|
|
61
|
+
// Do something before request is sent
|
|
62
|
+
NProgress.start();
|
|
63
|
+
return config;
|
|
64
|
+
},
|
|
65
|
+
(error) => {
|
|
66
|
+
// Do something with request error
|
|
67
|
+
NProgress.done();
|
|
68
|
+
return Promise.reject(error);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* 配置request请求时的默认参数
|
|
71
74
|
*/
|
|
72
|
-
axios.interceptors.response.use(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
axios.interceptors.response.use(
|
|
76
|
+
(response) => {
|
|
77
|
+
// Do something with response data
|
|
78
|
+
// console.log(response, 'response!!!!!!');
|
|
79
|
+
NProgress.done();
|
|
80
|
+
if (response.status !== 200) {
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
const error = {
|
|
83
|
+
description: codeMessage[response.status],
|
|
84
|
+
message: response.status,
|
|
85
|
+
};
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
// notification.error(error);
|
|
88
|
+
throw new Error(JSON.stringify(error));
|
|
89
|
+
}
|
|
90
|
+
const {data, headers} = response;
|
|
91
|
+
if (headers['content-disposition']?.includes('attachment;')) {
|
|
92
|
+
// downloadFile(response);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
// console.log(data, 'data2390jasdflkf');
|
|
93
97
|
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
// if ((data.errcode === undefined
|
|
100
|
+
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
101
|
+
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
102
|
+
// || data.ret !== 0) {
|
|
103
|
+
//
|
|
104
|
+
// // notification.error({
|
|
105
|
+
// // message: data.msg,
|
|
106
|
+
// // });
|
|
107
|
+
// throw new Error(JSON.stringify(data));
|
|
108
|
+
// }
|
|
109
|
+
return data;
|
|
110
|
+
},
|
|
111
|
+
(error) => {
|
|
112
|
+
// Do something with response error
|
|
113
|
+
NProgress.done();
|
|
114
|
+
return Promise.reject(error);
|
|
115
|
+
});
|
|
111
116
|
|
|
112
117
|
export default axios;
|
|
113
118
|
|
|
@@ -125,21 +130,12 @@ export async function request(config: AxiosRequestConfig, {
|
|
|
125
130
|
if (result.ret === 0 && result.errCode === 30 && !noRedirect) {
|
|
126
131
|
await FServiceAPI.User.logout();
|
|
127
132
|
window.location.replace(`${completeUrlByDomain('user')}${LinkTo.login({goTo: window.location.href})}`);
|
|
128
|
-
}
|
|
129
|
-
if (result.ret === 4 && result.errCode === 10 && !noRedirect) {
|
|
133
|
+
} else if (result.ret === 4 && result.errCode === 10 && !noRedirect) {
|
|
130
134
|
window.location.replace(`${completeUrlByDomain('user')}${LinkTo.userFreeze({goTo: window.location.href})}`);
|
|
131
|
-
}
|
|
132
|
-
if ((result.errcode !== 0 || result.errCode !== 0) && !noErrorAlert) {
|
|
135
|
+
} else if ((result.errcode !== 0 || result.errCode !== 0) && !noErrorAlert) {
|
|
133
136
|
// window.alert(result.msg);
|
|
134
137
|
// return;
|
|
138
|
+
|
|
135
139
|
}
|
|
136
140
|
return result;
|
|
137
141
|
}
|
|
138
|
-
|
|
139
|
-
// export function downloadFile(res: AxiosResponse) {
|
|
140
|
-
// const {data, headers} = res;
|
|
141
|
-
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
142
|
-
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
143
|
-
// const blob = new Blob([data], {});
|
|
144
|
-
// FileSaver.saveAs(blob, fileName);
|
|
145
|
-
// }
|