@freelog/tools-lib 0.1.65 → 0.1.66
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/tools-lib.cjs.development.js +60 -29
- 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 -29
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/axios.d.ts +0 -3
- package/package.json +1 -1
- package/src/utils/axios.ts +132 -149
|
@@ -1274,23 +1274,23 @@ var Predefined = {
|
|
|
1274
1274
|
get EnumContractStatus () { return EnumContractStatus; }
|
|
1275
1275
|
};
|
|
1276
1276
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
// export let apiHost: string = '';
|
|
1277
|
+
var codeMessage = {
|
|
1278
|
+
200: '服务器成功返回请求的数据。',
|
|
1279
|
+
201: '新建或修改数据成功。',
|
|
1280
|
+
202: '一个请求已经进入后台排队(异步任务)。',
|
|
1281
|
+
204: '删除数据成功。',
|
|
1282
|
+
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
1283
|
+
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
1284
|
+
403: '用户得到授权,但是访问是被禁止的。',
|
|
1285
|
+
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
1286
|
+
406: '请求的格式不可得。',
|
|
1287
|
+
410: '请求的资源被永久删除,且不会再得到的。',
|
|
1288
|
+
422: '当创建一个对象时,发生一个验证错误。',
|
|
1289
|
+
500: '服务器发生错误,请检查服务器。',
|
|
1290
|
+
502: '网关错误。',
|
|
1291
|
+
503: '服务不可用,服务器暂时过载或维护。',
|
|
1292
|
+
504: '网关超时。'
|
|
1293
|
+
}; // export let apiHost: string = '';
|
|
1294
1294
|
|
|
1295
1295
|
if (window.location.hostname.includes('.com')) {
|
|
1296
1296
|
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
@@ -1321,28 +1321,59 @@ if (window.location.hostname.includes('.com')) {
|
|
|
1321
1321
|
// };
|
|
1322
1322
|
//
|
|
1323
1323
|
// // Add a request interceptor
|
|
1324
|
-
// axios.interceptors.request.use(function (config) {
|
|
1325
|
-
// // Do something before request is sent
|
|
1326
|
-
// NProgress.start();
|
|
1327
|
-
// return config;
|
|
1328
|
-
// }, function (error) {
|
|
1329
|
-
// // Do something with request error
|
|
1330
|
-
// NProgress.done();
|
|
1331
|
-
// return Promise.reject(error);
|
|
1332
|
-
// });
|
|
1333
1324
|
|
|
1334
1325
|
|
|
1335
1326
|
axios.interceptors.request.use(function (config) {
|
|
1336
|
-
|
|
1327
|
+
// Do something before request is sent
|
|
1328
|
+
NProgress.start();
|
|
1337
1329
|
return config;
|
|
1338
1330
|
}, function (error) {
|
|
1331
|
+
// Do something with request error
|
|
1339
1332
|
NProgress.done();
|
|
1340
1333
|
return Promise.reject(error);
|
|
1341
1334
|
});
|
|
1342
|
-
|
|
1335
|
+
/**
|
|
1336
|
+
* 配置request请求时的默认参数
|
|
1337
|
+
*/
|
|
1338
|
+
|
|
1339
|
+
axios.interceptors.response.use(function (response) {
|
|
1340
|
+
var _headers$contentDisp;
|
|
1341
|
+
|
|
1342
|
+
// Do something with response data
|
|
1343
|
+
// console.log(response, 'response!!!!!!');
|
|
1343
1344
|
NProgress.done();
|
|
1344
|
-
|
|
1345
|
+
|
|
1346
|
+
if (response.status !== 200) {
|
|
1347
|
+
var error = {
|
|
1348
|
+
description: codeMessage[response.status],
|
|
1349
|
+
message: response.status
|
|
1350
|
+
}; // notification.error(error);
|
|
1351
|
+
|
|
1352
|
+
throw new Error(JSON.stringify(error));
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
var data = response.data,
|
|
1356
|
+
headers = response.headers;
|
|
1357
|
+
|
|
1358
|
+
if ((_headers$contentDisp = headers['content-disposition']) != null && _headers$contentDisp.includes('attachment;')) {
|
|
1359
|
+
// downloadFile(response);
|
|
1360
|
+
return;
|
|
1361
|
+
} // console.log(data, 'data2390jasdflkf');
|
|
1362
|
+
// if ((data.errcode === undefined
|
|
1363
|
+
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
1364
|
+
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
1365
|
+
// || data.ret !== 0) {
|
|
1366
|
+
//
|
|
1367
|
+
// // notification.error({
|
|
1368
|
+
// // message: data.msg,
|
|
1369
|
+
// // });
|
|
1370
|
+
// throw new Error(JSON.stringify(data));
|
|
1371
|
+
// }
|
|
1372
|
+
|
|
1373
|
+
|
|
1374
|
+
return data;
|
|
1345
1375
|
}, function (error) {
|
|
1376
|
+
// Do something with response error
|
|
1346
1377
|
NProgress.done();
|
|
1347
1378
|
return Promise.reject(error);
|
|
1348
1379
|
});
|