@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.
@@ -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: `/v1/storages/buckets`,
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: `/v1/storages/buckets`,
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: `/v1/storages/buckets/spaceStatistics`,
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: `/v1/storages/buckets/${params.bucketName}`,
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: `/v1/storages/buckets/${bucketName}`,
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: `/v1/storages/buckets/${bucketName}/objects`,
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: `/v1/storages/buckets/${bucketName}/objects`,
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: `/v1/storages/objects/${encodeURIComponent((params as ObjectDetailsParamsType2).objectIdOrName)}`,
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: `/v1/storages/buckets/${(params as ObjectDetailsParamsType1).bucketName}/objects/${(params as ObjectDetailsParamsType1).objectId}`,
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: `/v1/storages/buckets/${params.bucketName}/objects/${params.objectIds}`,
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: `/v1/storages/buckets/${bucketName}/isExist`,
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') + `/v1/storages/objects/${params.objectIdOrName}/file`;
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: `/v1/storages/files/fileIsExist`,
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('/v1/storages/files/upload', formData, config);
208
+ // return FUtil.Axios.post('/v2/storages/files/upload', formData, config);
209
209
  return FUtil.Request({
210
210
  method: 'POST',
211
- url: `/v1/storages/files/upload`,
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('/v1/storages/files/upload', formData, {
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: `/v1/storages/files/upload`,
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: `/v1/storages/files/uploadImage`,
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: `/v1/storages/objects/list`,
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: `/v1/storages/files/${sha1}/property`,
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: `/v1/storages/objects/${objectIdOrName}/cycleDependencyCheck`,
328
+ url: `/v2/storages/objects/${objectIdOrName}/cycleDependencyCheck`,
329
329
  data: params,
330
330
  });
331
331
  }
@@ -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(function (config) {
60
- // Do something before request is sent
61
- NProgress.start();
62
- return config;
63
- }, function (error) {
64
- // Do something with request error
65
- NProgress.done();
66
- return Promise.reject(error);
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(function (response) {
73
- // Do something with response data
74
- // console.log(response, 'response!!!!!!');
75
- NProgress.done();
76
- if (response.status !== 200) {
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
- const error = {
79
- description: codeMessage[response.status],
80
- message: response.status,
81
- };
82
+ const error = {
83
+ description: codeMessage[response.status],
84
+ message: response.status,
85
+ };
82
86
 
83
- // notification.error(error);
84
- throw new Error(JSON.stringify(error));
85
- }
86
- const {data, headers} = response;
87
- if (headers['content-disposition']?.includes('attachment;')) {
88
- // downloadFile(response);
89
- return;
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
- // console.log(data, 'data2390jasdflkf');
96
+ // console.log(data, 'data2390jasdflkf');
93
97
 
94
98
 
95
- // if ((data.errcode === undefined
96
- // ? (data.errCode !== 0 && data.errCode !== 2)
97
- // : (data.errcode !== 0 && data.errcode !== 2))
98
- // || data.ret !== 0) {
99
- //
100
- // // notification.error({
101
- // // message: data.msg,
102
- // // });
103
- // throw new Error(JSON.stringify(data));
104
- // }
105
- return data;
106
- }, function (error) {
107
- // Do something with response error
108
- NProgress.done();
109
- return Promise.reject(error);
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
- // }