jinbi-utils 1.0.1 → 1.0.2

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,8 @@
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
+ ### [1.0.2](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.1...v1.0.2) (2025-07-31)
6
+
5
7
  ### [1.0.1](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.0...v1.0.1) (2025-07-25)
6
8
 
7
9
  ## 1.0.0 (2025-07-25)
package/dist/index.esm.js CHANGED
@@ -1400,6 +1400,12 @@ var http = function (_a) {
1400
1400
  return request;
1401
1401
  };
1402
1402
 
1403
+ /**
1404
+ * 日志记录中间件
1405
+ *
1406
+ * @param systemName 系统名称
1407
+ * @returns 返回一个中间件函数
1408
+ */
1403
1409
  var recordLogMiddleWare = function (systemName) {
1404
1410
  return function (ctx, next) { return __awaiter(void 0, void 0, void 0, function () {
1405
1411
  var ip, path, method, timeToString, requestParams, headers, result, logData;
@@ -1409,7 +1415,7 @@ var recordLogMiddleWare = function (systemName) {
1409
1415
  ip = ctx.ip || ctx.request.ip;
1410
1416
  path = ctx.path;
1411
1417
  method = ctx.method;
1412
- timeToString = new Date().toISOString();
1418
+ timeToString = getNowTime();
1413
1419
  requestParams = {
1414
1420
  method: ctx.method,
1415
1421
  url: ctx.url,
@@ -1443,25 +1449,68 @@ var recordLogMiddleWare = function (systemName) {
1443
1449
  });
1444
1450
  }); };
1445
1451
  };
1452
+ var getNowTime = function () {
1453
+ var localDateTime = new Date();
1454
+ var year = localDateTime.getFullYear() + '';
1455
+ var month = localDateTime.getMonth() + 1 + '';
1456
+ var day = localDateTime.getDate() + '';
1457
+ var hours = localDateTime.getHours() + '';
1458
+ var minutes = localDateTime.getMinutes() + '';
1459
+ var timeToString = year + '年' + month + '月' + day + '日' + hours + ':' + minutes;
1460
+ return timeToString;
1461
+ };
1446
1462
  var sendLog = function (logData) {
1447
1463
  console.log('logData---------', logData);
1448
- var LOG_HOST = 'http://localhost:7003';
1464
+ var LOG_HOST = 'https://fe-log-producer.jinbizhihui.com';
1449
1465
  axios.post(LOG_HOST + "/log/save", logData);
1450
1466
  };
1451
1467
 
1452
- // 获取state,(针对iam跳转)
1453
- var getUrlState = function (route) {
1454
- var state = route.query.state;
1455
- var stateObj = {};
1456
- if (state && typeof state === 'string' && state.indexOf('?') > -1) {
1457
- var jsonPart = state.slice(0, state.indexOf('?'));
1458
- // const queryPart = state.slice(state.indexOf('?') + 1);
1459
- stateObj = JSON.parse(decodeURIComponent(jsonPart));
1460
- }
1461
- else if (state && typeof state === 'string') {
1462
- stateObj = JSON.parse(decodeURIComponent(state));
1463
- }
1464
- return stateObj;
1468
+ /**
1469
+ * 扁平化 state 字段
1470
+ * @param state 需要扁平化的 state 字段
1471
+ * @param keyName 需要剥离的 key 名称
1472
+ * @returns 扁平化后的 state 字段
1473
+ */
1474
+ function flattenStateRecursive(state, keyName) {
1475
+ if (keyName === void 0) { keyName = 'state'; }
1476
+ var result = state;
1477
+ var lastResult;
1478
+ // 递归解码和解析
1479
+ while (typeof result === 'string') {
1480
+ try {
1481
+ lastResult = result;
1482
+ result = decodeURIComponent(result);
1483
+ result = JSON.parse(result);
1484
+ }
1485
+ catch (_a) {
1486
+ result = lastResult;
1487
+ break;
1488
+ }
1489
+ }
1490
+ // 递归剥离 state 字段
1491
+ while (result &&
1492
+ typeof result === 'object' &&
1493
+ keyName in result &&
1494
+ (typeof result[keyName] === 'string' || typeof result[keyName] === 'object')) {
1495
+ result = result[keyName];
1496
+ if (typeof result === 'string') {
1497
+ try {
1498
+ result = decodeURIComponent(result);
1499
+ result = JSON.parse(result);
1500
+ }
1501
+ catch (_b) {
1502
+ break;
1503
+ }
1504
+ }
1505
+ }
1506
+ return result;
1507
+ }
1508
+ var handleFlatStr = function (keyName, value) {
1509
+ // return `${key}=${value}`
1510
+ if (keyName === void 0) { keyName = 'state'; }
1511
+ var flat = flattenStateRecursive(value, keyName);
1512
+ var flatStr = typeof flat === 'object' ? JSON.stringify(flat) : String(flat);
1513
+ return flatStr;
1465
1514
  };
1466
1515
 
1467
- export { addDays, base64ToBlob, base64ToFile, blobToDataURL, buildUUID, calcFileSize, ceil, clearLoginData, compatibleDate, compressImg, computeMoney, convertBase64UrlToBlob, convertCurrency, dataURLtoBlob, deepEqual, fileSizeFormat, filterRepeat, findNodePath, floor, formatBank, formatCentsToYuan, formatEmptyValue, formatFloat, formatMoney, formatPhone, formatPhoneHide, formatTime, formateTimestamp, fromNow, genExportByBlob, generateEnglishLetters, getCookie, getDeviceType, getEnvironment, getFileData, getFromType, getIsComWx, getIsDevelopment, getQueryString, getQueryVariable, getTicket, getToken, getUrlState, getWecomToken, http, httpEnum, humpTurnDashed, isEmail, isEmpty, isExternal, isImage, isMobile, isMobileSimple, isQQ, isTelephone, newDate, randomString, recordLogMiddleWare, removeTicket, removeToken, setTicket, toThousands, trimVal, uuid, validateTwoDecimal };
1516
+ export { addDays, base64ToBlob, base64ToFile, blobToDataURL, buildUUID, calcFileSize, ceil, clearLoginData, compatibleDate, compressImg, computeMoney, convertBase64UrlToBlob, convertCurrency, dataURLtoBlob, deepEqual, fileSizeFormat, filterRepeat, findNodePath, floor, formatBank, formatCentsToYuan, formatEmptyValue, formatFloat, formatMoney, formatPhone, formatPhoneHide, formatTime, formateTimestamp, fromNow, genExportByBlob, generateEnglishLetters, getCookie, getDeviceType, getEnvironment, getFileData, getFromType, getIsComWx, getIsDevelopment, getQueryString, getQueryVariable, getTicket, getToken, getWecomToken, handleFlatStr, http, httpEnum, humpTurnDashed, isEmail, isEmpty, isExternal, isImage, isMobile, isMobileSimple, isQQ, isTelephone, newDate, randomString, recordLogMiddleWare, removeTicket, removeToken, setTicket, toThousands, trimVal, uuid, validateTwoDecimal };
@@ -1,4 +1,4 @@
1
- import e from"axios";var t={isWxWork:"wecom",isWeixin:"wechat",isMobile:"mobile",isMobileAny:"mobile"};function r(e){return null===e||""===e||void 0===e}var n=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},o=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},i=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},a=function(){return localStorage.getItem("wecom_token")},u=function(){var e=navigator.userAgent.toLowerCase(),t=/wxwork/.test(e),r=/micromessenger/.test(e)&&!t,n=window.innerWidth<=768;return{isWxWork:t,isWeixin:r,isMobileScreen:n,isMobileAny:t||r||n}},c=function(e){var r="wecom";for(var n in e){if(e[n]){r=t[n];break}}return r};function s(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n}var l=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},f=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},d=function(){return localStorage.getItem("jsapiTicket")},g=function(e){return localStorage.setItem("jsapiTicket",e)},p=function(){return localStorage.removeItem("jsapiTicket")},h=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},v=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},m=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},w=function(){return/wxwork/i.test(navigator.userAgent)},y=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},b=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},S=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},M=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},A=function(e){return/^image\//i.test(e)},C=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},R=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},x=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},I=function(e,t){var r=e.toLowerCase();return"localstorage"===r?localStorage.getItem("token")||"":"sessionstorage"===r?sessionStorage.getItem("token")||"":localStorage.getItem("token")||sessionStorage.getItem("token")||""},k=function(e,t){var r=e.toLowerCase();"localstorage"===r?localStorage.removeItem("token"):"sessionstorage"===r?sessionStorage.removeItem("token"):(localStorage.removeItem("token"),sessionStorage.getItem("token"))};function E(e){return"string"==typeof e?e.replace(/-/g,"/"):e}function N(e){return e?new Date(E(e)):new Date}function T(e,t){void 0===e&&(e=Date.now()),void 0===t&&(t="yyyy-MM-dd HH:mm:ss"),e=E(e);var r={"M+":(e=new Date(e)).getMonth()+1,"d+":e.getDate(),"h+":e.getHours()%12==0?12:e.getHours()%12,"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};return/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(""+e.getFullYear()).substr(4-RegExp.$1.length))),Object.keys(r).forEach((function(e){new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[e]:("00"+r[e]).substr((""+r[e]).length)))})),t}function D(e,t,n){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===n&&(n="-"),r(e))return n;e=E(e);var o=new Date(e),i=(Date.now()-o.getTime())/1e3;return i<0?e:i<30?"刚刚":i<3600?Math.ceil(i/60)+"分钟前":i<86400?Math.floor(i/3600)+"小时前":i<172800?"1天前":T(e,t)}function O(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n="yyyy-MM-dd"),r(e))return"-";e=E(e);var o=new Date(e);return o.setDate(o.getDate()+Number(t)),T(o,n)}
1
+ import e from"axios";var t={isWxWork:"wecom",isWeixin:"wechat",isMobile:"mobile",isMobileAny:"mobile"};function r(e){return null===e||""===e||void 0===e}var n=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},o=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},i=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},a=function(){return localStorage.getItem("wecom_token")},u=function(){var e=navigator.userAgent.toLowerCase(),t=/wxwork/.test(e),r=/micromessenger/.test(e)&&!t,n=window.innerWidth<=768;return{isWxWork:t,isWeixin:r,isMobileScreen:n,isMobileAny:t||r||n}},c=function(e){var r="wecom";for(var n in e){if(e[n]){r=t[n];break}}return r};function s(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n}var l=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},f=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},d=function(){return localStorage.getItem("jsapiTicket")},g=function(e){return localStorage.setItem("jsapiTicket",e)},p=function(){return localStorage.removeItem("jsapiTicket")},h=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},v=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},m=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},w=function(){return/wxwork/i.test(navigator.userAgent)},y=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},b=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},S=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},M=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},A=function(e){return/^image\//i.test(e)},C=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},R=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},k=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},x=function(e,t){var r=e.toLowerCase();return"localstorage"===r?localStorage.getItem("token")||"":"sessionstorage"===r?sessionStorage.getItem("token")||"":localStorage.getItem("token")||sessionStorage.getItem("token")||""},I=function(e,t){var r=e.toLowerCase();"localstorage"===r?localStorage.removeItem("token"):"sessionstorage"===r?sessionStorage.removeItem("token"):(localStorage.removeItem("token"),sessionStorage.getItem("token"))};function E(e){return"string"==typeof e?e.replace(/-/g,"/"):e}function N(e){return e?new Date(E(e)):new Date}function D(e,t){void 0===e&&(e=Date.now()),void 0===t&&(t="yyyy-MM-dd HH:mm:ss"),e=E(e);var r={"M+":(e=new Date(e)).getMonth()+1,"d+":e.getDate(),"h+":e.getHours()%12==0?12:e.getHours()%12,"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};return/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(""+e.getFullYear()).substr(4-RegExp.$1.length))),Object.keys(r).forEach((function(e){new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[e]:("00"+r[e]).substr((""+r[e]).length)))})),t}function T(e,t,n){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===n&&(n="-"),r(e))return n;e=E(e);var o=new Date(e),i=(Date.now()-o.getTime())/1e3;return i<0?e:i<30?"刚刚":i<3600?Math.ceil(i/60)+"分钟前":i<86400?Math.floor(i/3600)+"小时前":i<172800?"1天前":D(e,t)}function U(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n="yyyy-MM-dd"),r(e))return"-";e=E(e);var o=new Date(e);return o.setDate(o.getDate()+Number(t)),D(o,n)}
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var U=function(){return(U=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function P(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function B(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var F={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function j(e,t){if(void 0===t&&(t="-"),r(e))return t;var n=e.toString();return n.includes(".")||(n+="."),n.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function z(e){void 0===e&&(e="");if(r(e))return"";if(Number(e)>=1e15)return e;var t,n,o,i=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=i[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,n=""):(t=(o=e.split("."))[0],n=o[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,h=p/4,v=p%4;"0"===g?l+=1:(l>0&&(s+=i[0]),l=0,s+=i[parseInt(g,10)]+a[v]),0===v&&l<4&&(s+=u[h])}s+="元"}if(""!==n){var m=n.length;for(d=0;d<m;d+=1){var w=n.substr(d,1);"0"!==w&&(s+=i[Number(w)]+c[d])}}return""===s?s+=i[0]+"元整":""===n&&(s+="整"),s}function H(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n}function W(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.ceil(o)/n}function q(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.floor(o)/n}function $(e,t){var r=Y(e,t),n=U(U({},F),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?j(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function Y(e,t){var r,n,o=U(U({},F),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function _(e,t){return $(e,U({operation:"divide",factor:100,formatAsCurrency:!0},t))}function L(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function G(e,t,n){if(void 0===t&&(t="B"),void 0===n&&(n="-"),r(e))return n;var o=L(parseFloat(e.toString()),t);return""+W(o.size,2)+o.unit}function Z(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function J(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function Q(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(Z(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))}function K(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return P(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return B(this,(function(p){switch(p.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,J(f)];case 2:g=p.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),p.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}}function V(e,t){var r=Object.keys,n=typeof e;return e&&t&&"object"===n&&n===typeof t?r(e).length===r(t).length&&r(e).every((function(r){return V(e[r],t[r])})):e===t}function X(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)X(e[n][i],t,r,n,o);o.pop()}function ee(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)X(r[i],e,t,n,o)}catch(e){return o}}function te(e){return/^(https?:|mailto:|tel:)/.test(e)}function re(e){if(!e)return e;return e.replace(/^\s+|\s+$/g,"")}function ne(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())}function oe(e){return e=e.toString(),/^1/.test(e)&&11===e.length}function ie(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))}function ae(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)}function ue(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))}function ce(e,t){return void 0===t&&(t="-"),r(e)?t:e}function se(e,t,n){if(void 0===t&&(t=" "),void 0===n&&(n="-"),r(e))return n;if(11!==e.toString().length)return e;var o=e.toString().replace(/[^\d]/g,"").split(""),i="";return o.forEach((function(e,r){3!==r&&7!==r||(i+=t),i+=e})),i}function le(e,t){if(void 0===t&&(t=""),r(e))return t;if(11!==e.toString().length)return e;var n=e.toString();return n.substr(0,3)+"****"+n.substr(7,11)}function fe(e,t){return void 0===t&&(t=""),r(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")}function de(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e}function ge(e){void 0===e&&(e="");return e.replace(/\B([A-Z])/g,"-$1").toLowerCase()}var pe={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},he=e.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),ve=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;return e.tokenKey,he.interceptors.request.use((function(e){return P(void 0,void 0,void 0,(function(){var r,n;return B(this,(function(o){return r=I(t),n=u(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=c(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),he.interceptors.response.use((function(e){return P(void 0,void 0,void 0,(function(){var n,i,a;return B(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===pe.CODES.Success?[2,n]:i===pe.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(k(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return P(void 0,void 0,void 0,(function(){return B(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),he},me=function(e){return function(t,r){return P(void 0,void 0,void 0,(function(){var n,o,i,a,u,c,s;return B(this,(function(l){switch(l.label){case 0:return n=t.ip||t.request.ip,o=t.path,i=t.method,a=(new Date).toISOString(),u={method:t.method,url:t.url,query:t.query,body:t.request.body},c=t.headers,[4,r()];case 1:return l.sent(),s={status:t.status,body:t.body,headers:t.response.headers},we({system:e,ip:n,path:o,method:i,time:a,params:u,headers:c,result:s}),[2]}}))}))}},we=function(t){console.log("logData---------",t);e.post("http://localhost:7003/log/save",t)},ye=function(e){var t=e.query.state,r={};if(t&&"string"==typeof t&&t.indexOf("?")>-1){var n=t.slice(0,t.indexOf("?"));r=JSON.parse(decodeURIComponent(n))}else t&&"string"==typeof t&&(r=JSON.parse(decodeURIComponent(t)));return r};export{O as addDays,S as base64ToBlob,M as base64ToFile,J as blobToDataURL,f as buildUUID,L as calcFileSize,W as ceil,n as clearLoginData,E as compatibleDate,Q as compressImg,Y as computeMoney,v as convertBase64UrlToBlob,z as convertCurrency,Z as dataURLtoBlob,V as deepEqual,G as fileSizeFormat,b as filterRepeat,ee as findNodePath,q as floor,fe as formatBank,_ as formatCentsToYuan,ce as formatEmptyValue,H as formatFloat,$ as formatMoney,se as formatPhone,le as formatPhoneHide,T as formatTime,h as formateTimestamp,D as fromNow,K as genExportByBlob,de as generateEnglishLetters,l as getCookie,u as getDeviceType,m as getEnvironment,C as getFileData,c as getFromType,w as getIsComWx,y as getIsDevelopment,o as getQueryString,i as getQueryVariable,d as getTicket,I as getToken,ye as getUrlState,a as getWecomToken,ve as http,pe as httpEnum,ge as humpTurnDashed,ae as isEmail,r as isEmpty,te as isExternal,A as isImage,ne as isMobile,oe as isMobileSimple,ue as isQQ,ie as isTelephone,N as newDate,s as randomString,me as recordLogMiddleWare,p as removeTicket,k as removeToken,g as setTicket,j as toThousands,re as trimVal,x as uuid,R as validateTwoDecimal};
15
+ ***************************************************************************** */var O=function(){return(O=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function P(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function B(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var j={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function F(e,t){if(void 0===t&&(t="-"),r(e))return t;var n=e.toString();return n.includes(".")||(n+="."),n.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function z(e){void 0===e&&(e="");if(r(e))return"";if(Number(e)>=1e15)return e;var t,n,o,i=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=i[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,n=""):(t=(o=e.split("."))[0],n=o[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,h=p/4,v=p%4;"0"===g?l+=1:(l>0&&(s+=i[0]),l=0,s+=i[parseInt(g,10)]+a[v]),0===v&&l<4&&(s+=u[h])}s+="元"}if(""!==n){var m=n.length;for(d=0;d<m;d+=1){var w=n.substr(d,1);"0"!==w&&(s+=i[Number(w)]+c[d])}}return""===s?s+=i[0]+"元整":""===n&&(s+="整"),s}function H(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n}function W(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.ceil(o)/n}function Y(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.floor(o)/n}function $(e,t){var r=q(e,t),n=O(O({},j),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?F(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function q(e,t){var r,n,o=O(O({},j),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function _(e,t){return $(e,O({operation:"divide",factor:100,formatAsCurrency:!0},t))}function L(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function G(e,t,n){if(void 0===t&&(t="B"),void 0===n&&(n="-"),r(e))return n;var o=L(parseFloat(e.toString()),t);return""+W(o.size,2)+o.unit}function J(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function Z(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function Q(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(J(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))}function K(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return P(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return B(this,(function(p){switch(p.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,Z(f)];case 2:g=p.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),p.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}}function V(e,t){var r=Object.keys,n=typeof e;return e&&t&&"object"===n&&n===typeof t?r(e).length===r(t).length&&r(e).every((function(r){return V(e[r],t[r])})):e===t}function X(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)X(e[n][i],t,r,n,o);o.pop()}function ee(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)X(r[i],e,t,n,o)}catch(e){return o}}function te(e){return/^(https?:|mailto:|tel:)/.test(e)}function re(e){if(!e)return e;return e.replace(/^\s+|\s+$/g,"")}function ne(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())}function oe(e){return e=e.toString(),/^1/.test(e)&&11===e.length}function ie(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))}function ae(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)}function ue(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))}function ce(e,t){return void 0===t&&(t="-"),r(e)?t:e}function se(e,t,n){if(void 0===t&&(t=" "),void 0===n&&(n="-"),r(e))return n;if(11!==e.toString().length)return e;var o=e.toString().replace(/[^\d]/g,"").split(""),i="";return o.forEach((function(e,r){3!==r&&7!==r||(i+=t),i+=e})),i}function le(e,t){if(void 0===t&&(t=""),r(e))return t;if(11!==e.toString().length)return e;var n=e.toString();return n.substr(0,3)+"****"+n.substr(7,11)}function fe(e,t){return void 0===t&&(t=""),r(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")}function de(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e}function ge(e){void 0===e&&(e="");return e.replace(/\B([A-Z])/g,"-$1").toLowerCase()}var pe={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},he=e.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),ve=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;return e.tokenKey,he.interceptors.request.use((function(e){return P(void 0,void 0,void 0,(function(){var r,n;return B(this,(function(o){return r=x(t),n=u(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=c(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),he.interceptors.response.use((function(e){return P(void 0,void 0,void 0,(function(){var n,i,a;return B(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===pe.CODES.Success?[2,n]:i===pe.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(I(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return P(void 0,void 0,void 0,(function(){return B(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),he},me=function(e){return function(t,r){return P(void 0,void 0,void 0,(function(){var n,o,i,a,u,c,s;return B(this,(function(l){switch(l.label){case 0:return n=t.ip||t.request.ip,o=t.path,i=t.method,a=we(),u={method:t.method,url:t.url,query:t.query,body:t.request.body},c=t.headers,[4,r()];case 1:return l.sent(),s={status:t.status,body:t.body,headers:t.response.headers},ye({system:e,ip:n,path:o,method:i,time:a,params:u,headers:c,result:s}),[2]}}))}))}},we=function(){var e=new Date;return e.getFullYear()+""+"年"+(e.getMonth()+1+"")+"月"+(e.getDate()+"")+"日"+(e.getHours()+"")+":"+(e.getMinutes()+"")},ye=function(t){console.log("logData---------",t);e.post("https://fe-log-producer.jinbizhihui.com/log/save",t)};var be=function(e,t){void 0===e&&(e="state");var r=function(e,t){void 0===t&&(t="state");for(var r,n=e;"string"==typeof n;)try{r=n,n=decodeURIComponent(n),n=JSON.parse(n)}catch(e){n=r;break}for(;n&&"object"==typeof n&&t in n&&("string"==typeof n[t]||"object"==typeof n[t]);)if("string"==typeof(n=n[t]))try{n=decodeURIComponent(n),n=JSON.parse(n)}catch(e){break}return n}(t,e);return"object"==typeof r?JSON.stringify(r):String(r)};export{U as addDays,S as base64ToBlob,M as base64ToFile,Z as blobToDataURL,f as buildUUID,L as calcFileSize,W as ceil,n as clearLoginData,E as compatibleDate,Q as compressImg,q as computeMoney,v as convertBase64UrlToBlob,z as convertCurrency,J as dataURLtoBlob,V as deepEqual,G as fileSizeFormat,b as filterRepeat,ee as findNodePath,Y as floor,fe as formatBank,_ as formatCentsToYuan,ce as formatEmptyValue,H as formatFloat,$ as formatMoney,se as formatPhone,le as formatPhoneHide,D as formatTime,h as formateTimestamp,T as fromNow,K as genExportByBlob,de as generateEnglishLetters,l as getCookie,u as getDeviceType,m as getEnvironment,C as getFileData,c as getFromType,w as getIsComWx,y as getIsDevelopment,o as getQueryString,i as getQueryVariable,d as getTicket,x as getToken,a as getWecomToken,be as handleFlatStr,ve as http,pe as httpEnum,ge as humpTurnDashed,ae as isEmail,r as isEmpty,te as isExternal,A as isImage,ne as isMobile,oe as isMobileSimple,ue as isQQ,ie as isTelephone,N as newDate,s as randomString,me as recordLogMiddleWare,p as removeTicket,I as removeToken,g as setTicket,F as toThousands,re as trimVal,k as uuid,R as validateTwoDecimal};
package/dist/index.umd.js CHANGED
@@ -1408,6 +1408,12 @@
1408
1408
  return request;
1409
1409
  };
1410
1410
 
1411
+ /**
1412
+ * 日志记录中间件
1413
+ *
1414
+ * @param systemName 系统名称
1415
+ * @returns 返回一个中间件函数
1416
+ */
1411
1417
  var recordLogMiddleWare = function (systemName) {
1412
1418
  return function (ctx, next) { return __awaiter(void 0, void 0, void 0, function () {
1413
1419
  var ip, path, method, timeToString, requestParams, headers, result, logData;
@@ -1417,7 +1423,7 @@
1417
1423
  ip = ctx.ip || ctx.request.ip;
1418
1424
  path = ctx.path;
1419
1425
  method = ctx.method;
1420
- timeToString = new Date().toISOString();
1426
+ timeToString = getNowTime();
1421
1427
  requestParams = {
1422
1428
  method: ctx.method,
1423
1429
  url: ctx.url,
@@ -1451,25 +1457,68 @@
1451
1457
  });
1452
1458
  }); };
1453
1459
  };
1460
+ var getNowTime = function () {
1461
+ var localDateTime = new Date();
1462
+ var year = localDateTime.getFullYear() + '';
1463
+ var month = localDateTime.getMonth() + 1 + '';
1464
+ var day = localDateTime.getDate() + '';
1465
+ var hours = localDateTime.getHours() + '';
1466
+ var minutes = localDateTime.getMinutes() + '';
1467
+ var timeToString = year + '年' + month + '月' + day + '日' + hours + ':' + minutes;
1468
+ return timeToString;
1469
+ };
1454
1470
  var sendLog = function (logData) {
1455
1471
  console.log('logData---------', logData);
1456
- var LOG_HOST = 'http://localhost:7003';
1472
+ var LOG_HOST = 'https://fe-log-producer.jinbizhihui.com';
1457
1473
  axios__default["default"].post(LOG_HOST + "/log/save", logData);
1458
1474
  };
1459
1475
 
1460
- // 获取state,(针对iam跳转)
1461
- var getUrlState = function (route) {
1462
- var state = route.query.state;
1463
- var stateObj = {};
1464
- if (state && typeof state === 'string' && state.indexOf('?') > -1) {
1465
- var jsonPart = state.slice(0, state.indexOf('?'));
1466
- // const queryPart = state.slice(state.indexOf('?') + 1);
1467
- stateObj = JSON.parse(decodeURIComponent(jsonPart));
1468
- }
1469
- else if (state && typeof state === 'string') {
1470
- stateObj = JSON.parse(decodeURIComponent(state));
1471
- }
1472
- return stateObj;
1476
+ /**
1477
+ * 扁平化 state 字段
1478
+ * @param state 需要扁平化的 state 字段
1479
+ * @param keyName 需要剥离的 key 名称
1480
+ * @returns 扁平化后的 state 字段
1481
+ */
1482
+ function flattenStateRecursive(state, keyName) {
1483
+ if (keyName === void 0) { keyName = 'state'; }
1484
+ var result = state;
1485
+ var lastResult;
1486
+ // 递归解码和解析
1487
+ while (typeof result === 'string') {
1488
+ try {
1489
+ lastResult = result;
1490
+ result = decodeURIComponent(result);
1491
+ result = JSON.parse(result);
1492
+ }
1493
+ catch (_a) {
1494
+ result = lastResult;
1495
+ break;
1496
+ }
1497
+ }
1498
+ // 递归剥离 state 字段
1499
+ while (result &&
1500
+ typeof result === 'object' &&
1501
+ keyName in result &&
1502
+ (typeof result[keyName] === 'string' || typeof result[keyName] === 'object')) {
1503
+ result = result[keyName];
1504
+ if (typeof result === 'string') {
1505
+ try {
1506
+ result = decodeURIComponent(result);
1507
+ result = JSON.parse(result);
1508
+ }
1509
+ catch (_b) {
1510
+ break;
1511
+ }
1512
+ }
1513
+ }
1514
+ return result;
1515
+ }
1516
+ var handleFlatStr = function (keyName, value) {
1517
+ // return `${key}=${value}`
1518
+ if (keyName === void 0) { keyName = 'state'; }
1519
+ var flat = flattenStateRecursive(value, keyName);
1520
+ var flatStr = typeof flat === 'object' ? JSON.stringify(flat) : String(flat);
1521
+ return flatStr;
1473
1522
  };
1474
1523
 
1475
1524
  exports.addDays = addDays;
@@ -1514,8 +1563,8 @@
1514
1563
  exports.getQueryVariable = getQueryVariable;
1515
1564
  exports.getTicket = getTicket;
1516
1565
  exports.getToken = getToken;
1517
- exports.getUrlState = getUrlState;
1518
1566
  exports.getWecomToken = getWecomToken;
1567
+ exports.handleFlatStr = handleFlatStr;
1519
1568
  exports.http = http;
1520
1569
  exports.httpEnum = httpEnum;
1521
1570
  exports.humpTurnDashed = humpTurnDashed;
@@ -13,4 +13,4 @@
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- var d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function g(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var m={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function h(e,t){if(void 0===t&&(t="-"),i(e))return t;var r=e.toString();return r.includes(".")||(r+="."),r.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function v(e,t){if(void 0===t&&(t=0),i(e))return e;var r=Math.pow(10,t),n=Number(e)*r;return Math.ceil(n)/r}function y(e,t){var r=w(e,t),n=d(d({},m),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?h(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function w(e,t){var r,n,o=d(d({},m),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function b(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function S(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function M(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function T(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)T(e[n][i],t,r,n,o);o.pop()}var A={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},x=n.default.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),C=function(e){console.log("logData---------",e);n.default.post("http://localhost:7003/log/save",e)};e.addDays=function(e,t,r){if(void 0===t&&(t=0),void 0===r&&(r="yyyy-MM-dd"),i(e))return"-";e=l(e);var n=new Date(e);return n.setDate(n.getDate()+Number(t)),f(n,r)},e.base64ToBlob=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},e.base64ToFile=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},e.blobToDataURL=M,e.buildUUID=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},e.calcFileSize=b,e.ceil=v,e.clearLoginData=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},e.compatibleDate=l,e.compressImg=function(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(S(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))},e.computeMoney=w,e.convertBase64UrlToBlob=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},e.convertCurrency=function(e){if(void 0===e&&(e=""),i(e))return"";if(Number(e)>=1e15)return e;var t,r,n,o=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=o[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,r=""):(t=(n=e.split("."))[0],r=n[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,m=p/4,h=p%4;"0"===g?l+=1:(l>0&&(s+=o[0]),l=0,s+=o[parseInt(g,10)]+a[h]),0===h&&l<4&&(s+=u[m])}s+="元"}if(""!==r){var v=r.length;for(d=0;d<v;d+=1){var y=r.substr(d,1);"0"!==y&&(s+=o[Number(y)]+c[d])}}return""===s?s+=o[0]+"元整":""===r&&(s+="整"),s},e.dataURLtoBlob=S,e.deepEqual=function e(t,r){var n=Object.keys,o=typeof t;return t&&r&&"object"===o&&o===typeof r?n(t).length===n(r).length&&n(t).every((function(n){return e(t[n],r[n])})):t===r},e.fileSizeFormat=function(e,t,r){if(void 0===t&&(t="B"),void 0===r&&(r="-"),i(e))return r;var n=b(parseFloat(e.toString()),t);return""+v(n.size,2)+n.unit},e.filterRepeat=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},e.findNodePath=function(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)T(r[i],e,t,n,o)}catch(e){return o}},e.floor=function(e,t){if(void 0===t&&(t=0),i(e))return e;var r=Math.pow(10,t),n=Number(e)*r;return Math.floor(n)/r},e.formatBank=function(e,t){return void 0===t&&(t=""),i(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")},e.formatCentsToYuan=function(e,t){return y(e,d({operation:"divide",factor:100,formatAsCurrency:!0},t))},e.formatEmptyValue=function(e,t){return void 0===t&&(t="-"),i(e)?t:e},e.formatFloat=function(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n},e.formatMoney=y,e.formatPhone=function(e,t,r){if(void 0===t&&(t=" "),void 0===r&&(r="-"),i(e))return r;if(11!==e.toString().length)return e;var n=e.toString().replace(/[^\d]/g,"").split(""),o="";return n.forEach((function(e,r){3!==r&&7!==r||(o+=t),o+=e})),o},e.formatPhoneHide=function(e,t){if(void 0===t&&(t=""),i(e))return t;if(11!==e.toString().length)return e;var r=e.toString();return r.substr(0,3)+"****"+r.substr(7,11)},e.formatTime=f,e.formateTimestamp=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},e.fromNow=function(e,t,r){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===r&&(r="-"),i(e))return r;e=l(e);var n=new Date(e),o=(Date.now()-n.getTime())/1e3;return o<0?e:o<30?"刚刚":o<3600?Math.ceil(o/60)+"分钟前":o<86400?Math.floor(o/3600)+"小时前":o<172800?"1天前":f(e,t)},e.genExportByBlob=function(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return g(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return p(this,(function(p){switch(p.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,M(f)];case 2:g=p.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),p.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}},e.generateEnglishLetters=function(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e},e.getCookie=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},e.getDeviceType=a,e.getEnvironment=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},e.getFileData=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},e.getFromType=u,e.getIsComWx=function(){return/wxwork/i.test(navigator.userAgent)},e.getIsDevelopment=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},e.getQueryString=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},e.getQueryVariable=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},e.getTicket=function(){return localStorage.getItem("jsapiTicket")},e.getToken=c,e.getUrlState=function(e){var t=e.query.state,r={};if(t&&"string"==typeof t&&t.indexOf("?")>-1){var n=t.slice(0,t.indexOf("?"));r=JSON.parse(decodeURIComponent(n))}else t&&"string"==typeof t&&(r=JSON.parse(decodeURIComponent(t)));return r},e.getWecomToken=function(){return localStorage.getItem("wecom_token")},e.http=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;return e.tokenKey,x.interceptors.request.use((function(e){return g(void 0,void 0,void 0,(function(){var r,n;return p(this,(function(o){return r=c(t),n=a(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=u(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),x.interceptors.response.use((function(e){return g(void 0,void 0,void 0,(function(){var n,i,a;return p(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===A.CODES.Success?[2,n]:i===A.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(s(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return g(void 0,void 0,void 0,(function(){return p(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),x},e.httpEnum=A,e.humpTurnDashed=function(e){return void 0===e&&(e=""),e.replace(/\B([A-Z])/g,"-$1").toLowerCase()},e.isEmail=function(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)},e.isEmpty=i,e.isExternal=function(e){return/^(https?:|mailto:|tel:)/.test(e)},e.isImage=function(e){return/^image\//i.test(e)},e.isMobile=function(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())},e.isMobileSimple=function(e){return e=e.toString(),/^1/.test(e)&&11===e.length},e.isQQ=function(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))},e.isTelephone=function(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))},e.newDate=function(e){return e?new Date(l(e)):new Date},e.randomString=function(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n},e.recordLogMiddleWare=function(e){return function(t,r){return g(void 0,void 0,void 0,(function(){var n,o,i,a,u,c,s;return p(this,(function(l){switch(l.label){case 0:return n=t.ip||t.request.ip,o=t.path,i=t.method,a=(new Date).toISOString(),u={method:t.method,url:t.url,query:t.query,body:t.request.body},c=t.headers,[4,r()];case 1:return l.sent(),s={status:t.status,body:t.body,headers:t.response.headers},C({system:e,ip:n,path:o,method:i,time:a,params:u,headers:c,result:s}),[2]}}))}))}},e.removeTicket=function(){return localStorage.removeItem("jsapiTicket")},e.removeToken=s,e.setTicket=function(e){return localStorage.setItem("jsapiTicket",e)},e.toThousands=h,e.trimVal=function(e){return e?e.replace(/^\s+|\s+$/g,""):e},e.uuid=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},e.validateTwoDecimal=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},Object.defineProperty(e,"__esModule",{value:!0})}));
16
+ var d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function g(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var m={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function h(e,t){if(void 0===t&&(t="-"),i(e))return t;var r=e.toString();return r.includes(".")||(r+="."),r.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function v(e,t){if(void 0===t&&(t=0),i(e))return e;var r=Math.pow(10,t),n=Number(e)*r;return Math.ceil(n)/r}function y(e,t){var r=b(e,t),n=d(d({},m),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?h(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function b(e,t){var r,n,o=d(d({},m),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function w(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function S(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function M(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function T(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)T(e[n][i],t,r,n,o);o.pop()}var A={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},k=n.default.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),C=function(){var e=new Date;return e.getFullYear()+""+"年"+(e.getMonth()+1+"")+"月"+(e.getDate()+"")+"日"+(e.getHours()+"")+":"+(e.getMinutes()+"")},x=function(e){console.log("logData---------",e);n.default.post("https://fe-log-producer.jinbizhihui.com/log/save",e)};e.addDays=function(e,t,r){if(void 0===t&&(t=0),void 0===r&&(r="yyyy-MM-dd"),i(e))return"-";e=l(e);var n=new Date(e);return n.setDate(n.getDate()+Number(t)),f(n,r)},e.base64ToBlob=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},e.base64ToFile=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},e.blobToDataURL=M,e.buildUUID=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},e.calcFileSize=w,e.ceil=v,e.clearLoginData=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},e.compatibleDate=l,e.compressImg=function(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(S(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))},e.computeMoney=b,e.convertBase64UrlToBlob=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},e.convertCurrency=function(e){if(void 0===e&&(e=""),i(e))return"";if(Number(e)>=1e15)return e;var t,r,n,o=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=o[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,r=""):(t=(n=e.split("."))[0],r=n[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,m=p/4,h=p%4;"0"===g?l+=1:(l>0&&(s+=o[0]),l=0,s+=o[parseInt(g,10)]+a[h]),0===h&&l<4&&(s+=u[m])}s+="元"}if(""!==r){var v=r.length;for(d=0;d<v;d+=1){var y=r.substr(d,1);"0"!==y&&(s+=o[Number(y)]+c[d])}}return""===s?s+=o[0]+"元整":""===r&&(s+="整"),s},e.dataURLtoBlob=S,e.deepEqual=function e(t,r){var n=Object.keys,o=typeof t;return t&&r&&"object"===o&&o===typeof r?n(t).length===n(r).length&&n(t).every((function(n){return e(t[n],r[n])})):t===r},e.fileSizeFormat=function(e,t,r){if(void 0===t&&(t="B"),void 0===r&&(r="-"),i(e))return r;var n=w(parseFloat(e.toString()),t);return""+v(n.size,2)+n.unit},e.filterRepeat=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},e.findNodePath=function(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)T(r[i],e,t,n,o)}catch(e){return o}},e.floor=function(e,t){if(void 0===t&&(t=0),i(e))return e;var r=Math.pow(10,t),n=Number(e)*r;return Math.floor(n)/r},e.formatBank=function(e,t){return void 0===t&&(t=""),i(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")},e.formatCentsToYuan=function(e,t){return y(e,d({operation:"divide",factor:100,formatAsCurrency:!0},t))},e.formatEmptyValue=function(e,t){return void 0===t&&(t="-"),i(e)?t:e},e.formatFloat=function(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n},e.formatMoney=y,e.formatPhone=function(e,t,r){if(void 0===t&&(t=" "),void 0===r&&(r="-"),i(e))return r;if(11!==e.toString().length)return e;var n=e.toString().replace(/[^\d]/g,"").split(""),o="";return n.forEach((function(e,r){3!==r&&7!==r||(o+=t),o+=e})),o},e.formatPhoneHide=function(e,t){if(void 0===t&&(t=""),i(e))return t;if(11!==e.toString().length)return e;var r=e.toString();return r.substr(0,3)+"****"+r.substr(7,11)},e.formatTime=f,e.formateTimestamp=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},e.fromNow=function(e,t,r){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===r&&(r="-"),i(e))return r;e=l(e);var n=new Date(e),o=(Date.now()-n.getTime())/1e3;return o<0?e:o<30?"刚刚":o<3600?Math.ceil(o/60)+"分钟前":o<86400?Math.floor(o/3600)+"小时前":o<172800?"1天前":f(e,t)},e.genExportByBlob=function(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return g(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return p(this,(function(p){switch(p.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,M(f)];case 2:g=p.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),p.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}},e.generateEnglishLetters=function(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e},e.getCookie=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},e.getDeviceType=a,e.getEnvironment=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},e.getFileData=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},e.getFromType=u,e.getIsComWx=function(){return/wxwork/i.test(navigator.userAgent)},e.getIsDevelopment=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},e.getQueryString=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},e.getQueryVariable=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},e.getTicket=function(){return localStorage.getItem("jsapiTicket")},e.getToken=c,e.getWecomToken=function(){return localStorage.getItem("wecom_token")},e.handleFlatStr=function(e,t){void 0===e&&(e="state");var r=function(e,t){void 0===t&&(t="state");for(var r,n=e;"string"==typeof n;)try{r=n,n=decodeURIComponent(n),n=JSON.parse(n)}catch(e){n=r;break}for(;n&&"object"==typeof n&&t in n&&("string"==typeof n[t]||"object"==typeof n[t]);)if("string"==typeof(n=n[t]))try{n=decodeURIComponent(n),n=JSON.parse(n)}catch(e){break}return n}(t,e);return"object"==typeof r?JSON.stringify(r):String(r)},e.http=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;return e.tokenKey,k.interceptors.request.use((function(e){return g(void 0,void 0,void 0,(function(){var r,n;return p(this,(function(o){return r=c(t),n=a(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=u(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),k.interceptors.response.use((function(e){return g(void 0,void 0,void 0,(function(){var n,i,a;return p(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===A.CODES.Success?[2,n]:i===A.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(s(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return g(void 0,void 0,void 0,(function(){return p(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),k},e.httpEnum=A,e.humpTurnDashed=function(e){return void 0===e&&(e=""),e.replace(/\B([A-Z])/g,"-$1").toLowerCase()},e.isEmail=function(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)},e.isEmpty=i,e.isExternal=function(e){return/^(https?:|mailto:|tel:)/.test(e)},e.isImage=function(e){return/^image\//i.test(e)},e.isMobile=function(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())},e.isMobileSimple=function(e){return e=e.toString(),/^1/.test(e)&&11===e.length},e.isQQ=function(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))},e.isTelephone=function(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))},e.newDate=function(e){return e?new Date(l(e)):new Date},e.randomString=function(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n},e.recordLogMiddleWare=function(e){return function(t,r){return g(void 0,void 0,void 0,(function(){var n,o,i,a,u,c,s;return p(this,(function(l){switch(l.label){case 0:return n=t.ip||t.request.ip,o=t.path,i=t.method,a=C(),u={method:t.method,url:t.url,query:t.query,body:t.request.body},c=t.headers,[4,r()];case 1:return l.sent(),s={status:t.status,body:t.body,headers:t.response.headers},x({system:e,ip:n,path:o,method:i,time:a,params:u,headers:c,result:s}),[2]}}))}))}},e.removeTicket=function(){return localStorage.removeItem("jsapiTicket")},e.removeToken=s,e.setTicket=function(e){return localStorage.setItem("jsapiTicket",e)},e.toThousands=h,e.trimVal=function(e){return e?e.replace(/^\s+|\s+$/g,""):e},e.uuid=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},e.validateTwoDecimal=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},Object.defineProperty(e,"__esModule",{value:!0})}));
package/docs/index.html CHANGED
@@ -187,6 +187,34 @@ findNodePath(nodeValue, nodeKey, treeArray, childrenKey)</code></pre>
187
187
 
188
188
  <span class="hljs-comment">// 初始化企业微信配置</span>
189
189
  initWWConfig()</code></pre>
190
+ <a href="#8-middleware-模块-middleware" id="8-middleware-模块-middleware" style="color: inherit; text-decoration: none;">
191
+ <h2>8. middleware 模块 (middleware)</h2>
192
+ </a>
193
+ <p>中间件相关功能:</p>
194
+ <a href="#81-requestloggermiddwarets" id="81-requestloggermiddwarets" style="color: inherit; text-decoration: none;">
195
+ <h3>8.1 requestLogger.middware.ts</h3>
196
+ </a>
197
+ <p>日志服务 此插件支持使用了koa的nodejs项目
198
+ 注意:(recordLogMiddleWare(&#39;project-plan-service&#39;))需要传入项目名,日志文件会根据传入的项目名来 命名前缀</p>
199
+ <pre><code class="language-typescript"><span class="hljs-comment">// midway 项目接入方案 configuration.ts</span>
200
+ <span class="hljs-keyword">import</span> { recordLogMiddleWare } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;jinbi-utils&#x27;</span>
201
+
202
+ <span class="hljs-keyword">export</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainConfiguration</span> </span>{
203
+ <span class="hljs-meta">@App</span>(<span class="hljs-string">&#x27;koa&#x27;</span>)
204
+ <span class="hljs-attr">app</span>: koa.Application;
205
+
206
+ <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-title">onReady</span>(<span class="hljs-params"></span>)</span> {
207
+ <span class="hljs-comment">// </span>
208
+ <span class="hljs-built_in">this</span>.app.useMiddleware([recordLogMiddleWare(<span class="hljs-string">&#x27;project-plan-service&#x27;</span>)]);
209
+
210
+ }
211
+ }</code></pre>
212
+ <pre><code class="language-typescript"><span class="hljs-comment">// 只用了koa的nodejs项目接入方案 app.js</span>
213
+ <span class="hljs-keyword">import</span> { recordLogMiddleWare } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;jinbi-utils&#x27;</span>
214
+
215
+ <span class="hljs-keyword">const</span> app = <span class="hljs-keyword">new</span> Koa();
216
+ app.use(bodyParser());
217
+ app.use(router.routes()).use(router.allowedMethods()).use(recordLogMiddleWare(<span class="hljs-string">&#x27;project-plan-service&#x27;</span>));</code></pre>
190
218
  <a href="#安装和使用" id="安装和使用" style="color: inherit; text-decoration: none;">
191
219
  <h2>安装和使用</h2>
192
220
  </a>
@@ -89,16 +89,27 @@
89
89
  <li class="tsd-description">
90
90
  <aside class="tsd-sources">
91
91
  <ul>
92
- <li>Defined in src/middleware/requestLogger.middware.ts:4</li>
92
+ <li>Defined in src/middleware/requestLogger.middware.ts:10</li>
93
93
  </ul>
94
94
  </aside>
95
+ <div class="tsd-comment tsd-typography">
96
+ <div class="lead">
97
+ <p>日志记录中间件</p>
98
+ </div>
99
+ </div>
95
100
  <h4 class="tsd-parameters-title">Parameters</h4>
96
101
  <ul class="tsd-parameters">
97
102
  <li>
98
103
  <h5>systemName: <span class="tsd-signature-type">any</span></h5>
104
+ <div class="tsd-comment tsd-typography">
105
+ <div class="lead">
106
+ <p>系统名称</p>
107
+ </div>
108
+ </div>
99
109
  </li>
100
110
  </ul>
101
111
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">(Anonymous function)</span></h4>
112
+ <p>返回一个中间件函数</p>
102
113
  </li>
103
114
  </ul>
104
115
  </section>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinbi-utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.umd.min.js",
6
6
  "module": "dist/index.esm.min.js",
@@ -1 +1,7 @@
1
+ /**
2
+ * 日志记录中间件
3
+ *
4
+ * @param systemName 系统名称
5
+ * @returns 返回一个中间件函数
6
+ */
1
7
  export declare const recordLogMiddleWare: (systemName: any) => (ctx: any, next: any) => Promise<void>;