@indfnd/utils 0.0.31 → 0.0.33

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/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.33](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.32...v0.0.33) (2024-01-31)
6
+
7
+
8
+ ### Features
9
+
10
+ * **uuid:** 增加和后端uuid格式一致的方法 ([3e6805e](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/3e6805eed46b856816c235884eea356c4a4a7d1a))
11
+
12
+ ### [0.0.32](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.31...v0.0.32) (2024-01-27)
13
+
14
+
15
+ ### Features
16
+
17
+ * **request:** 请求超时和状态码非200增加提示 ([8742d1f](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/8742d1fd149801f909722bd1f51c67b5cea8c100))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **date:** 日期格式化函数判断格式 ([bfa032d](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/bfa032d682514d5104abe068a7cc8d00891cad94))
23
+
5
24
  ### [0.0.31](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.30...v0.0.31) (2024-01-24)
6
25
 
7
26
  ### [0.0.30](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.29...v0.0.30) (2024-01-24)
@@ -3319,6 +3319,12 @@ function responseInterceptors(response) {
3319
3319
  return Promise.reject(data);
3320
3320
  }
3321
3321
  function inspectorError(error) {
3322
+ if ((error == null ? void 0 : error.code) === "ECONNABORTED") {
3323
+ window.apiErrorHandler && window.apiErrorHandler("\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
3324
+ }
3325
+ if (error.response.status !== 200) {
3326
+ window.apiErrorHandler && window.apiErrorHandler("\u8BF7\u6C42\u51FA\u9519\u4E86");
3327
+ }
3322
3328
  return Promise.reject(error);
3323
3329
  }
3324
3330
  const instance = axios.create({ timeout: 60 * 1e3 });
@@ -4023,7 +4029,7 @@ function str2Date(value) {
4023
4029
  }
4024
4030
  }
4025
4031
  function formatDate(value) {
4026
- if (value) {
4032
+ if (value && /^[0-9]+$/.test(value)) {
4027
4033
  switch (value.length) {
4028
4034
  case 14: {
4029
4035
  return dayjs(value, ["YYYYMMDDHHmmss"]).format("YYYY-MM-DD HH:mm:ss");
@@ -4042,11 +4048,11 @@ function formatDate(value) {
4042
4048
  }
4043
4049
  }
4044
4050
  } else {
4045
- return "-";
4051
+ return value || "-";
4046
4052
  }
4047
4053
  }
4048
4054
  function formatDateChinese(value) {
4049
- if (value) {
4055
+ if (value && /^[0-9]+$/.test(value)) {
4050
4056
  switch (value.length) {
4051
4057
  case 14: {
4052
4058
  return dayjs(value, ["YYYYMMDDHHmmss"]).format("YYYY\u5E74MM\u6708DD\u65E5 HH:mm:ss");
@@ -4065,7 +4071,7 @@ function formatDateChinese(value) {
4065
4071
  }
4066
4072
  }
4067
4073
  } else {
4068
- return "-";
4074
+ return value || "-";
4069
4075
  }
4070
4076
  }
4071
4077
  const toString2 = {}.toString;
@@ -8638,7 +8644,7 @@ var lodash = { exports: {} };
8638
8644
  number = toNumber(number);
8639
8645
  return baseInRange(number, start, end);
8640
8646
  }
8641
- function random(lower, upper, floating) {
8647
+ function random2(lower, upper, floating) {
8642
8648
  if (floating && typeof floating != "boolean" && isIterateeCall(lower, upper, floating)) {
8643
8649
  upper = floating = undefined$12;
8644
8650
  }
@@ -9392,7 +9398,7 @@ var lodash = { exports: {} };
9392
9398
  lodash2.padEnd = padEnd;
9393
9399
  lodash2.padStart = padStart;
9394
9400
  lodash2.parseInt = parseInt2;
9395
- lodash2.random = random;
9401
+ lodash2.random = random2;
9396
9402
  lodash2.reduce = reduce;
9397
9403
  lodash2.reduceRight = reduceRight;
9398
9404
  lodash2.repeat = repeat2;
@@ -10591,6 +10597,25 @@ function flattenRow2ColumnData(data = [], columns = [], option = {}) {
10591
10597
  []
10592
10598
  );
10593
10599
  }
10600
+ let random = (bytes) => crypto.getRandomValues(new Uint8Array(bytes));
10601
+ let customRandom = (alphabet, defaultSize, getRandom) => {
10602
+ let mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1;
10603
+ let step = -~(1.6 * mask * defaultSize / alphabet.length);
10604
+ return (size = defaultSize) => {
10605
+ let id = "";
10606
+ while (true) {
10607
+ let bytes = getRandom(step);
10608
+ let j = step;
10609
+ while (j--) {
10610
+ id += alphabet[bytes[j] & mask] || "";
10611
+ if (id.length === size)
10612
+ return id;
10613
+ }
10614
+ }
10615
+ };
10616
+ };
10617
+ let customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
10618
+ const uuid = customAlphabet("0123456789abcdef", 32);
10594
10619
  function guid() {
10595
10620
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
10596
10621
  var r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
@@ -10828,4 +10853,4 @@ const UC_CONTEXT = config.ucExtServerContext;
10828
10853
  function listUserTreeApi(params) {
10829
10854
  return instance.get(`${UC_CONTEXT}/tree/uc-user/listUserTree`, { params });
10830
10855
  }
10831
- export { CONTENT_TYPE, IS_OR_NOT_ENUM, IS_OR_NOT_ENUM_KEY, IS_OR_NOT_ENUM_LIST, MIME_TYPE, UC_ENUM, addMenuCollectApi, instance as axios, checkIdCard, checkPhone, checkTel, checkVehicleNo, clearPermissionCache, clearSessionStorage, clearUserInfoCache, config, cryptor, deleteMenuCollectApi, deleteMenuHistoryApi, exportJsonToExcel, flattenRow2ColumnData, formatDate, formatDateChinese, formatDecimal, formatHalfYear, formatQuarter, getAppListApi, getCaptchaURL, getContentType, getDictApi, getDictMapApi, getDictsMapApi, getExcelColumnIdx, getGlobalPolicyApi, getHalfYear, getHalfYearBeginMonth, getHalfYearEndMonth, getHalfYearNum, getItem, getLocalStorage, getMaxTabNumValueApi, getMenuCollectApi, getMenuHistoryApi, getOssFileApi, getPermissionApi, getPermissionCache, getPriceCode, getPriceSeg, getQuarter, getQuarterBeginMonth, getQuarterEndMonth, getQuarterNum, getSessionStorage, getToken, getType, getUrlParams, getUserInfoApi, getUserInfoCache, guid, importJsonFromExcel, isArguments, isArray, isArrayLike, isBoolean, isDate, isDecimal, isElement, isEmpty, isEqual, isEqualWith, isError, isEven, isFinite$1 as isFinite, isFunction, isInteger, isNegative, isNil, isNull, isNumber, isNumberEqual, isObject, isObjectLike, isOdd, isPlainObject, isPositive, isPromise, isPrototype, isRegExp2 as isRegExp, isString, isType, isUndefined, listComTreeApi, listItemTreeApi, listUserTreeApi, loginApi, logoutApi, menuHistoryApi, numToChineseNumerals, numToDX, off, on, quarter2Chinese, removeLocalStorage, removeMenuCollectApi, removeSessionStorage, renderColumnEnums, renderEnumData, renderEnumList, renderFieldEnums, responseInterceptors, round, row2column, setContentType, setLocalStorage, setPermissionCache, setSessionStorage, setToken, setUserInfoCache, str2Date, toChies, toFixed, toThousands, updatePasswordApi, useConfig };
10856
+ export { CONTENT_TYPE, IS_OR_NOT_ENUM, IS_OR_NOT_ENUM_KEY, IS_OR_NOT_ENUM_LIST, MIME_TYPE, UC_ENUM, addMenuCollectApi, instance as axios, checkIdCard, checkPhone, checkTel, checkVehicleNo, clearPermissionCache, clearSessionStorage, clearUserInfoCache, config, cryptor, deleteMenuCollectApi, deleteMenuHistoryApi, exportJsonToExcel, flattenRow2ColumnData, formatDate, formatDateChinese, formatDecimal, formatHalfYear, formatQuarter, getAppListApi, getCaptchaURL, getContentType, getDictApi, getDictMapApi, getDictsMapApi, getExcelColumnIdx, getGlobalPolicyApi, getHalfYear, getHalfYearBeginMonth, getHalfYearEndMonth, getHalfYearNum, getItem, getLocalStorage, getMaxTabNumValueApi, getMenuCollectApi, getMenuHistoryApi, getOssFileApi, getPermissionApi, getPermissionCache, getPriceCode, getPriceSeg, getQuarter, getQuarterBeginMonth, getQuarterEndMonth, getQuarterNum, getSessionStorage, getToken, getType, getUrlParams, getUserInfoApi, getUserInfoCache, guid, importJsonFromExcel, isArguments, isArray, isArrayLike, isBoolean, isDate, isDecimal, isElement, isEmpty, isEqual, isEqualWith, isError, isEven, isFinite$1 as isFinite, isFunction, isInteger, isNegative, isNil, isNull, isNumber, isNumberEqual, isObject, isObjectLike, isOdd, isPlainObject, isPositive, isPromise, isPrototype, isRegExp2 as isRegExp, isString, isType, isUndefined, listComTreeApi, listItemTreeApi, listUserTreeApi, loginApi, logoutApi, menuHistoryApi, numToChineseNumerals, numToDX, off, on, quarter2Chinese, removeLocalStorage, removeMenuCollectApi, removeSessionStorage, renderColumnEnums, renderEnumData, renderEnumList, renderFieldEnums, responseInterceptors, round, row2column, setContentType, setLocalStorage, setPermissionCache, setSessionStorage, setToken, setUserInfoCache, str2Date, toChies, toFixed, toThousands, updatePasswordApi, useConfig, uuid };