@freelog/tools-lib 0.1.65 → 0.1.69
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/informalNodes.d.ts +5 -0
- package/dist/tools-lib.cjs.development.js +88 -46
- 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 +88 -46
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/axios.d.ts +0 -3
- package/dist/utils/linkTo.d.ts +8 -4
- package/package.json +1 -1
- package/src/service-API/informalNodes.ts +14 -3
- package/src/utils/axios.ts +132 -149
- package/src/utils/linkTo.ts +14 -10
package/dist/utils/axios.d.ts
CHANGED
package/dist/utils/linkTo.d.ts
CHANGED
|
@@ -62,15 +62,19 @@ interface ObjectDetailsParamsType {
|
|
|
62
62
|
objectID: string;
|
|
63
63
|
}
|
|
64
64
|
export declare function objectDetails({ ...params }: ObjectDetailsParamsType): TReturnType;
|
|
65
|
-
interface
|
|
65
|
+
interface ResourceCreateSuccessParamsType {
|
|
66
66
|
resourceID: string;
|
|
67
67
|
}
|
|
68
|
-
export declare function resourceCreateSuccess({ resourceID }:
|
|
69
|
-
interface
|
|
68
|
+
export declare function resourceCreateSuccess({ resourceID }: ResourceCreateSuccessParamsType): string;
|
|
69
|
+
interface ResourceVersionCreateSuccessParamsType {
|
|
70
70
|
resourceID: string;
|
|
71
71
|
version: string;
|
|
72
72
|
}
|
|
73
|
-
export declare function resourceVersionCreateSuccess({ resourceID, version }:
|
|
73
|
+
export declare function resourceVersionCreateSuccess({ resourceID, version }: ResourceVersionCreateSuccessParamsType): string;
|
|
74
|
+
interface NodeCreateSuccessParamsType {
|
|
75
|
+
nodeID: number;
|
|
76
|
+
}
|
|
77
|
+
export declare function nodeCreateSuccess({ nodeID }: NodeCreateSuccessParamsType): string;
|
|
74
78
|
interface Exception403ParamsType {
|
|
75
79
|
from?: string;
|
|
76
80
|
}
|
package/package.json
CHANGED
|
@@ -199,7 +199,6 @@ interface RulesRematchParamsType {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
export function rulesRematch({nodeId, ...params}: RulesRematchParamsType) {
|
|
202
|
-
// return FUtil.Axios.post(`/v2/testNodes/${nodeId}/rules/rematch`, params);
|
|
203
202
|
return FUtil.Request({
|
|
204
203
|
method: 'POST',
|
|
205
204
|
url: `/v2/testNodes/${nodeId}/rules/rematch`,
|
|
@@ -207,6 +206,20 @@ export function rulesRematch({nodeId, ...params}: RulesRematchParamsType) {
|
|
|
207
206
|
});
|
|
208
207
|
}
|
|
209
208
|
|
|
209
|
+
// 节点测试规则预执行(不存档)
|
|
210
|
+
interface RulesPreExecutionParamsType {
|
|
211
|
+
nodeId: number;
|
|
212
|
+
testRuleText: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function rulesPreExecution({nodeId, ...params}: RulesPreExecutionParamsType) {
|
|
216
|
+
return FUtil.Request({
|
|
217
|
+
method: 'POST',
|
|
218
|
+
url: `/v2/testNodes/${nodeId}/rules/preExecution`,
|
|
219
|
+
data: params,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
210
223
|
// 批量获取测试资源授权结果
|
|
211
224
|
interface BatchGetAuthsParamsType {
|
|
212
225
|
nodeId: number;
|
|
@@ -215,10 +228,8 @@ interface BatchGetAuthsParamsType {
|
|
|
215
228
|
}
|
|
216
229
|
|
|
217
230
|
export function batchGetAuths({nodeId, ...params}: BatchGetAuthsParamsType) {
|
|
218
|
-
// return FUtil.Axios.post(`/v2/testNodes/${nodeId}/rules/rematch`, params);
|
|
219
231
|
return FUtil.Request({
|
|
220
232
|
method: 'GET',
|
|
221
|
-
// url: `/v2/auths/testResources/nodes/${nodeId}/result`,
|
|
222
233
|
url: `/v2/auths/exhibits/${nodeId}/test/batchAuth/results`,
|
|
223
234
|
params: params,
|
|
224
235
|
});
|
package/src/utils/axios.ts
CHANGED
|
@@ -1,149 +1,132 @@
|
|
|
1
|
-
import axios, {AxiosRequestConfig} from 'axios';
|
|
2
|
-
import NProgress from 'nprogress';
|
|
3
|
-
import "nprogress/nprogress.css";
|
|
4
|
-
import {completeUrlByDomain} from "./format";
|
|
5
|
-
import * as LinkTo from './linkTo';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// export let apiHost: string = '';
|
|
26
|
-
if (window.location.hostname.includes('.com')) {
|
|
27
|
-
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
28
|
-
// apiHost = window.location.origin.replace('console', 'qi');
|
|
29
|
-
axios.defaults.withCredentials = true;
|
|
30
|
-
axios.defaults.baseURL = completeUrlByDomain('qi');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 异常处理程序
|
|
35
|
-
*/
|
|
36
|
-
// const errorHandler = (error: { response: Response }): Response => {
|
|
37
|
-
// const {response} = error;
|
|
38
|
-
// if (response && response.status) {
|
|
39
|
-
// const errorText = codeMessage[response.status] || response.statusText;
|
|
40
|
-
// const {status, url} = response;
|
|
41
|
-
//
|
|
42
|
-
// // notification.error({
|
|
43
|
-
// // message: `请求错误 ${status}: ${url}`,
|
|
44
|
-
// // description: errorText,
|
|
45
|
-
// // });
|
|
46
|
-
// } else if (!response) {
|
|
47
|
-
// // notification.error({
|
|
48
|
-
// // description: '您的网络发生异常,无法连接服务器',
|
|
49
|
-
// // message: '网络异常',
|
|
50
|
-
// // });
|
|
51
|
-
// }
|
|
52
|
-
// return response;
|
|
53
|
-
// };
|
|
54
|
-
//
|
|
55
|
-
// // Add a request interceptor
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
// }
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
export
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const result: any = await axios.request(config);
|
|
134
|
-
// console.log(result, 'response');
|
|
135
|
-
// const {data} = response;
|
|
136
|
-
|
|
137
|
-
if ((result.errCode === 30 || result.errcode === 30) && !noRedirect) {
|
|
138
|
-
return window.location.replace(`${completeUrlByDomain('user')}${LinkTo.login({goTo: window.location.href})}`);
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// export function downloadFile(res: AxiosResponse) {
|
|
144
|
-
// const {data, headers} = res;
|
|
145
|
-
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
146
|
-
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
147
|
-
// const blob = new Blob([data], {});
|
|
148
|
-
// FileSaver.saveAs(blob, fileName);
|
|
149
|
-
// }
|
|
1
|
+
import axios, {AxiosRequestConfig} from 'axios';
|
|
2
|
+
import NProgress from 'nprogress';
|
|
3
|
+
import "nprogress/nprogress.css";
|
|
4
|
+
import {completeUrlByDomain} from "./format";
|
|
5
|
+
import * as LinkTo from './linkTo';
|
|
6
|
+
|
|
7
|
+
const codeMessage: any = {
|
|
8
|
+
200: '服务器成功返回请求的数据。',
|
|
9
|
+
201: '新建或修改数据成功。',
|
|
10
|
+
202: '一个请求已经进入后台排队(异步任务)。',
|
|
11
|
+
204: '删除数据成功。',
|
|
12
|
+
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
13
|
+
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
14
|
+
403: '用户得到授权,但是访问是被禁止的。',
|
|
15
|
+
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
16
|
+
406: '请求的格式不可得。',
|
|
17
|
+
410: '请求的资源被永久删除,且不会再得到的。',
|
|
18
|
+
422: '当创建一个对象时,发生一个验证错误。',
|
|
19
|
+
500: '服务器发生错误,请检查服务器。',
|
|
20
|
+
502: '网关错误。',
|
|
21
|
+
503: '服务不可用,服务器暂时过载或维护。',
|
|
22
|
+
504: '网关超时。',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// export let apiHost: string = '';
|
|
26
|
+
if (window.location.hostname.includes('.com')) {
|
|
27
|
+
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
28
|
+
// apiHost = window.location.origin.replace('console', 'qi');
|
|
29
|
+
axios.defaults.withCredentials = true;
|
|
30
|
+
axios.defaults.baseURL = completeUrlByDomain('qi');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 异常处理程序
|
|
35
|
+
*/
|
|
36
|
+
// const errorHandler = (error: { response: Response }): Response => {
|
|
37
|
+
// const {response} = error;
|
|
38
|
+
// if (response && response.status) {
|
|
39
|
+
// const errorText = codeMessage[response.status] || response.statusText;
|
|
40
|
+
// const {status, url} = response;
|
|
41
|
+
//
|
|
42
|
+
// // notification.error({
|
|
43
|
+
// // message: `请求错误 ${status}: ${url}`,
|
|
44
|
+
// // description: errorText,
|
|
45
|
+
// // });
|
|
46
|
+
// } else if (!response) {
|
|
47
|
+
// // notification.error({
|
|
48
|
+
// // description: '您的网络发生异常,无法连接服务器',
|
|
49
|
+
// // message: '网络异常',
|
|
50
|
+
// // });
|
|
51
|
+
// }
|
|
52
|
+
// return response;
|
|
53
|
+
// };
|
|
54
|
+
//
|
|
55
|
+
// // Add a request interceptor
|
|
56
|
+
axios.interceptors.request.use(function (config) {
|
|
57
|
+
// Do something before request is sent
|
|
58
|
+
NProgress.start();
|
|
59
|
+
return config;
|
|
60
|
+
}, function (error) {
|
|
61
|
+
// Do something with request error
|
|
62
|
+
NProgress.done();
|
|
63
|
+
return Promise.reject(error);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 配置request请求时的默认参数
|
|
68
|
+
*/
|
|
69
|
+
axios.interceptors.response.use(function (response) {
|
|
70
|
+
// Do something with response data
|
|
71
|
+
// console.log(response, 'response!!!!!!');
|
|
72
|
+
NProgress.done();
|
|
73
|
+
if (response.status !== 200) {
|
|
74
|
+
|
|
75
|
+
const error = {
|
|
76
|
+
description: codeMessage[response.status],
|
|
77
|
+
message: response.status,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// notification.error(error);
|
|
81
|
+
throw new Error(JSON.stringify(error));
|
|
82
|
+
}
|
|
83
|
+
const {data, headers} = response;
|
|
84
|
+
if (headers['content-disposition']?.includes('attachment;')) {
|
|
85
|
+
// downloadFile(response);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// console.log(data, 'data2390jasdflkf');
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// if ((data.errcode === undefined
|
|
93
|
+
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
94
|
+
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
95
|
+
// || data.ret !== 0) {
|
|
96
|
+
//
|
|
97
|
+
// // notification.error({
|
|
98
|
+
// // message: data.msg,
|
|
99
|
+
// // });
|
|
100
|
+
// throw new Error(JSON.stringify(data));
|
|
101
|
+
// }
|
|
102
|
+
return data;
|
|
103
|
+
}, function (error) {
|
|
104
|
+
// Do something with response error
|
|
105
|
+
NProgress.done();
|
|
106
|
+
return Promise.reject(error);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export default axios;
|
|
110
|
+
|
|
111
|
+
interface RequestParamsType {
|
|
112
|
+
noRedirect?: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function request(config: AxiosRequestConfig, {noRedirect = false}: RequestParamsType = {}) {
|
|
116
|
+
const result: any = await axios.request(config);
|
|
117
|
+
// console.log(result, 'response');
|
|
118
|
+
// const {data} = response;
|
|
119
|
+
|
|
120
|
+
if ((result.errCode === 30 || result.errcode === 30) && !noRedirect) {
|
|
121
|
+
return window.location.replace(`${completeUrlByDomain('user')}${LinkTo.login({goTo: window.location.href})}`);
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// export function downloadFile(res: AxiosResponse) {
|
|
127
|
+
// const {data, headers} = res;
|
|
128
|
+
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
129
|
+
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
130
|
+
// const blob = new Blob([data], {});
|
|
131
|
+
// FileSaver.saveAs(blob, fileName);
|
|
132
|
+
// }
|
package/src/utils/linkTo.ts
CHANGED
|
@@ -18,7 +18,6 @@ interface ResourceDetailsParamsType {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function resourceDetails({resourceID, ...params}: ResourceDetailsParamsType): TReturnType {
|
|
21
|
-
// return `/resource/${resourceID}`;
|
|
22
21
|
return `/resource/details/${resourceID}${handleQuery(params)}`;
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -153,24 +152,33 @@ export function objectDetails({...params}: ObjectDetailsParamsType): TReturnType
|
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
// 资源创建成功
|
|
156
|
-
interface
|
|
155
|
+
interface ResourceCreateSuccessParamsType {
|
|
157
156
|
resourceID: string;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
export function resourceCreateSuccess({resourceID}:
|
|
159
|
+
export function resourceCreateSuccess({resourceID}: ResourceCreateSuccessParamsType) {
|
|
161
160
|
return `/result/resource/create/success/${resourceID}`;
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
//
|
|
165
|
-
interface
|
|
163
|
+
// 资源版本创建成功
|
|
164
|
+
interface ResourceVersionCreateSuccessParamsType {
|
|
166
165
|
resourceID: string;
|
|
167
166
|
version: string;
|
|
168
167
|
}
|
|
169
168
|
|
|
170
|
-
export function resourceVersionCreateSuccess({resourceID, version}:
|
|
169
|
+
export function resourceVersionCreateSuccess({resourceID, version}: ResourceVersionCreateSuccessParamsType) {
|
|
171
170
|
return `/result/resource/version/create/success/${resourceID}/${version}`;
|
|
172
171
|
}
|
|
173
172
|
|
|
173
|
+
// 节点创建成功
|
|
174
|
+
interface NodeCreateSuccessParamsType {
|
|
175
|
+
nodeID: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function nodeCreateSuccess({nodeID}: NodeCreateSuccessParamsType) {
|
|
179
|
+
return `/result/node/create/success/${nodeID}`;
|
|
180
|
+
}
|
|
181
|
+
|
|
174
182
|
// 403
|
|
175
183
|
interface Exception403ParamsType {
|
|
176
184
|
from?: string;
|
|
@@ -178,16 +186,12 @@ interface Exception403ParamsType {
|
|
|
178
186
|
|
|
179
187
|
export function exception403({...params}: Exception403ParamsType = {}) {
|
|
180
188
|
|
|
181
|
-
// console.log(from, 'exception403!!!!!!!!');
|
|
182
|
-
|
|
183
189
|
let fromUrl: string = params.from || '';
|
|
184
190
|
if (!fromUrl) {
|
|
185
191
|
const {href, origin} = window.location;
|
|
186
192
|
fromUrl = href.replace(origin, '');
|
|
187
193
|
}
|
|
188
194
|
|
|
189
|
-
// console.log(fromUrl, 'fromUrl!!!!!!!!');
|
|
190
|
-
|
|
191
195
|
return `/exception/403${handleQuery({
|
|
192
196
|
from: fromUrl
|
|
193
197
|
})}`;
|