@freelog/tools-lib 0.1.87 → 0.1.91

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.
Files changed (36) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +103 -103
  3. package/dist/service-API/informalNodes.d.ts +15 -45
  4. package/dist/service-API/policies.d.ts +2 -6
  5. package/dist/tools-lib.cjs.development.js +342 -330
  6. package/dist/tools-lib.cjs.development.js.map +1 -1
  7. package/dist/tools-lib.cjs.production.min.js +1 -1
  8. package/dist/tools-lib.cjs.production.min.js.map +1 -1
  9. package/dist/tools-lib.esm.js +342 -330
  10. package/dist/tools-lib.esm.js.map +1 -1
  11. package/dist/utils/axios.d.ts +1 -4
  12. package/dist/utils/linkTo.d.ts +3 -0
  13. package/package.json +1 -1
  14. package/src/index.ts +7 -7
  15. package/src/service-API/activities.ts +28 -28
  16. package/src/service-API/captcha.ts +30 -30
  17. package/src/service-API/collections.ts +81 -81
  18. package/src/service-API/contracts.ts +84 -84
  19. package/src/service-API/events.ts +18 -18
  20. package/src/service-API/index.ts +29 -29
  21. package/src/service-API/informalNodes.ts +238 -238
  22. package/src/service-API/nodes.ts +65 -65
  23. package/src/service-API/policies.ts +39 -39
  24. package/src/service-API/presentables.ts +282 -282
  25. package/src/service-API/resources.ts +496 -496
  26. package/src/service-API/storages.ts +345 -345
  27. package/src/service-API/tools/index.ts +10 -10
  28. package/src/service-API/transactions.ts +109 -109
  29. package/src/service-API/user.ts +188 -188
  30. package/src/utils/axios.ts +8 -3
  31. package/src/utils/format.ts +89 -89
  32. package/src/utils/index.ts +18 -18
  33. package/src/utils/linkTo.ts +332 -324
  34. package/src/utils/predefined.ts +37 -37
  35. package/src/utils/regexp.ts +52 -52
  36. package/src/utils/tools.ts +72 -72
@@ -1048,106 +1048,113 @@ function market(_temp4) {
1048
1048
 
1049
1049
  return "/market";
1050
1050
  }
1051
- function resourceDetails(_ref6) {
1052
- var resourceID = _ref6.resourceID,
1053
- params = _objectWithoutPropertiesLoose(_ref6, _excluded);
1051
+ function exampleNodes(_temp5) {
1052
+ var _ref6 = _temp5 === void 0 ? {} : _temp5;
1054
1053
 
1055
- return "/resource/details/" + resourceID + handleQuery(params);
1056
- }
1057
- function resourceCreator(_temp5) {
1058
- var _ref7 = _temp5 === void 0 ? {} : _temp5;
1054
+ _objectDestructuringEmpty(_ref6);
1059
1055
 
1060
- _objectDestructuringEmpty(_ref7);
1056
+ return "/examples";
1057
+ }
1058
+ function resourceDetails(_ref7) {
1059
+ var resourceID = _ref7.resourceID,
1060
+ params = _objectWithoutPropertiesLoose(_ref7, _excluded);
1061
1061
 
1062
- return "/resource/creator";
1062
+ return "/resource/details/" + resourceID + handleQuery(params);
1063
1063
  }
1064
- function myResources(_temp6) {
1064
+ function resourceCreator(_temp6) {
1065
1065
  var _ref8 = _temp6 === void 0 ? {} : _temp6;
1066
1066
 
1067
1067
  _objectDestructuringEmpty(_ref8);
1068
1068
 
1069
- return "/resource/list";
1069
+ return "/resource/creator";
1070
1070
  }
1071
- function myCollects(_temp7) {
1071
+ function myResources(_temp7) {
1072
1072
  var _ref9 = _temp7 === void 0 ? {} : _temp7;
1073
1073
 
1074
1074
  _objectDestructuringEmpty(_ref9);
1075
1075
 
1076
+ return "/resource/list";
1077
+ }
1078
+ function myCollects(_temp8) {
1079
+ var _ref10 = _temp8 === void 0 ? {} : _temp8;
1080
+
1081
+ _objectDestructuringEmpty(_ref10);
1082
+
1076
1083
  return "/resource/collect";
1077
1084
  }
1078
- function resourceInfo(_ref10) {
1079
- var resourceID = _ref10.resourceID;
1085
+ function resourceInfo(_ref11) {
1086
+ var resourceID = _ref11.resourceID;
1080
1087
  return "/resource/info/" + resourceID;
1081
1088
  }
1082
- function resourceAuth(_ref11) {
1083
- var resourceID = _ref11.resourceID;
1089
+ function resourceAuth(_ref12) {
1090
+ var resourceID = _ref12.resourceID;
1084
1091
  return "/resource/auth/" + resourceID;
1085
1092
  }
1086
- function resourceCreateVersion(_ref12) {
1087
- var resourceID = _ref12.resourceID;
1093
+ function resourceCreateVersion(_ref13) {
1094
+ var resourceID = _ref13.resourceID;
1088
1095
  return "/resource/version/creator/" + resourceID;
1089
1096
  }
1090
- function resourceVersion(_ref13) {
1091
- var resourceID = _ref13.resourceID,
1092
- version = _ref13.version;
1097
+ function resourceVersion(_ref14) {
1098
+ var resourceID = _ref14.resourceID,
1099
+ version = _ref14.version;
1093
1100
  return "/resource/version/info/" + resourceID + "/" + version;
1094
1101
  }
1095
- function nodeCreator(_temp8) {
1096
- var _ref14 = _temp8 === void 0 ? {} : _temp8;
1102
+ function nodeCreator(_temp9) {
1103
+ var _ref15 = _temp9 === void 0 ? {} : _temp9;
1097
1104
 
1098
- _objectDestructuringEmpty(_ref14);
1105
+ _objectDestructuringEmpty(_ref15);
1099
1106
 
1100
1107
  return "/node/creator";
1101
1108
  }
1102
- function nodeManagement(_ref15) {
1103
- var nodeID = _ref15.nodeID;
1109
+ function nodeManagement(_ref16) {
1110
+ var nodeID = _ref16.nodeID;
1104
1111
  return "/node/formal/" + nodeID;
1105
1112
  }
1106
- function exhibitManagement(_ref16) {
1107
- var exhibitID = _ref16.exhibitID;
1113
+ function exhibitManagement(_ref17) {
1114
+ var exhibitID = _ref17.exhibitID;
1108
1115
  return "/node/exhibit/formal/" + exhibitID;
1109
1116
  }
1110
- function informNodeManagement(_ref17) {
1111
- var nodeID = _ref17.nodeID,
1112
- _ref17$showPage = _ref17.showPage,
1113
- showPage = _ref17$showPage === void 0 ? 'exhibit' : _ref17$showPage,
1114
- params = _objectWithoutPropertiesLoose(_ref17, _excluded2);
1117
+ function informNodeManagement(_ref18) {
1118
+ var nodeID = _ref18.nodeID,
1119
+ _ref18$showPage = _ref18.showPage,
1120
+ showPage = _ref18$showPage === void 0 ? 'exhibit' : _ref18$showPage,
1121
+ params = _objectWithoutPropertiesLoose(_ref18, _excluded2);
1115
1122
 
1116
1123
  return "/node/informal/" + nodeID + handleQuery(_extends({
1117
1124
  showPage: showPage
1118
1125
  }, params));
1119
1126
  }
1120
- function informExhibitManagement(_ref18) {
1121
- var exhibitID = _ref18.exhibitID;
1127
+ function informExhibitManagement(_ref19) {
1128
+ var exhibitID = _ref19.exhibitID;
1122
1129
  return "/node/exhibit/informal/" + exhibitID;
1123
1130
  }
1124
- function storageSpace(_temp9) {
1125
- var _ref19 = _temp9 === void 0 ? {} : _temp9,
1126
- params = _extends({}, _ref19);
1131
+ function storageSpace(_temp10) {
1132
+ var _ref20 = _temp10 === void 0 ? {} : _temp10,
1133
+ params = _extends({}, _ref20);
1127
1134
 
1128
1135
  return "/storage" + handleQuery(params);
1129
1136
  }
1130
- function objectDetails(_ref20) {
1131
- var params = _extends({}, _ref20);
1137
+ function objectDetails(_ref21) {
1138
+ var params = _extends({}, _ref21);
1132
1139
 
1133
1140
  return "/storage" + handleQuery(params);
1134
1141
  }
1135
- function resourceCreateSuccess(_ref21) {
1136
- var resourceID = _ref21.resourceID;
1142
+ function resourceCreateSuccess(_ref22) {
1143
+ var resourceID = _ref22.resourceID;
1137
1144
  return "/result/resource/create/success/" + resourceID;
1138
1145
  }
1139
- function resourceVersionCreateSuccess(_ref22) {
1140
- var resourceID = _ref22.resourceID,
1141
- version = _ref22.version;
1146
+ function resourceVersionCreateSuccess(_ref23) {
1147
+ var resourceID = _ref23.resourceID,
1148
+ version = _ref23.version;
1142
1149
  return "/result/resource/version/create/success/" + resourceID + "/" + version;
1143
1150
  }
1144
- function nodeCreateSuccess(_ref23) {
1145
- var nodeID = _ref23.nodeID;
1151
+ function nodeCreateSuccess(_ref24) {
1152
+ var nodeID = _ref24.nodeID;
1146
1153
  return "/result/node/create/success/" + nodeID;
1147
1154
  }
1148
- function exception403(_temp10) {
1149
- var _ref24 = _temp10 === void 0 ? {} : _temp10,
1150
- params = _extends({}, _ref24);
1155
+ function exception403(_temp11) {
1156
+ var _ref25 = _temp11 === void 0 ? {} : _temp11,
1157
+ params = _extends({}, _ref25);
1151
1158
 
1152
1159
  var fromUrl = params.from || '';
1153
1160
 
@@ -1162,56 +1169,56 @@ function exception403(_temp10) {
1162
1169
  from: fromUrl
1163
1170
  });
1164
1171
  }
1165
- function login(_temp11) {
1166
- var _ref25 = _temp11 === void 0 ? {} : _temp11,
1167
- goTo = _ref25.goTo;
1172
+ function login(_temp12) {
1173
+ var _ref26 = _temp12 === void 0 ? {} : _temp12,
1174
+ goTo = _ref26.goTo;
1168
1175
 
1169
1176
  return "/login" + handleQuery({
1170
1177
  goTo: goTo ? encodeURIComponent(goTo) : undefined
1171
1178
  });
1172
1179
  }
1173
- function logon(_temp12) {
1174
- var _ref26 = _temp12 === void 0 ? {} : _temp12,
1175
- goTo = _ref26.goTo;
1180
+ function logon(_temp13) {
1181
+ var _ref27 = _temp13 === void 0 ? {} : _temp13,
1182
+ goTo = _ref27.goTo;
1176
1183
 
1177
1184
  return "/logon" + handleQuery({
1178
1185
  goTo: goTo ? encodeURIComponent(goTo) : undefined
1179
1186
  });
1180
1187
  }
1181
- function retrieveUserPassword(_temp13) {
1182
- var _ref27 = _temp13 === void 0 ? {} : _temp13,
1183
- goTo = _ref27.goTo;
1188
+ function retrieveUserPassword(_temp14) {
1189
+ var _ref28 = _temp14 === void 0 ? {} : _temp14,
1190
+ goTo = _ref28.goTo;
1184
1191
 
1185
1192
  return "/retrieve" + handleQuery({
1186
1193
  goTo: goTo ? encodeURIComponent(goTo) : undefined
1187
1194
  });
1188
1195
  }
1189
- function retrievePayPassword(_temp14) {
1190
- var _ref28 = _temp14 === void 0 ? {} : _temp14;
1191
-
1192
- _objectDestructuringEmpty(_ref28);
1193
-
1194
- return "/retrievePayPassword";
1195
- }
1196
- function wallet(_temp15) {
1196
+ function retrievePayPassword(_temp15) {
1197
1197
  var _ref29 = _temp15 === void 0 ? {} : _temp15;
1198
1198
 
1199
1199
  _objectDestructuringEmpty(_ref29);
1200
1200
 
1201
- return "/logged/wallet";
1201
+ return "/retrievePayPassword";
1202
1202
  }
1203
- function contract(_temp16) {
1203
+ function wallet(_temp16) {
1204
1204
  var _ref30 = _temp16 === void 0 ? {} : _temp16;
1205
1205
 
1206
1206
  _objectDestructuringEmpty(_ref30);
1207
1207
 
1208
- return "/logged/contract";
1208
+ return "/logged/wallet";
1209
1209
  }
1210
- function setting(_temp17) {
1210
+ function contract(_temp17) {
1211
1211
  var _ref31 = _temp17 === void 0 ? {} : _temp17;
1212
1212
 
1213
1213
  _objectDestructuringEmpty(_ref31);
1214
1214
 
1215
+ return "/logged/contract";
1216
+ }
1217
+ function setting(_temp18) {
1218
+ var _ref32 = _temp18 === void 0 ? {} : _temp18;
1219
+
1220
+ _objectDestructuringEmpty(_ref32);
1221
+
1215
1222
  return "/logged/setting";
1216
1223
  }
1217
1224
  /************** user End ******************************************************/
@@ -1240,6 +1247,7 @@ var LinkTo = {
1240
1247
  activity: activity,
1241
1248
  dashboard: dashboard,
1242
1249
  market: market,
1250
+ exampleNodes: exampleNodes,
1243
1251
  resourceDetails: resourceDetails,
1244
1252
  resourceCreator: resourceCreator,
1245
1253
  myResources: myResources,
@@ -1302,265 +1310,19 @@ var EnumContractStatus;
1302
1310
  EnumContractStatus[EnumContractStatus["authorized"] = 1] = "authorized";
1303
1311
  EnumContractStatus[EnumContractStatus["stopped"] = 2] = "stopped";
1304
1312
  })(EnumContractStatus || (EnumContractStatus = {})); // 合约授权状态定义
1305
- // export enum ContractAuthStatus {
1306
- //
1307
- // }
1308
-
1309
- var Predefined = {
1310
- __proto__: null,
1311
- resourceTypes: resourceTypes,
1312
- pageSize: pageSize,
1313
- momentDateFormat: momentDateFormat,
1314
- momentDateTimeFormat: momentDateTimeFormat,
1315
- get EnumContractPartyIdentityType () { return EnumContractPartyIdentityType; },
1316
- get EnumSubjectType () { return EnumSubjectType; },
1317
- get EnumContractStatus () { return EnumContractStatus; }
1318
- };
1319
-
1320
- var codeMessage = {
1321
- 200: '服务器成功返回请求的数据。',
1322
- 201: '新建或修改数据成功。',
1323
- 202: '一个请求已经进入后台排队(异步任务)。',
1324
- 204: '删除数据成功。',
1325
- 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
1326
- 401: '用户没有权限(令牌、用户名、密码错误)。',
1327
- 403: '用户得到授权,但是访问是被禁止的。',
1328
- 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
1329
- 406: '请求的格式不可得。',
1330
- 410: '请求的资源被永久删除,且不会再得到的。',
1331
- 422: '当创建一个对象时,发生一个验证错误。',
1332
- 500: '服务器发生错误,请检查服务器。',
1333
- 502: '网关错误。',
1334
- 503: '服务不可用,服务器暂时过载或维护。',
1335
- 504: '网关超时。'
1336
- }; // export let apiHost: string = '';
1337
-
1338
- if (window.location.hostname.includes('.com')) {
1339
- // apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
1340
- // apiHost = window.location.origin.replace('console', 'qi');
1341
- axios.defaults.withCredentials = true;
1342
- axios.defaults.baseURL = /*#__PURE__*/completeUrlByDomain('qi');
1343
- }
1344
- /**
1345
- * 异常处理程序
1346
- */
1347
- // const errorHandler = (error: { response: Response }): Response => {
1348
- // const {response} = error;
1349
- // if (response && response.status) {
1350
- // const errorText = codeMessage[response.status] || response.statusText;
1351
- // const {status, url} = response;
1352
- //
1353
- // // notification.error({
1354
- // // message: `请求错误 ${status}: ${url}`,
1355
- // // description: errorText,
1356
- // // });
1357
- // } else if (!response) {
1358
- // // notification.error({
1359
- // // description: '您的网络发生异常,无法连接服务器',
1360
- // // message: '网络异常',
1361
- // // });
1362
- // }
1363
- // return response;
1364
- // };
1365
- //
1366
- // // Add a request interceptor
1367
-
1368
-
1369
- axios.interceptors.request.use(function (config) {
1370
- // Do something before request is sent
1371
- NProgress.start();
1372
- return config;
1373
- }, function (error) {
1374
- // Do something with request error
1375
- NProgress.done();
1376
- return Promise.reject(error);
1377
- });
1378
- /**
1379
- * 配置request请求时的默认参数
1380
- */
1381
-
1382
- axios.interceptors.response.use(function (response) {
1383
- var _headers$contentDisp;
1384
-
1385
- // Do something with response data
1386
- // console.log(response, 'response!!!!!!');
1387
- NProgress.done();
1388
-
1389
- if (response.status !== 200) {
1390
- var error = {
1391
- description: codeMessage[response.status],
1392
- message: response.status
1393
- }; // notification.error(error);
1394
-
1395
- throw new Error(JSON.stringify(error));
1396
- }
1397
-
1398
- var data = response.data,
1399
- headers = response.headers;
1400
-
1401
- if ((_headers$contentDisp = headers['content-disposition']) != null && _headers$contentDisp.includes('attachment;')) {
1402
- // downloadFile(response);
1403
- return;
1404
- } // console.log(data, 'data2390jasdflkf');
1405
- // if ((data.errcode === undefined
1406
- // ? (data.errCode !== 0 && data.errCode !== 2)
1407
- // : (data.errcode !== 0 && data.errcode !== 2))
1408
- // || data.ret !== 0) {
1409
- //
1410
- // // notification.error({
1411
- // // message: data.msg,
1412
- // // });
1413
- // throw new Error(JSON.stringify(data));
1414
- // }
1415
-
1416
-
1417
- return data;
1418
- }, function (error) {
1419
- // Do something with response error
1420
- NProgress.done();
1421
- return Promise.reject(error);
1422
- });
1423
- function request(_x, _x2) {
1424
- return _request.apply(this, arguments);
1425
- } // export function downloadFile(res: AxiosResponse) {
1426
- // const {data, headers} = res;
1427
- // // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
1428
- // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
1429
- // const blob = new Blob([data], {});
1430
- // FileSaver.saveAs(blob, fileName);
1431
- // }
1432
-
1433
- function _request() {
1434
- _request = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(config, _temp) {
1435
- var _ref, _ref$noRedirect, noRedirect, _ref$noErrorAlert, noErrorAlert, result;
1436
-
1437
- return runtime_1.wrap(function _callee$(_context) {
1438
- while (1) {
1439
- switch (_context.prev = _context.next) {
1440
- case 0:
1441
- _ref = _temp === void 0 ? {} : _temp, _ref$noRedirect = _ref.noRedirect, noRedirect = _ref$noRedirect === void 0 ? false : _ref$noRedirect, _ref$noErrorAlert = _ref.noErrorAlert, noErrorAlert = _ref$noErrorAlert === void 0 ? false : _ref$noErrorAlert;
1442
- _context.next = 3;
1443
- return axios.request(config);
1444
-
1445
- case 3:
1446
- result = _context.sent;
1447
-
1448
- if (!((result.errCode === 30 || result.errCode === 30) && !noRedirect)) {
1449
- _context.next = 6;
1450
- break;
1451
- }
1452
-
1453
- return _context.abrupt("return", window.location.replace("" + completeUrlByDomain('user') + login({
1454
- goTo: window.location.href
1455
- })));
1456
-
1457
- case 6:
1458
-
1459
- return _context.abrupt("return", result);
1460
-
1461
- case 8:
1462
- case "end":
1463
- return _context.stop();
1464
- }
1465
- }
1466
- }, _callee);
1467
- }));
1468
- return _request.apply(this, arguments);
1469
- }
1470
-
1471
- /**
1472
- * 根据 File 获取 SHA1 Hash 字符串
1473
- * @param file
1474
- * @return {Promise<string>}
1475
- */
1476
-
1477
- function getSHA1Hash(file) {
1478
- return new Promise(function (resolve) {
1479
- var reader = new FileReader();
1480
-
1481
- reader.onload = function () {
1482
- var wordArray = CryptoJS.lib.WordArray.create(reader.result);
1483
- var hash = CryptoJS.SHA1(wordArray).toString();
1484
- resolve(hash);
1485
- };
1486
-
1487
- reader.readAsArrayBuffer(file);
1488
- });
1489
- }
1490
- /**
1491
- * 生成随机码
1492
- */
1493
-
1494
- function generateRandomCode(strLen) {
1495
- if (strLen === void 0) {
1496
- strLen = 5;
1497
- }
1498
-
1499
- var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
1500
- var newStrArr = [];
1501
-
1502
- for (var i = 0; i < strLen; i++) {
1503
- newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
1504
- }
1505
-
1506
- return newStrArr.join('');
1507
- }
1508
- /**
1509
- * 通过读取 cookies 获取用户 ID
1510
- */
1511
-
1512
- function getUserIDByCookies() {
1513
- var uid = document.cookie.split('; ').find(function (co) {
1514
- return co.startsWith('uid=');
1515
- });
1516
-
1517
- if (!uid) {
1518
- return -1;
1519
- }
1520
-
1521
- return Number(uid.replace('uid=', ''));
1522
- }
1523
- function transformServerAPIContractState(_ref) {
1524
- var status = _ref.status,
1525
- authStatus = _ref.authStatus;
1526
-
1527
- if (status === 0) {
1528
- if (authStatus === 1 || authStatus === 3) {
1529
- return 'active';
1530
- }
1531
-
1532
- if (authStatus === 2) {
1533
- return 'testActive';
1534
- }
1535
-
1536
- if (authStatus === 128) {
1537
- return 'inactive';
1538
- }
1539
- }
1540
-
1541
- if (status === 1) {
1542
- return 'terminal';
1543
- }
1544
-
1545
- return 'exception';
1546
- }
1547
-
1548
- var Tool = {
1549
- __proto__: null,
1550
- getSHA1Hash: getSHA1Hash,
1551
- generateRandomCode: generateRandomCode,
1552
- getUserIDByCookies: getUserIDByCookies,
1553
- transformServerAPIContractState: transformServerAPIContractState
1554
- };
1555
-
1556
- var FUtil = {
1557
- Format: Format,
1558
- Regexp: Regexp,
1559
- LinkTo: LinkTo,
1560
- Predefined: Predefined,
1561
- Axios: axios,
1562
- Request: request,
1563
- Tool: Tool
1313
+ // export enum ContractAuthStatus {
1314
+ //
1315
+ // }
1316
+
1317
+ var Predefined = {
1318
+ __proto__: null,
1319
+ resourceTypes: resourceTypes,
1320
+ pageSize: pageSize,
1321
+ momentDateFormat: momentDateFormat,
1322
+ momentDateTimeFormat: momentDateTimeFormat,
1323
+ get EnumContractPartyIdentityType () { return EnumContractPartyIdentityType; },
1324
+ get EnumSubjectType () { return EnumSubjectType; },
1325
+ get EnumContractStatus () { return EnumContractStatus; }
1564
1326
  };
1565
1327
 
1566
1328
  function create(params) {
@@ -2857,6 +2619,256 @@ var FServiceAPI = {
2857
2619
  Activity: Activity
2858
2620
  };
2859
2621
 
2622
+ var codeMessage = {
2623
+ 200: '服务器成功返回请求的数据。',
2624
+ 201: '新建或修改数据成功。',
2625
+ 202: '一个请求已经进入后台排队(异步任务)。',
2626
+ 204: '删除数据成功。',
2627
+ 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
2628
+ 401: '用户没有权限(令牌、用户名、密码错误)。',
2629
+ 403: '用户得到授权,但是访问是被禁止的。',
2630
+ 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
2631
+ 406: '请求的格式不可得。',
2632
+ 410: '请求的资源被永久删除,且不会再得到的。',
2633
+ 422: '当创建一个对象时,发生一个验证错误。',
2634
+ 500: '服务器发生错误,请检查服务器。',
2635
+ 502: '网关错误。',
2636
+ 503: '服务不可用,服务器暂时过载或维护。',
2637
+ 504: '网关超时。'
2638
+ }; // export let apiHost: string = '';
2639
+
2640
+ if (window.location.hostname.includes('.com')) {
2641
+ // apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
2642
+ // apiHost = window.location.origin.replace('console', 'qi');
2643
+ axios.defaults.withCredentials = true;
2644
+ axios.defaults.baseURL = /*#__PURE__*/completeUrlByDomain('qi');
2645
+ }
2646
+ /**
2647
+ * 异常处理程序
2648
+ */
2649
+ // const errorHandler = (error: { response: Response }): Response => {
2650
+ // const {response} = error;
2651
+ // if (response && response.status) {
2652
+ // const errorText = codeMessage[response.status] || response.statusText;
2653
+ // const {status, url} = response;
2654
+ //
2655
+ // // notification.error({
2656
+ // // message: `请求错误 ${status}: ${url}`,
2657
+ // // description: errorText,
2658
+ // // });
2659
+ // } else if (!response) {
2660
+ // // notification.error({
2661
+ // // description: '您的网络发生异常,无法连接服务器',
2662
+ // // message: '网络异常',
2663
+ // // });
2664
+ // }
2665
+ // return response;
2666
+ // };
2667
+ //
2668
+ // // Add a request interceptor
2669
+
2670
+
2671
+ axios.interceptors.request.use(function (config) {
2672
+ // Do something before request is sent
2673
+ NProgress.start();
2674
+ return config;
2675
+ }, function (error) {
2676
+ // Do something with request error
2677
+ NProgress.done();
2678
+ return Promise.reject(error);
2679
+ });
2680
+ /**
2681
+ * 配置request请求时的默认参数
2682
+ */
2683
+
2684
+ axios.interceptors.response.use(function (response) {
2685
+ var _headers$contentDisp;
2686
+
2687
+ // Do something with response data
2688
+ // console.log(response, 'response!!!!!!');
2689
+ NProgress.done();
2690
+
2691
+ if (response.status !== 200) {
2692
+ var error = {
2693
+ description: codeMessage[response.status],
2694
+ message: response.status
2695
+ }; // notification.error(error);
2696
+
2697
+ throw new Error(JSON.stringify(error));
2698
+ }
2699
+
2700
+ var data = response.data,
2701
+ headers = response.headers;
2702
+
2703
+ if ((_headers$contentDisp = headers['content-disposition']) != null && _headers$contentDisp.includes('attachment;')) {
2704
+ // downloadFile(response);
2705
+ return;
2706
+ } // console.log(data, 'data2390jasdflkf');
2707
+ // if ((data.errcode === undefined
2708
+ // ? (data.errCode !== 0 && data.errCode !== 2)
2709
+ // : (data.errcode !== 0 && data.errcode !== 2))
2710
+ // || data.ret !== 0) {
2711
+ //
2712
+ // // notification.error({
2713
+ // // message: data.msg,
2714
+ // // });
2715
+ // throw new Error(JSON.stringify(data));
2716
+ // }
2717
+
2718
+
2719
+ return data;
2720
+ }, function (error) {
2721
+ // Do something with response error
2722
+ NProgress.done();
2723
+ return Promise.reject(error);
2724
+ });
2725
+ function request(_x, _x2) {
2726
+ return _request.apply(this, arguments);
2727
+ } // export function downloadFile(res: AxiosResponse) {
2728
+ // const {data, headers} = res;
2729
+ // // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
2730
+ // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
2731
+ // const blob = new Blob([data], {});
2732
+ // FileSaver.saveAs(blob, fileName);
2733
+ // }
2734
+
2735
+ function _request() {
2736
+ _request = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(config, _temp) {
2737
+ var _ref, _ref$noRedirect, noRedirect, _ref$noErrorAlert, noErrorAlert, result;
2738
+
2739
+ return runtime_1.wrap(function _callee$(_context) {
2740
+ while (1) {
2741
+ switch (_context.prev = _context.next) {
2742
+ case 0:
2743
+ _ref = _temp === void 0 ? {} : _temp, _ref$noRedirect = _ref.noRedirect, noRedirect = _ref$noRedirect === void 0 ? false : _ref$noRedirect, _ref$noErrorAlert = _ref.noErrorAlert, noErrorAlert = _ref$noErrorAlert === void 0 ? false : _ref$noErrorAlert;
2744
+ _context.next = 3;
2745
+ return axios.request(config);
2746
+
2747
+ case 3:
2748
+ result = _context.sent;
2749
+
2750
+ if (!((result.errCode === 30 || result.errCode === 30) && !noRedirect)) {
2751
+ _context.next = 8;
2752
+ break;
2753
+ }
2754
+
2755
+ _context.next = 7;
2756
+ return FServiceAPI.User.logout();
2757
+
2758
+ case 7:
2759
+ window.location.replace("" + completeUrlByDomain('user') + login({
2760
+ goTo: window.location.href
2761
+ }));
2762
+
2763
+ case 8:
2764
+
2765
+ return _context.abrupt("return", result);
2766
+
2767
+ case 10:
2768
+ case "end":
2769
+ return _context.stop();
2770
+ }
2771
+ }
2772
+ }, _callee);
2773
+ }));
2774
+ return _request.apply(this, arguments);
2775
+ }
2776
+
2777
+ /**
2778
+ * 根据 File 获取 SHA1 Hash 字符串
2779
+ * @param file
2780
+ * @return {Promise<string>}
2781
+ */
2782
+
2783
+ function getSHA1Hash(file) {
2784
+ return new Promise(function (resolve) {
2785
+ var reader = new FileReader();
2786
+
2787
+ reader.onload = function () {
2788
+ var wordArray = CryptoJS.lib.WordArray.create(reader.result);
2789
+ var hash = CryptoJS.SHA1(wordArray).toString();
2790
+ resolve(hash);
2791
+ };
2792
+
2793
+ reader.readAsArrayBuffer(file);
2794
+ });
2795
+ }
2796
+ /**
2797
+ * 生成随机码
2798
+ */
2799
+
2800
+ function generateRandomCode(strLen) {
2801
+ if (strLen === void 0) {
2802
+ strLen = 5;
2803
+ }
2804
+
2805
+ var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
2806
+ var newStrArr = [];
2807
+
2808
+ for (var i = 0; i < strLen; i++) {
2809
+ newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
2810
+ }
2811
+
2812
+ return newStrArr.join('');
2813
+ }
2814
+ /**
2815
+ * 通过读取 cookies 获取用户 ID
2816
+ */
2817
+
2818
+ function getUserIDByCookies() {
2819
+ var uid = document.cookie.split('; ').find(function (co) {
2820
+ return co.startsWith('uid=');
2821
+ });
2822
+
2823
+ if (!uid) {
2824
+ return -1;
2825
+ }
2826
+
2827
+ return Number(uid.replace('uid=', ''));
2828
+ }
2829
+ function transformServerAPIContractState(_ref) {
2830
+ var status = _ref.status,
2831
+ authStatus = _ref.authStatus;
2832
+
2833
+ if (status === 0) {
2834
+ if (authStatus === 1 || authStatus === 3) {
2835
+ return 'active';
2836
+ }
2837
+
2838
+ if (authStatus === 2) {
2839
+ return 'testActive';
2840
+ }
2841
+
2842
+ if (authStatus === 128) {
2843
+ return 'inactive';
2844
+ }
2845
+ }
2846
+
2847
+ if (status === 1) {
2848
+ return 'terminal';
2849
+ }
2850
+
2851
+ return 'exception';
2852
+ }
2853
+
2854
+ var Tool = {
2855
+ __proto__: null,
2856
+ getSHA1Hash: getSHA1Hash,
2857
+ generateRandomCode: generateRandomCode,
2858
+ getUserIDByCookies: getUserIDByCookies,
2859
+ transformServerAPIContractState: transformServerAPIContractState
2860
+ };
2861
+
2862
+ var FUtil = {
2863
+ Format: Format,
2864
+ Regexp: Regexp,
2865
+ LinkTo: LinkTo,
2866
+ Predefined: Predefined,
2867
+ Axios: axios,
2868
+ Request: request,
2869
+ Tool: Tool
2870
+ };
2871
+
2860
2872
  exports.FServiceAPI = FServiceAPI;
2861
2873
  exports.FUtil = FUtil;
2862
2874
  //# sourceMappingURL=tools-lib.cjs.development.js.map