@yh-kit/utils 1.14.0 → 1.15.0

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/README.md CHANGED
@@ -1,12 +1,3 @@
1
- <!--
2
- * @Description: 实用程序合集
3
- * @Author: YH
4
- * @Date: 2025-10-17 17:13:02
5
- * @LastEditors: YH
6
- * @LastEditTime: 2025-10-21 14:54:58
7
- * @FilePath: \vite-project\packages\utils\README.md
8
- -->
9
-
10
1
  # 实用程序合集
11
2
 
12
3
  实用程序合集
@@ -30,7 +21,7 @@
30
21
  | dateUtils | 日期相关操作工具函数 | js对象函数 |
31
22
  | documentUtils | 文档相关操作工具函数 | js对象函数 |
32
23
  | downloadUtils | 下载相关操作工具函数 | js对象函数 |
33
- | echartsUtils | Echarts 相关操作工具函数 |
24
+ | echartsUtils | Echarts 相关操作工具函数 | js对象函数 |
34
25
  | letterUtils | 字母相关操作工具函数 | js对象函数 |
35
26
  | mapUtils | 地图相关操作工具函数 | js对象函数 |
36
27
  | MoneyFormatter | 金额格式化工具函数 | class类 |
package/dist/utils.js CHANGED
@@ -431,7 +431,16 @@ const S = {
431
431
  isMobile() {
432
432
  return /Mobi|Android|iPhone/i.test(navigator.userAgent);
433
433
  }
434
- }, L = {
434
+ }, O = {
435
+ /**
436
+ * 获取变量的类型
437
+ * @param val 任意变量
438
+ * @returns 类型字符串
439
+ */
440
+ getType(e) {
441
+ return Object.prototype.toString.call(e).replace(/\[object\s(\w+)\]/, "$1");
442
+ }
443
+ }, T = {
435
444
  /**
436
445
  * 通过传入的name获取cookie的值
437
446
  * @param name cookie的name
@@ -461,7 +470,7 @@ const S = {
461
470
  deleteCookie(e) {
462
471
  this.setCookie(e, "", -1);
463
472
  }
464
- }, O = {
473
+ }, L = {
465
474
  /**
466
475
  * 获取当前时间字符串
467
476
  * @param locales 区域设置。如:'zh-CN','en-US',"chinese"。默认'zh-CN'。
@@ -576,7 +585,7 @@ const S = {
576
585
  new RegExp("(" + r + ")").test(n) && (n = n.replace(RegExp.$1, RegExp.$1.length === 1 ? t[r] : ("00" + t[r]).substr(("" + t[r]).length)));
577
586
  return n;
578
587
  }
579
- }, T = {
588
+ }, I = {
580
589
  /**
581
590
  * 获取元素相对于文档顶部的偏移量(距离)
582
591
  * 处理了SVG元素的特殊情况。
@@ -647,7 +656,7 @@ const S = {
647
656
  getViewportHeight() {
648
657
  return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
649
658
  }
650
- }, I = {
659
+ }, k = {
651
660
  /**
652
661
  * 将blob对象转化成文件并导出到本地
653
662
  * @param blob blob对象
@@ -666,7 +675,7 @@ const S = {
666
675
  const t = document.createElement("a");
667
676
  t.href = e, t.download = n, document.body.appendChild(t), t.click(), URL.revokeObjectURL(e), document.body.removeChild(t);
668
677
  }
669
- }, k = {
678
+ }, j = {
670
679
  /**
671
680
  * echarts动画函数
672
681
  * @param option echarts配置
@@ -710,7 +719,7 @@ const S = {
710
719
  return o < s ? -1 : o > s ? 1 : 0;
711
720
  }) : void 0;
712
721
  }
713
- }, j = {
722
+ }, $ = {
714
723
  /**
715
724
  * 角度(度数)转弧度
716
725
  * 在数学和编程里,角度有两种常用单位,分别是度(°)和弧度(rad)。
@@ -796,7 +805,7 @@ const S = {
796
805
  return { segments: r, total: o };
797
806
  }
798
807
  };
799
- class $ {
808
+ class N {
800
809
  /**
801
810
  * 转换为标准金额格式(带千分位和两位小数)
802
811
  * @param num 要转换的数字
@@ -851,7 +860,7 @@ class $ {
851
860
  }
852
861
  }
853
862
  }
854
- const N = {
863
+ const P = {
855
864
  /**
856
865
  * 中文姓名脱敏
857
866
  * @param name 姓名
@@ -900,7 +909,7 @@ const N = {
900
909
  }, Symbol.toStringTag, { value: "Module" })), E = (e) => e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","), C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
901
910
  __proto__: null,
902
911
  toMoney: E
903
- }, Symbol.toStringTag, { value: "Module" })), P = {
912
+ }, Symbol.toStringTag, { value: "Module" })), F = {
904
913
  ...x,
905
914
  ...C,
906
915
  /**
@@ -911,14 +920,14 @@ const N = {
911
920
  isNumber(e) {
912
921
  return typeof e == "number" && !isNaN(e);
913
922
  }
914
- }, F = {
923
+ }, V = {
915
924
  /**
916
925
  * 判断对象是否为空
917
926
  * @param obj 对象
918
927
  * @returns 是否为空。true 为空;false 不为空
919
928
  */
920
929
  isEmptyObject(e) {
921
- return e ? Object.keys(e).length === 0 && e.constructor === Object : !0;
930
+ return !e || JSON.stringify(e) === "{}" ? !0 : Object.keys(e).length === 0 && e.constructor === Object;
922
931
  },
923
932
  /**
924
933
  * 复制对象【对象的浅拷贝 把obj1的成员,复制给obj2】
@@ -942,7 +951,7 @@ const N = {
942
951
  r instanceof Object ? (n[t] = {}, this.deepCopy(r, n[t])) : r instanceof Array ? (n[t] = [], this.deepCopy(r, n[t])) : n[t] = e[t];
943
952
  }
944
953
  }
945
- }, V = {
954
+ }, W = {
946
955
  /**
947
956
  * 脱敏
948
957
  * @param phone 电话号码/手机号码
@@ -951,7 +960,7 @@ const N = {
951
960
  desensitize(e) {
952
961
  return e ? e.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2") || e.slice(0, 3) + "****" + e.slice(7) : "";
953
962
  }
954
- }, W = {
963
+ }, Y = {
955
964
  /**
956
965
  * 生成随机颜色
957
966
  * @returns 随机颜色值
@@ -975,7 +984,7 @@ const N = {
975
984
  uniqueId() {
976
985
  return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
977
986
  }
978
- }, Y = {
987
+ }, z = {
979
988
  /**
980
989
  * 验证手机号
981
990
  */
@@ -1012,7 +1021,7 @@ const N = {
1012
1021
  * 验证0.01~0.99正则:最多两位小数。0.1、0.10、0.9、0.90
1013
1022
  */
1014
1023
  decimal: /^0\.(0[1-9]|[1-9][0-9]*)$/
1015
- }, z = {
1024
+ }, q = {
1016
1025
  /**
1017
1026
  * 通过key值获取 localStorage 中存储的某个值
1018
1027
  * @param key 获取的key
@@ -1059,7 +1068,7 @@ const N = {
1059
1068
  removeSession(e) {
1060
1069
  sessionStorage.removeItem(e);
1061
1070
  }
1062
- }, q = {
1071
+ }, Z = {
1063
1072
  /**
1064
1073
  * 判断某元素是否在字符串中-比includes()方法更兼容,includes为ES6新增方法,IE不支持。小程序也不支持
1065
1074
  * @param str 字符串
@@ -1153,7 +1162,7 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1153
1162
  __proto__: null,
1154
1163
  getQueryInfoByName: B,
1155
1164
  getQueryParam: D
1156
- }, Symbol.toStringTag, { value: "Module" })), Z = {
1165
+ }, Symbol.toStringTag, { value: "Module" })), J = {
1157
1166
  ...R,
1158
1167
  /**
1159
1168
  * 获取当前域名
@@ -1169,7 +1178,7 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1169
1178
  getPath() {
1170
1179
  return window.location.pathname;
1171
1180
  }
1172
- }, J = {
1181
+ }, X = {
1173
1182
  /**
1174
1183
  * 处理瀑布流数据,使其竖向瀑布流布局呈现横向瀑布流的展现形式。适用于 column-gap: 20rpx; column-count: 2; 布局的瀑布流
1175
1184
  * @param list 瀑布流数据-数组
@@ -1208,24 +1217,25 @@ const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1208
1217
  };
1209
1218
  export {
1210
1219
  _ as Base64Utils,
1211
- $ as MoneyFormatter,
1220
+ N as MoneyFormatter,
1212
1221
  A as arrayUtils,
1213
1222
  S as booleanUtils,
1214
- L as cookieUtils,
1215
- O as dateUtils,
1216
- T as documentUtils,
1217
- I as downloadUtils,
1218
- k as echartsUtils,
1223
+ O as commonUtils,
1224
+ T as cookieUtils,
1225
+ L as dateUtils,
1226
+ I as documentUtils,
1227
+ k as downloadUtils,
1228
+ j as echartsUtils,
1219
1229
  H as letterUtils,
1220
- j as mapUtils,
1221
- N as nameUtils,
1222
- P as numberUtils,
1223
- F as objectUtils,
1224
- V as phoneUtils,
1225
- W as randomUtils,
1226
- Y as regexpUtils,
1227
- z as storageUtils,
1228
- q as stringUtils,
1229
- Z as urlUtils,
1230
- J as waterfallUtils
1230
+ $ as mapUtils,
1231
+ P as nameUtils,
1232
+ F as numberUtils,
1233
+ V as objectUtils,
1234
+ W as phoneUtils,
1235
+ Y as randomUtils,
1236
+ z as regexpUtils,
1237
+ q as storageUtils,
1238
+ Z as stringUtils,
1239
+ J as urlUtils,
1240
+ X as waterfallUtils
1231
1241
  };
@@ -1 +1 @@
1
- (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.yhkitUtils={}))})(this,function(d){"use strict";const A=Object.assign({unique(e){return e?Array.from(new Set(e)):[]},isExist(e,n){return!e||!n?!1:e.indexOf(n)!==-1},countOfAppear(e,n){let t=0;for(const r of e)r===n&&t++;return t},indexsOfAppear(e,n){let t=-1;const r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},sort(e,n="asc"){return e?e.sort((t,r)=>n==="asc"?t>r?1:-1:t<r?1:-1):[]},shuffle(e){if(!e)return[];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return e},getMaxValue(e){return e?Math.max(...e):0},getMinValue(e){return e?Math.min(...e):0},getMinValueAndIndex(e){if(e.length===0)return{value:0,index:0};const n={value:e[0],index:0};for(let t=1,r=e.length;t<r;t++){const o=e[t];n.value>o&&(n.value=o,n.index=t)}return n},getMaxValueAndIndex(e){return e.length===0?{value:0,index:0}:e.reduce((n,t,r)=>t<n.value?{value:t,index:r}:n,{value:e[0],index:0})}},{...Object.freeze(Object.defineProperty({__proto__:null,toEnumObj:(e,n="value")=>{if(!e||!e.length)return{};const t={};return e.forEach(r=>{const o=Object.assign({label:r.label,text:r.label},r);t[r[n]]=o}),t}},Symbol.toStringTag,{value:"Module"}))});class M{static BASE64_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";static toBlob(n,t="",r=512){const s=(n.split(",")[1]||n).replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),l=s+c;try{const i=atob(l),h=[];for(let a=0;a<i.length;a+=r){const u=i.slice(a,a+r),f=new Array(u.length);for(let g=0;g<u.length;g++)f[g]=u.charCodeAt(g);const y=new Uint8Array(f);h.push(y)}return new Blob(h,{type:t})}catch(i){return console.error("Failed to convert base64 to blob:",i),null}}static toFile(n,t="file.txt",r="text/plain"){const s=n.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),l=s+c,i=atob(l),h=[];for(let u=0;u<i.length;u+=512){const f=i.slice(u,u+512),y=new Array(f.length);for(let g=0;g<f.length;g++)y[g]=f.charCodeAt(g);h.push(new Uint8Array(y))}const a=new Blob(h,{type:r});return new File([a],t,{type:r})}static encode(n){if(!n)return"";const t=this._stringToUtf8Bytes(n);return this._bytesToBase64(t)}static decode(n){if(!n)return"";n=n.replace(/\s/g,"");const t=this._base64ToBytes(n);return this._utf8BytesToString(t)}static _stringToUtf8Bytes(n){const t=[];for(let r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<128)t.push(o);else if(o<2048)t.push(192|o>>6),t.push(128|o&63);else if(o<55296||o>=57344)t.push(224|o>>12),t.push(128|o>>6&63),t.push(128|o&63);else{r++;const s=o,c=n.charCodeAt(r);if(isNaN(c))throw new Error("代理对不完整");o=65536+((s&1023)<<10)+(c&1023),t.push(240|o>>18),t.push(128|o>>12&63),t.push(128|o>>6&63),t.push(128|o&63)}}return t}static _utf8BytesToString(n){let t="",r=0;for(;r<n.length;){const o=n[r++];if(o<128)t+=String.fromCharCode(o);else if(o>=192&&o<224){const s=n[r++]&63;t+=String.fromCharCode((o&31)<<6|s)}else if(o>=224&&o<240){const s=n[r++]&63,c=n[r++]&63;t+=String.fromCharCode((o&15)<<12|s<<6|c)}else if(o>=240&&o<248){const s=n[r++]&63,c=n[r++]&63,l=n[r++]&63,i=(o&7)<<18|s<<12|c<<6|l,h=Math.floor((i-65536)/1024)+55296,a=(i-65536)%1024+56320;t+=String.fromCharCode(h,a)}else t+="�"}return t}static _bytesToBase64(n){let t="",r=0;for(;r<n.length;){const o=n[r++],s=r<n.length,c=s?n[r++]:0,l=r<n.length,i=l?n[r++]:0,h=o>>2,a=(o&3)<<4|c>>4,u=(c&15)<<2|i>>6,f=i&63;s?l?t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(u)+this.BASE64_CHARS.charAt(f):t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(u)+"=":t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+"=="}return t}static _base64ToBytes(n){const t=n.length;let r=0;t>=2&&(n[t-1]==="="&&r++,n[t-2]==="="&&r++);const o=Math.floor(t*3/4)-r,s=new Array(o),c=new Array(256).fill(-1);for(let h=0;h<this.BASE64_CHARS.length;h++)c[this.BASE64_CHARS.charCodeAt(h)]=h;let l=0,i=0;for(;i<t;){const h=c[n.charCodeAt(i++)],a=c[n.charCodeAt(i++)],u=i<t?c[n.charCodeAt(i++)]:-1,f=i<t?c[n.charCodeAt(i++)]:-1;if(h===-1||a===-1)throw new Error("无效的 Base64 字符");const y=h<<2|a>>4;if(s[l++]=y,u!==-1){const g=(a&15)<<4|u>>2;if(s[l++]=g,f!==-1){const p=(u&3)<<6|f;s[l++]=p}}}return s}}const S={isEmptyString(e){return typeof e=="string"&&e.trim()===""},isNumber(e){return typeof e=="number"&&!isNaN(e)},isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)},isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},isBoolean(e){return typeof e=="boolean"},isArray(e){return Array.isArray(e)},isFunction(e){return typeof e=="function"},isPromise(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"},isElement(e){return e instanceof Element},isPhone(e){return/^1[3-9]\d{9}$/.test(e)},isEmail(e){return/^[\w.-]+@[\w.-]+\.\w+$/.test(e)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},isImageLoaded(e){return e.complete&&e.naturalWidth!==0},isInViewport(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=window.innerHeight&&n.right<=window.innerWidth},isLeapYear(e){return e%4===0&&e%100!==0||e%400===0},isMobile(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}},U={getCookie(e){if(!e)return;const n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?decodeURIComponent(n[2]):null},setCookie(e,n,t=7){const r=new Date;r.setTime(r.getTime()+t*24*60*60*1e3),document.cookie=`${e}=${encodeURIComponent(n)};expires=${r.toUTCString()};path=/`},deleteCookie(e){this.setCookie(e,"",-1)}},E={getTimeString(e,n=!1){return n?new Date().toLocaleString(e,{hour12:!0}):new Date().toLocaleString("chinese",{hour12:!1})},diffDays(e,n){const t=new Date(e).getTime(),r=new Date(n).getTime();return t>r?Math.abs(Math.floor((t-r)/(24*3600*1e3))):Math.abs(Math.floor((r-t)/(24*3600*1e3)))},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)},getWhichDays(e,n,t){let r=t;for(let o=1;o<n;o++)switch(o){case 1:case 3:case 5:case 7:case 8:case 10:case 12:r+=31;break;case 2:S.isLeapYear(e)?r+=29:r+=28;break;default:r+=30;break}return r},getTimeStringAutoShort2(e,n){const t=new Date,r=new Date(e),o=t.getFullYear(),s=t.getMonth()+1,c=t.getDate(),l=r.getFullYear(),i=r.getMonth()+1,h=r.getDate();let a="";const u=n?" "+this.formatDate(r,"hh:mm"):"";if(o===l){const g=t.getTime()-e;if(s===i&&c===h)g<60*1e3?a="刚刚":a=this.formatDate(r,"hh:mm");else{const p=new Date;p.setDate(p.getDate()-1);const b=new Date;if(b.setDate(b.getDate()-2),i===p.getMonth()+1&&h===p.getDate())a="昨天"+u;else if(i===b.getMonth()+1&&h===b.getDate())a="前天"+u;else if(g/36e5<=7*24){const m=new Array(7);m[0]="星期日",m[1]="星期一",m[2]="星期二",m[3]="星期三",m[4]="星期四",m[5]="星期五",m[6]="星期六",a=m[r.getDay()]+u}else a=this.formatDate(r,"yyyy/M/d")+u}}else a=this.formatDate(r,"yyyy/M/d")+u;return a},formatDate(e,n){const t={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(n)&&(n=n.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(const r in t)new RegExp("("+r+")").test(n)&&(n=n.replace(RegExp.$1,RegExp.$1.length===1?t[r]:("00"+t[r]).substr((""+t[r]).length)));return n}},C={getOffsetTop(e){if(!e)throw new Error("Element is not provided");if(e instanceof SVGElement){const t=e.getBoundingClientRect(),r=window.pageYOffset||document.documentElement.scrollTop;return t.top+r}let n=0;for(;e;)n+=e.offsetTop,e=e.offsetParent;return n},getScrollValue(){const e={scrollLeft:0,scrollTop:0};return e.scrollLeft=document.body.scrollLeft||document.documentElement.scrollLeft,e.scrollTop=document.body.scrollTop||document.documentElement.scrollTop,e},getPageValue(e){e=e||window.event;const n=e.pageX||e.clientX+this.getScrollValue().scrollLeft,t=e.pageY||e.clientY+this.getScrollValue().scrollTop;return{pageX:n,pageY:t}},addEventListener(e,n,t){e.addEventListener?e.addEventListener(n,t):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t},getViewportWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},getViewportHeight(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}},B={saveAsBlob(e,n){const t=document.createElement("a"),r=window.URL.createObjectURL(e);t.href=r,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(r),document.body.removeChild(t)},saveAsUrl(e,n){const t=document.createElement("a");t.href=e,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(e),document.body.removeChild(t)}},D={animate(e,n){let t=-1;const r=e.series[0].data.length;let o;o=setInterval(()=>{n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t}),t=(t+1)%r,n.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:t}),n.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:t}),t>r&&(t=0)},2e3),n.on("mouseover",()=>{clearInterval(o),n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t})})}},R={sortFromA2Z(e){return e?.length?e.sort((t,r)=>{const o=t.toUpperCase(),s=r.toUpperCase();return o<s?-1:o>s?1:0}):void 0}},v={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,r){const o=this.degrees2Radians(e),s=this.degrees2Radians(t),c=o-s,l=this.degrees2Radians(n)-this.degrees2Radians(r);let i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(c/2),2)+Math.cos(o)*Math.cos(s)*Math.pow(Math.sin(l/2),2)));return i=i*6378.137,i=Math.round(i*1e4)/1e4,i=+i.toFixed(2),console.log("经纬度计算的距离为:"+i),i},calculateDistanceByHaversine(e,n,t="km"){const r=this,o=e.longitude??e.lng,s=e.latitude??e.lat,c=n.longitude??n.lng,l=n.latitude??n.lat;if(o===void 0||s===void 0||c===void 0||l===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const i=6371,h=r.degrees2Radians(s),a=r.degrees2Radians(l),u=r.degrees2Radians(l-s),f=r.degrees2Radians(c-o),y=Math.sin(u/2)*Math.sin(u/2)+Math.cos(h)*Math.cos(a)*Math.sin(f/2)*Math.sin(f/2),g=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y)),p=i*g;switch(t){case"m":return p*1e3;case"mi":return p*.621371;case"nmi":return p*.539957;default:return p}},calculateDistancesByHaversine(e,n="km",t=!1){if(e.length<2)return{segments:[],total:0};const r=[];let o=0;for(let s=0;s<e.length-1;s++){const c=this.calculateDistanceByHaversine(e[s],e[s+1],n);r.push(c),o+=c}if(t&&e.length>2){const s=this.calculateDistanceByHaversine(e[e.length-1],e[0],n);r.push(s),o+=s}return{segments:r,total:o}}};class x{static toStandardFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(!isFinite(t))throw new Error("输入是无穷大");return t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}catch(t){return console.error("格式化失败:",t),"格式错误"}}static toChineseFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(t>9999999999999e-2||t<-9999999999999e-2)throw new Error("输入数字超出范围");const r=t<0,o=Math.abs(t),s=Math.floor(o),c=Math.round((o-s)*100),l=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],i=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],h=["角","分"];let a="",u=s;if(u===0)a=l[0];else{let g=0;for(;u>0;){const p=u%10;p!==0?a=l[p]+i[g]+a:a.charAt(0)!==l[0]&&(a=l[p]+a),u=Math.floor(u/10),g++}a=a.replace(/零+/g,"零"),a=a.replace(/零+$/,"")}let f="";if(c>0){const g=Math.floor(c/10),p=c%10;g>0&&(f+=l[g]+h[0]),p>0&&(f+=l[p]+h[1])}else f="整";let y=(r?"负":"")+a+"圆"+f;return y==="零圆整"&&(y="零圆"),y}catch(t){return console.error("转换失败:",t),"格式错误"}}}const T={desensitizeChineseName(e,n={}){const{keepLength:t=1,keepLast:r=!1}=n;if(!e||e.length===0||e.trim().length===0)throw new Error("姓名不能为空");if(typeof e!="string")throw new Error("姓名必须是字符串");if(e.length<=1)return e;const o=["欧阳","司马","上官","东方","独孤","南宫","闻人","夏侯","诸葛","尉迟","公孙","长孙","宇文","司徒","慕容"];n.compoundSurname&&n.compoundSurname.trim().length>0&&!o.includes(n.compoundSurname)&&o.push(n.compoundSurname);let s="";o.some(l=>e.startsWith(l))?s=o.find(l=>e.startsWith(l))||"":s=e[0]||"";const c=Math.max(t,s.length);if(c>=e.length)return e;if(r&&e.length>2){const l=e.slice(0,c),i=e.slice(-1),h=e.length-c-1;return`${l}${"*".repeat(h)}${i}`}return`${e.slice(0,c)}${"*".repeat(e.length-c)}`}},_={...Object.freeze(Object.defineProperty({__proto__:null,toLetter:e=>e>25||e<0?"":"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e]},Symbol.toStringTag,{value:"Module"})),...Object.freeze(Object.defineProperty({__proto__:null,toMoney:e=>e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Symbol.toStringTag,{value:"Module"})),isNumber(e){return typeof e=="number"&&!isNaN(e)}},O={isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},copy(e,n){for(const t in e)n[t]=e[t]},deepCopy(e,n){for(const t in e){const r=e[t];r instanceof Object?(n[t]={},this.deepCopy(r,n[t])):r instanceof Array?(n[t]=[],this.deepCopy(r,n[t])):n[t]=e[t]}}},L={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},k={color:function(){return`#${Math.random().toString(16).slice(2,8)}`},int(e,n){return Math.floor(Math.random()*(n-e+1))+e},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)}},j={mobile:/^1[3-9]\d{9}$/,email:/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,chinese:/^[\u4e00-\u9fa5]+$/,english:/^[a-zA-Z]+$/,chineseStart:/^[\u4e00-\u9fa5]+\w*$/,integer:/^\d+$/,integerAndzero:/^(0|[1-9]+[0-9]*)$/,strongPassword:/^(?!.*[\s\p{C}])(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[\d\W])|(?=.*\d)(?=.*[^\w\s])).{8,}$/u,decimal:/^0\.(0[1-9]|[1-9][0-9]*)$/},I={getLocal(e){return localStorage.getItem(e)},setLocal(e,n){localStorage.setItem(e,n)},removeLocal(e){localStorage.removeItem(e)},getSession(e){return sessionStorage.getItem(e)},setSession(e,n){sessionStorage.setItem(e,n)},removeSession(e){sessionStorage.removeItem(e)}},H={isExist(e,n){if(!e||!n)return!1;const t=e.split(",");return console.log("判断某元素是否在字符串中",t.indexOf(n)===-1),t.indexOf(n)!==-1},includes(e,n){return!e||!n?!1:e.includes(n)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},indexsOfAppear(e,n){let t=-1;const r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},getMaxTimesAndVal(e){const n=[0,""],t={};for(let s=0;s<e.length;s++){const c=e.charAt(s);t[c]?t[c]++:t[c]=1}let r=1;for(const s in t)r<t[s]&&(r=t[s]);const o=[];for(const s in t)r==t[s]&&o.push(s);return n[0]=r,n[1]=o.join(),n},mask(e,n,t){if(!e)throw new Error("字符串为空");if(typeof n!="number"||typeof t!="number")throw new Error("开始位置或结束位置为空");if(n<0||t>e.length||n>t)throw new Error("开始位置小于0或结束位置超出字符串长度或开始位置大于结束位置");return e.slice(0,n)+"*".repeat(t-n+1)+e.slice(t)}},$=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function P(e){return new URLSearchParams(window.location.search).get(e)}const N={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:$,getQueryParam:P},Symbol.toStringTag,{value:"Module"})),getHost(){return window.location.host},getPath(){return window.location.pathname}},F={toList(e,n=2){console.log(e,n);const t={};for(let o=0;o<n;o++)t[o]=[];e.forEach((o,s)=>t[s%n].push(o));const r=[];for(const o in t)r.push(...t[o]);return r},jsLayout(e,n,t){const r=e.offsetWidth,o=n[0].offsetWidth,s=parseInt((r/o).toString()),c=(r-o*s)/(s-1),l=[];for(let i=0,h=n.length;i<h;i++){const a=n[i];if(i<s)a.style.left=(o+c)*i+"px",l[i]=a.offsetHeight;else{const{index:u,value:f}=A.getMinValueAndIndex(l);a.style.left=(o+c)*u+"px",a.style.top=f+t+"px",l[u]=a.offsetHeight+t+f}}}};d.Base64Utils=M,d.MoneyFormatter=x,d.arrayUtils=A,d.booleanUtils=S,d.cookieUtils=U,d.dateUtils=E,d.documentUtils=C,d.downloadUtils=B,d.echartsUtils=D,d.letterUtils=R,d.mapUtils=v,d.nameUtils=T,d.numberUtils=_,d.objectUtils=O,d.phoneUtils=L,d.randomUtils=k,d.regexpUtils=j,d.storageUtils=I,d.stringUtils=H,d.urlUtils=N,d.waterfallUtils=F,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.yhkitUtils={}))})(this,function(d){"use strict";const A=Object.assign({unique(e){return e?Array.from(new Set(e)):[]},isExist(e,n){return!e||!n?!1:e.indexOf(n)!==-1},countOfAppear(e,n){let t=0;for(const r of e)r===n&&t++;return t},indexsOfAppear(e,n){let t=-1;const r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},sort(e,n="asc"){return e?e.sort((t,r)=>n==="asc"?t>r?1:-1:t<r?1:-1):[]},shuffle(e){if(!e)return[];for(let n=e.length-1;n>0;n--){const t=Math.floor(Math.random()*(n+1));[e[n],e[t]]=[e[t],e[n]]}return e},getMaxValue(e){return e?Math.max(...e):0},getMinValue(e){return e?Math.min(...e):0},getMinValueAndIndex(e){if(e.length===0)return{value:0,index:0};const n={value:e[0],index:0};for(let t=1,r=e.length;t<r;t++){const o=e[t];n.value>o&&(n.value=o,n.index=t)}return n},getMaxValueAndIndex(e){return e.length===0?{value:0,index:0}:e.reduce((n,t,r)=>t<n.value?{value:t,index:r}:n,{value:e[0],index:0})}},{...Object.freeze(Object.defineProperty({__proto__:null,toEnumObj:(e,n="value")=>{if(!e||!e.length)return{};const t={};return e.forEach(r=>{const o=Object.assign({label:r.label,text:r.label},r);t[r[n]]=o}),t}},Symbol.toStringTag,{value:"Module"}))});class M{static BASE64_CHARS="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";static toBlob(n,t="",r=512){const s=(n.split(",")[1]||n).replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),l=s+c;try{const i=atob(l),h=[];for(let a=0;a<i.length;a+=r){const u=i.slice(a,a+r),f=new Array(u.length);for(let g=0;g<u.length;g++)f[g]=u.charCodeAt(g);const y=new Uint8Array(f);h.push(y)}return new Blob(h,{type:t})}catch(i){return console.error("Failed to convert base64 to blob:",i),null}}static toFile(n,t="file.txt",r="text/plain"){const s=n.replace(/^data:.+;base64,/,"").replace(/-/g,"+").replace(/_/g,"/"),c="=".repeat((4-s.length%4)%4),l=s+c,i=atob(l),h=[];for(let u=0;u<i.length;u+=512){const f=i.slice(u,u+512),y=new Array(f.length);for(let g=0;g<f.length;g++)y[g]=f.charCodeAt(g);h.push(new Uint8Array(y))}const a=new Blob(h,{type:r});return new File([a],t,{type:r})}static encode(n){if(!n)return"";const t=this._stringToUtf8Bytes(n);return this._bytesToBase64(t)}static decode(n){if(!n)return"";n=n.replace(/\s/g,"");const t=this._base64ToBytes(n);return this._utf8BytesToString(t)}static _stringToUtf8Bytes(n){const t=[];for(let r=0;r<n.length;r++){let o=n.charCodeAt(r);if(o<128)t.push(o);else if(o<2048)t.push(192|o>>6),t.push(128|o&63);else if(o<55296||o>=57344)t.push(224|o>>12),t.push(128|o>>6&63),t.push(128|o&63);else{r++;const s=o,c=n.charCodeAt(r);if(isNaN(c))throw new Error("代理对不完整");o=65536+((s&1023)<<10)+(c&1023),t.push(240|o>>18),t.push(128|o>>12&63),t.push(128|o>>6&63),t.push(128|o&63)}}return t}static _utf8BytesToString(n){let t="",r=0;for(;r<n.length;){const o=n[r++];if(o<128)t+=String.fromCharCode(o);else if(o>=192&&o<224){const s=n[r++]&63;t+=String.fromCharCode((o&31)<<6|s)}else if(o>=224&&o<240){const s=n[r++]&63,c=n[r++]&63;t+=String.fromCharCode((o&15)<<12|s<<6|c)}else if(o>=240&&o<248){const s=n[r++]&63,c=n[r++]&63,l=n[r++]&63,i=(o&7)<<18|s<<12|c<<6|l,h=Math.floor((i-65536)/1024)+55296,a=(i-65536)%1024+56320;t+=String.fromCharCode(h,a)}else t+="�"}return t}static _bytesToBase64(n){let t="",r=0;for(;r<n.length;){const o=n[r++],s=r<n.length,c=s?n[r++]:0,l=r<n.length,i=l?n[r++]:0,h=o>>2,a=(o&3)<<4|c>>4,u=(c&15)<<2|i>>6,f=i&63;s?l?t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(u)+this.BASE64_CHARS.charAt(f):t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+this.BASE64_CHARS.charAt(u)+"=":t+=this.BASE64_CHARS.charAt(h)+this.BASE64_CHARS.charAt(a)+"=="}return t}static _base64ToBytes(n){const t=n.length;let r=0;t>=2&&(n[t-1]==="="&&r++,n[t-2]==="="&&r++);const o=Math.floor(t*3/4)-r,s=new Array(o),c=new Array(256).fill(-1);for(let h=0;h<this.BASE64_CHARS.length;h++)c[this.BASE64_CHARS.charCodeAt(h)]=h;let l=0,i=0;for(;i<t;){const h=c[n.charCodeAt(i++)],a=c[n.charCodeAt(i++)],u=i<t?c[n.charCodeAt(i++)]:-1,f=i<t?c[n.charCodeAt(i++)]:-1;if(h===-1||a===-1)throw new Error("无效的 Base64 字符");const y=h<<2|a>>4;if(s[l++]=y,u!==-1){const g=(a&15)<<4|u>>2;if(s[l++]=g,f!==-1){const p=(u&3)<<6|f;s[l++]=p}}}return s}}const S={isEmptyString(e){return typeof e=="string"&&e.trim()===""},isNumber(e){return typeof e=="number"&&!isNaN(e)},isObject(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)},isEmptyObject(e){return e?Object.keys(e).length===0&&e.constructor===Object:!0},isBoolean(e){return typeof e=="boolean"},isArray(e){return Array.isArray(e)},isFunction(e){return typeof e=="function"},isPromise(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"},isElement(e){return e instanceof Element},isPhone(e){return/^1[3-9]\d{9}$/.test(e)},isEmail(e){return/^[\w.-]+@[\w.-]+\.\w+$/.test(e)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},isImageLoaded(e){return e.complete&&e.naturalWidth!==0},isInViewport(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=window.innerHeight&&n.right<=window.innerWidth},isLeapYear(e){return e%4===0&&e%100!==0||e%400===0},isMobile(){return/Mobi|Android|iPhone/i.test(navigator.userAgent)}},U={getType(e){return Object.prototype.toString.call(e).replace(/\[object\s(\w+)\]/,"$1")}},E={getCookie(e){if(!e)return;const n=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return n?decodeURIComponent(n[2]):null},setCookie(e,n,t=7){const r=new Date;r.setTime(r.getTime()+t*24*60*60*1e3),document.cookie=`${e}=${encodeURIComponent(n)};expires=${r.toUTCString()};path=/`},deleteCookie(e){this.setCookie(e,"",-1)}},C={getTimeString(e,n=!1){return n?new Date().toLocaleString(e,{hour12:!0}):new Date().toLocaleString("chinese",{hour12:!1})},diffDays(e,n){const t=new Date(e).getTime(),r=new Date(n).getTime();return t>r?Math.abs(Math.floor((t-r)/(24*3600*1e3))):Math.abs(Math.floor((r-t)/(24*3600*1e3)))},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)},getWhichDays(e,n,t){let r=t;for(let o=1;o<n;o++)switch(o){case 1:case 3:case 5:case 7:case 8:case 10:case 12:r+=31;break;case 2:S.isLeapYear(e)?r+=29:r+=28;break;default:r+=30;break}return r},getTimeStringAutoShort2(e,n){const t=new Date,r=new Date(e),o=t.getFullYear(),s=t.getMonth()+1,c=t.getDate(),l=r.getFullYear(),i=r.getMonth()+1,h=r.getDate();let a="";const u=n?" "+this.formatDate(r,"hh:mm"):"";if(o===l){const g=t.getTime()-e;if(s===i&&c===h)g<60*1e3?a="刚刚":a=this.formatDate(r,"hh:mm");else{const p=new Date;p.setDate(p.getDate()-1);const b=new Date;if(b.setDate(b.getDate()-2),i===p.getMonth()+1&&h===p.getDate())a="昨天"+u;else if(i===b.getMonth()+1&&h===b.getDate())a="前天"+u;else if(g/36e5<=7*24){const m=new Array(7);m[0]="星期日",m[1]="星期一",m[2]="星期二",m[3]="星期三",m[4]="星期四",m[5]="星期五",m[6]="星期六",a=m[r.getDay()]+u}else a=this.formatDate(r,"yyyy/M/d")+u}}else a=this.formatDate(r,"yyyy/M/d")+u;return a},formatDate(e,n){const t={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};/(y+)/.test(n)&&(n=n.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length)));for(const r in t)new RegExp("("+r+")").test(n)&&(n=n.replace(RegExp.$1,RegExp.$1.length===1?t[r]:("00"+t[r]).substr((""+t[r]).length)));return n}},B={getOffsetTop(e){if(!e)throw new Error("Element is not provided");if(e instanceof SVGElement){const t=e.getBoundingClientRect(),r=window.pageYOffset||document.documentElement.scrollTop;return t.top+r}let n=0;for(;e;)n+=e.offsetTop,e=e.offsetParent;return n},getScrollValue(){const e={scrollLeft:0,scrollTop:0};return e.scrollLeft=document.body.scrollLeft||document.documentElement.scrollLeft,e.scrollTop=document.body.scrollTop||document.documentElement.scrollTop,e},getPageValue(e){e=e||window.event;const n=e.pageX||e.clientX+this.getScrollValue().scrollLeft,t=e.pageY||e.clientY+this.getScrollValue().scrollTop;return{pageX:n,pageY:t}},addEventListener(e,n,t){e.addEventListener?e.addEventListener(n,t):e.attachEvent?e.attachEvent("on"+n,t):e["on"+n]=t},getViewportWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},getViewportHeight(){return window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}},D={saveAsBlob(e,n){const t=document.createElement("a"),r=window.URL.createObjectURL(e);t.href=r,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(r),document.body.removeChild(t)},saveAsUrl(e,n){const t=document.createElement("a");t.href=e,t.download=n,document.body.appendChild(t),t.click(),URL.revokeObjectURL(e),document.body.removeChild(t)}},R={animate(e,n){let t=-1;const r=e.series[0].data.length;let o;o=setInterval(()=>{n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t}),t=(t+1)%r,n.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:t}),n.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:t}),t>r&&(t=0)},2e3),n.on("mouseover",()=>{clearInterval(o),n.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:t})})}},v={sortFromA2Z(e){return e?.length?e.sort((t,r)=>{const o=t.toUpperCase(),s=r.toUpperCase();return o<s?-1:o>s?1:0}):void 0}},x={degrees2Radians(e){return e*Math.PI/180},getDistance(e,n,t,r){const o=this.degrees2Radians(e),s=this.degrees2Radians(t),c=o-s,l=this.degrees2Radians(n)-this.degrees2Radians(r);let i=2*Math.asin(Math.sqrt(Math.pow(Math.sin(c/2),2)+Math.cos(o)*Math.cos(s)*Math.pow(Math.sin(l/2),2)));return i=i*6378.137,i=Math.round(i*1e4)/1e4,i=+i.toFixed(2),console.log("经纬度计算的距离为:"+i),i},calculateDistanceByHaversine(e,n,t="km"){const r=this,o=e.longitude??e.lng,s=e.latitude??e.lat,c=n.longitude??n.lng,l=n.latitude??n.lat;if(o===void 0||s===void 0||c===void 0||l===void 0)throw new Error("无效的坐标格式,缺少经纬度信息");const i=6371,h=r.degrees2Radians(s),a=r.degrees2Radians(l),u=r.degrees2Radians(l-s),f=r.degrees2Radians(c-o),y=Math.sin(u/2)*Math.sin(u/2)+Math.cos(h)*Math.cos(a)*Math.sin(f/2)*Math.sin(f/2),g=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y)),p=i*g;switch(t){case"m":return p*1e3;case"mi":return p*.621371;case"nmi":return p*.539957;default:return p}},calculateDistancesByHaversine(e,n="km",t=!1){if(e.length<2)return{segments:[],total:0};const r=[];let o=0;for(let s=0;s<e.length-1;s++){const c=this.calculateDistanceByHaversine(e[s],e[s+1],n);r.push(c),o+=c}if(t&&e.length>2){const s=this.calculateDistanceByHaversine(e[e.length-1],e[0],n);r.push(s),o+=s}return{segments:r,total:o}}};class O{static toStandardFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(!isFinite(t))throw new Error("输入是无穷大");return t.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}catch(t){return console.error("格式化失败:",t),"格式错误"}}static toChineseFormat(n){try{const t=typeof n=="string"?parseFloat(n):n;if(isNaN(t))throw new Error("输入不是有效的数字");if(t>9999999999999e-2||t<-9999999999999e-2)throw new Error("输入数字超出范围");const r=t<0,o=Math.abs(t),s=Math.floor(o),c=Math.round((o-s)*100),l=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],i=["","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],h=["角","分"];let a="",u=s;if(u===0)a=l[0];else{let g=0;for(;u>0;){const p=u%10;p!==0?a=l[p]+i[g]+a:a.charAt(0)!==l[0]&&(a=l[p]+a),u=Math.floor(u/10),g++}a=a.replace(/零+/g,"零"),a=a.replace(/零+$/,"")}let f="";if(c>0){const g=Math.floor(c/10),p=c%10;g>0&&(f+=l[g]+h[0]),p>0&&(f+=l[p]+h[1])}else f="整";let y=(r?"负":"")+a+"圆"+f;return y==="零圆整"&&(y="零圆"),y}catch(t){return console.error("转换失败:",t),"格式错误"}}}const T={desensitizeChineseName(e,n={}){const{keepLength:t=1,keepLast:r=!1}=n;if(!e||e.length===0||e.trim().length===0)throw new Error("姓名不能为空");if(typeof e!="string")throw new Error("姓名必须是字符串");if(e.length<=1)return e;const o=["欧阳","司马","上官","东方","独孤","南宫","闻人","夏侯","诸葛","尉迟","公孙","长孙","宇文","司徒","慕容"];n.compoundSurname&&n.compoundSurname.trim().length>0&&!o.includes(n.compoundSurname)&&o.push(n.compoundSurname);let s="";o.some(l=>e.startsWith(l))?s=o.find(l=>e.startsWith(l))||"":s=e[0]||"";const c=Math.max(t,s.length);if(c>=e.length)return e;if(r&&e.length>2){const l=e.slice(0,c),i=e.slice(-1),h=e.length-c-1;return`${l}${"*".repeat(h)}${i}`}return`${e.slice(0,c)}${"*".repeat(e.length-c)}`}},_={...Object.freeze(Object.defineProperty({__proto__:null,toLetter:e=>e>25||e<0?"":"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[e]},Symbol.toStringTag,{value:"Module"})),...Object.freeze(Object.defineProperty({__proto__:null,toMoney:e=>e.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Symbol.toStringTag,{value:"Module"})),isNumber(e){return typeof e=="number"&&!isNaN(e)}},L={isEmptyObject(e){return!e||JSON.stringify(e)==="{}"?!0:Object.keys(e).length===0&&e.constructor===Object},copy(e,n){for(const t in e)n[t]=e[t]},deepCopy(e,n){for(const t in e){const r=e[t];r instanceof Object?(n[t]={},this.deepCopy(r,n[t])):r instanceof Array?(n[t]=[],this.deepCopy(r,n[t])):n[t]=e[t]}}},j={desensitize(e){return e?e.replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2")||e.slice(0,3)+"****"+e.slice(7):""}},k={color:function(){return`#${Math.random().toString(16).slice(2,8)}`},int(e,n){return Math.floor(Math.random()*(n-e+1))+e},uniqueId(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)}},I={mobile:/^1[3-9]\d{9}$/,email:/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,chinese:/^[\u4e00-\u9fa5]+$/,english:/^[a-zA-Z]+$/,chineseStart:/^[\u4e00-\u9fa5]+\w*$/,integer:/^\d+$/,integerAndzero:/^(0|[1-9]+[0-9]*)$/,strongPassword:/^(?!.*[\s\p{C}])(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[\d\W])|(?=.*\d)(?=.*[^\w\s])).{8,}$/u,decimal:/^0\.(0[1-9]|[1-9][0-9]*)$/},H={getLocal(e){return localStorage.getItem(e)},setLocal(e,n){localStorage.setItem(e,n)},removeLocal(e){localStorage.removeItem(e)},getSession(e){return sessionStorage.getItem(e)},setSession(e,n){sessionStorage.setItem(e,n)},removeSession(e){sessionStorage.removeItem(e)}},$={isExist(e,n){if(!e||!n)return!1;const t=e.split(",");return console.log("判断某元素是否在字符串中",t.indexOf(n)===-1),t.indexOf(n)!==-1},includes(e,n){return!e||!n?!1:e.includes(n)},isJSON(e){try{return JSON.parse(e),!0}catch{return!1}},indexsOfAppear(e,n){let t=-1;const r=[];do t=e.indexOf(n,t+1),t!==-1&&r.push(t);while(t!==-1);return r},getMaxTimesAndVal(e){const n=[0,""],t={};for(let s=0;s<e.length;s++){const c=e.charAt(s);t[c]?t[c]++:t[c]=1}let r=1;for(const s in t)r<t[s]&&(r=t[s]);const o=[];for(const s in t)r==t[s]&&o.push(s);return n[0]=r,n[1]=o.join(),n},mask(e,n,t){if(!e)throw new Error("字符串为空");if(typeof n!="number"||typeof t!="number")throw new Error("开始位置或结束位置为空");if(n<0||t>e.length||n>t)throw new Error("开始位置小于0或结束位置超出字符串长度或开始位置大于结束位置");return e.slice(0,n)+"*".repeat(t-n+1)+e.slice(t)}},N=e=>{const t=new RegExp("[?&]"+e+"=([^&#]*)","i").exec(window.location.href);return t?decodeURIComponent(t[1]):null};function P(e){return new URLSearchParams(window.location.search).get(e)}const F={...Object.freeze(Object.defineProperty({__proto__:null,getQueryInfoByName:N,getQueryParam:P},Symbol.toStringTag,{value:"Module"})),getHost(){return window.location.host},getPath(){return window.location.pathname}},V={toList(e,n=2){console.log(e,n);const t={};for(let o=0;o<n;o++)t[o]=[];e.forEach((o,s)=>t[s%n].push(o));const r=[];for(const o in t)r.push(...t[o]);return r},jsLayout(e,n,t){const r=e.offsetWidth,o=n[0].offsetWidth,s=parseInt((r/o).toString()),c=(r-o*s)/(s-1),l=[];for(let i=0,h=n.length;i<h;i++){const a=n[i];if(i<s)a.style.left=(o+c)*i+"px",l[i]=a.offsetHeight;else{const{index:u,value:f}=A.getMinValueAndIndex(l);a.style.left=(o+c)*u+"px",a.style.top=f+t+"px",l[u]=a.offsetHeight+t+f}}}};d.Base64Utils=M,d.MoneyFormatter=O,d.arrayUtils=A,d.booleanUtils=S,d.commonUtils=U,d.cookieUtils=E,d.dateUtils=C,d.documentUtils=B,d.downloadUtils=D,d.echartsUtils=R,d.letterUtils=v,d.mapUtils=x,d.nameUtils=T,d.numberUtils=_,d.objectUtils=L,d.phoneUtils=j,d.randomUtils=k,d.regexpUtils=I,d.storageUtils=H,d.stringUtils=$,d.urlUtils=F,d.waterfallUtils=V,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yh-kit/utils",
3
3
  "private": false,
4
- "version": "1.14.0",
4
+ "version": "1.15.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 通用工具函数
3
+ */
4
+ export declare const commonUtils: {
5
+ /**
6
+ * 获取变量的类型
7
+ * @param val 任意变量
8
+ * @returns 类型字符串
9
+ */
10
+ getType(val: unknown): string;
11
+ };
@@ -1,6 +1,7 @@
1
1
  export * from "./array";
2
2
  export * from "./base64";
3
3
  export * from "./boolean";
4
+ export * from "./common";
4
5
  export * from "./cookie";
5
6
  export * from "./date";
6
7
  export * from "./document";