@allkit/shared 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +1 -0
  2. package/dist/README.md +1 -0
  3. package/dist/clipboard/index.d.ts +9 -0
  4. package/dist/cloneDeep/index.d.ts +47 -0
  5. package/dist/constants.d.ts +26 -0
  6. package/dist/cookie/index.d.ts +31 -0
  7. package/dist/date/index.d.ts +133 -0
  8. package/dist/device/index.d.ts +70 -0
  9. package/dist/element/index.d.ts +12 -0
  10. package/dist/index.d.ts +13 -0
  11. package/dist/is/index.d.ts +181 -0
  12. package/dist/lodash/index.d.ts +184 -0
  13. package/dist/number/index.d.ts +84 -0
  14. package/dist/package.json +21 -0
  15. package/dist/shared.es.d.ts +2 -0
  16. package/dist/shared.es.js +1367 -0
  17. package/dist/shared.umd.js +1 -0
  18. package/dist/storage/index.d.ts +144 -0
  19. package/dist/string/index.d.ts +40 -0
  20. package/dist/timer/index.d.ts +9 -0
  21. package/eslint.config.js +10 -0
  22. package/package.json +26 -0
  23. package/scripts/build.mjs +92 -0
  24. package/skill/SKILL.md +240 -0
  25. package/skill/examples/usage.ts +67 -0
  26. package/skill/references/clipboard.md +39 -0
  27. package/skill/references/cloneDeep.md +60 -0
  28. package/skill/references/cookie.md +56 -0
  29. package/skill/references/date.md +466 -0
  30. package/skill/references/device.md +138 -0
  31. package/skill/references/element.md +99 -0
  32. package/skill/references/is.md +415 -0
  33. package/skill/references/lodash.md +472 -0
  34. package/skill/references/number.md +248 -0
  35. package/skill/references/storage.md +113 -0
  36. package/skill/references/string.md +126 -0
  37. package/skill/references/timer.md +78 -0
  38. package/src/clipboard/index.ts +26 -0
  39. package/src/cloneDeep/__test__/cloneDeep.test.ts +92 -0
  40. package/src/cloneDeep/index.ts +168 -0
  41. package/src/constants.ts +27 -0
  42. package/src/cookie/index.ts +44 -0
  43. package/src/date/__test__/date-diff.test.ts +23 -0
  44. package/src/date/__test__/date-duration.test.ts +140 -0
  45. package/src/date/__test__/date-from.test.ts +64 -0
  46. package/src/date/__test__/date.test.ts +67 -0
  47. package/src/date/index.ts +331 -0
  48. package/src/device/__test__/device.test.ts +138 -0
  49. package/src/device/index.ts +125 -0
  50. package/src/element/index.ts +100 -0
  51. package/src/index.ts +14 -0
  52. package/src/is/__test__/is.test.ts +320 -0
  53. package/src/is/index.ts +293 -0
  54. package/src/lodash/__test__/lodash.test.ts +111 -0
  55. package/src/lodash/__test__/obj-string.test.ts +107 -0
  56. package/src/lodash/__test__/uniqueId.test.ts +40 -0
  57. package/src/lodash/index.ts +396 -0
  58. package/src/number/__test__/number.test.ts +137 -0
  59. package/src/number/index.ts +161 -0
  60. package/src/storage/__test__/storage.test.ts +44 -0
  61. package/src/storage/index.ts +185 -0
  62. package/src/string/__test__/string.test.ts +24 -0
  63. package/src/string/index.ts +49 -0
  64. package/src/timer/index.ts +15 -0
  65. package/tsconfig.json +25 -0
  66. package/types/global.d.ts +13 -0
  67. package/vite.config.ts +16 -0
  68. package/vitest.config.ts +28 -0
@@ -0,0 +1 @@
1
+ (function(u,Y){typeof exports=="object"&&typeof module!="undefined"?Y(exports):typeof define=="function"&&define.amd?define(["exports"],Y):(u=typeof globalThis!="undefined"?globalThis:u||self,Y(u.shared={}))})(this,(function(u){"use strict";var jn=Object.defineProperty,Fn=Object.defineProperties;var Rn=Object.getOwnPropertyDescriptors;var St=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ie=(u,Y,j)=>Y in u?jn(u,Y,{enumerable:!0,configurable:!0,writable:!0,value:j}):u[Y]=j,K=(u,Y)=>{for(var j in Y||(Y={}))oe.call(Y,j)&&ie(u,j,Y[j]);if(St)for(var j of St(Y))se.call(Y,j)&&ie(u,j,Y[j]);return u},Tt=(u,Y)=>Fn(u,Rn(Y));var ue=u=>typeof u=="symbol"?u:u+"",ce=(u,Y)=>{var j={};for(var H in u)oe.call(u,H)&&Y.indexOf(H)<0&&(j[H]=u[H]);if(u!=null&&St)for(var H of St(u))Y.indexOf(H)<0&&se.call(u,H)&&(j[H]=u[H]);return j};function Y(t=""){const e=document.createElement("textarea");e.readOnly=!0,e.style.position="absolute",e.style.left="-9999px",e.value=t,document.body.appendChild(e),e.select(),e.setSelectionRange(0,e.value.length);const r=document.execCommand("Copy");return document.body.removeChild(e),r}const j=Object.prototype.toString;function H(t,e){return j.call(t)===`[object ${e}]`}function vt(t){return typeof t!="undefined"}function ut(t){return!vt(t)}function ht(t){return t!==null&&typeof t=="object"}function Mt(t){return H(t,"Object")}const ae=t=>Mt(t)&&Object.keys(t).length===0,fe=t=>!!(ct(t)||t==="");function le(t){return Ot(t)||jt(t)?t.length===0:t instanceof Map||t instanceof Set?t.size===0:ht(t)?Object.keys(t).length===0:!1}function he(t){return H(t,"Date")}function Dt(t){return t===null}function de(t){return ut(t)&&Dt(t)}function ct(t){return ut(t)||Dt(t)}function me(t){return H(t,"Number")}function ge(t){return H(t,"Promise")&&bt(t.then)&&bt(t.catch)}function jt(t){return H(t,"String")}function bt(t){return typeof t=="function"}function $e(t){return H(t,"Boolean")}function pe(t){return H(t,"RegExp")}function Ot(t){return t&&Array.isArray(t)}function Ft(t){return typeof window!="undefined"&&H(t,"Window")}function we(t){return ht(t)&&!!t.tagName}function Rt(t){return H(t,"Map")}function Lt(t){return H(t,"Set")}const Ut=typeof window=="undefined",Bt=!Ut;function ye(t){return/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/.test(t)}function Se(t){return typeof t=="number"?Number.isInteger(t)&&!Number.isNaN(t)&&Number.isFinite(t):typeof t=="string"?/^-?[1-9]\d*$|^0$/.test(t):!1}function ve(t){return typeof t=="number"?!Number.isNaN(t)&&Number.isFinite(t):typeof t=="string"?/^-?[1-9]\d*(\.\d+)?$|^0(\.\d+)?$|^-?0\.\d+$/.test(t):!1}const Nt={cloneMap(t,e,r){const n=e(new Map);for(const[i,s]of t)n.set(i,r(s));return n},cloneSet(t,e,r){const n=e(new Set);for(const i of t)n.add(r(i));return n},cloneArray(t,e,r){const n=e(new Array(t.length));return t.forEach((i,s)=>{n[s]=r(i)}),n},cloneObject(t,e,r){const n=e(Object.create(Object.getPrototypeOf(t)));for(const i of Reflect.ownKeys(t)){const s=Object.getOwnPropertyDescriptor(t,i);"value"in s&&(s.value=r(s.value)),Object.defineProperty(n,i,s)}return n},cloneOther(t,e){return e(t)}};function Wt(t,e){if(ut(t))return t;const r=K(K({},Nt),e),n=new Map,i=(o,a)=>(n.set(o,a),a),s=o=>{var a;return o&&typeof o=="object"?(a=n.get(o))!=null?a:c(o,r):o},c=(o,a)=>{const S=(Mt(o)?a.cloneObject:Ot(o)?a.cloneArray:Rt(o)?a.cloneMap:Lt(o)?a.cloneSet:a.cloneOther)(o,i.bind(null,o),s);return S?(n.set(o,S),S):c(o,Nt)};return c(t,r)}const Me=Wt;function dt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}var De={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function At(t,e){function r(i,s,c){if(typeof document!="undefined"){c=dt({},e,c),typeof c.expires=="number"&&(c.expires=new Date(Date.now()+c.expires*864e5)),c.expires&&(c.expires=c.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var a in c)c[a]&&(o+="; "+a,c[a]!==!0&&(o+="="+c[a].split(";")[0]));return document.cookie=i+"="+t.write(s,i)+o}}function n(i){if(!(typeof document=="undefined"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],c={},o=0;o<s.length;o++){var a=s[o].split("="),f=a.slice(1).join("=");try{var S=decodeURIComponent(a[0]);if(c[S]=t.read(f,S),i===S)break}catch(y){}}return i?c[i]:c}}return Object.create({set:r,get:n,remove:function(i,s){r(i,"",dt({},s,{expires:-1}))},withAttributes:function(i){return At(this.converter,dt({},this.attributes,i))},withConverter:function(i){return At(dt({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var kt=At(De,{path:"/"});function be(t,e,r={expires:30}){kt.set(t,e,r)}function Oe(t){return kt.get(t)}function Ne(t){kt.remove(t)}function qt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mt={exports:{}},Ae=mt.exports,Vt;function ke(){return Vt||(Vt=1,(function(t,e){(function(r,n){t.exports=n()})(Ae,(function(){var r=1e3,n=6e4,i=36e5,s="millisecond",c="second",o="minute",a="hour",f="day",S="week",y="month",E="quarter",C="year",U="date",A="Invalid Date",T=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,F=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,rt={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(g){var d=["th","st","nd","rd"],l=g%100;return"["+g+(d[(l-20)%10]||d[l]||d[0])+"]"}},B=function(g,d,l){var $=String(g);return!$||$.length>=d?g:""+Array(d+1-$.length).join(l)+g},z={s:B,z:function(g){var d=-g.utcOffset(),l=Math.abs(d),$=Math.floor(l/60),h=l%60;return(d<=0?"+":"-")+B($,2,"0")+":"+B(h,2,"0")},m:function g(d,l){if(d.date()<l.date())return-g(l,d);var $=12*(l.year()-d.year())+(l.month()-d.month()),h=d.clone().add($,y),v=l-h<0,M=d.clone().add($+(v?-1:1),y);return+(-($+(l-h)/(v?h-M:M-h))||0)},a:function(g){return g<0?Math.ceil(g)||0:Math.floor(g)},p:function(g){return{M:y,y:C,w:S,d:f,D:U,h:a,m:o,s:c,ms:s,Q:E}[g]||String(g||"").toLowerCase().replace(/s$/,"")},u:function(g){return g===void 0}},X="en",b={};b[X]=rt;var p="$isDayjsObject",m=function(g){return g instanceof I||!(!g||!g[p])},N=function g(d,l,$){var h;if(!d)return X;if(typeof d=="string"){var v=d.toLowerCase();b[v]&&(h=v),l&&(b[v]=l,h=v);var M=d.split("-");if(!h&&M.length>1)return g(M[0])}else{var k=d.name;b[k]=d,h=k}return!$&&h&&(X=h),h||!$&&X},D=function(g,d){if(m(g))return g.clone();var l=typeof d=="object"?d:{};return l.date=g,l.args=arguments,new I(l)},w=z;w.l=N,w.i=m,w.w=function(g,d){return D(g,{locale:d.$L,utc:d.$u,x:d.$x,$offset:d.$offset})};var I=(function(){function g(l){this.$L=N(l.locale,null,!0),this.parse(l),this.$x=this.$x||l.x||{},this[p]=!0}var d=g.prototype;return d.parse=function(l){this.$d=(function($){var h=$.date,v=$.utc;if(h===null)return new Date(NaN);if(w.u(h))return new Date;if(h instanceof Date)return new Date(h);if(typeof h=="string"&&!/Z$/i.test(h)){var M=h.match(T);if(M){var k=M[2]-1||0,P=(M[7]||"0").substring(0,3);return v?new Date(Date.UTC(M[1],k,M[3]||1,M[4]||0,M[5]||0,M[6]||0,P)):new Date(M[1],k,M[3]||1,M[4]||0,M[5]||0,M[6]||0,P)}}return new Date(h)})(l),this.init()},d.init=function(){var l=this.$d;this.$y=l.getFullYear(),this.$M=l.getMonth(),this.$D=l.getDate(),this.$W=l.getDay(),this.$H=l.getHours(),this.$m=l.getMinutes(),this.$s=l.getSeconds(),this.$ms=l.getMilliseconds()},d.$utils=function(){return w},d.isValid=function(){return this.$d.toString()!==A},d.isSame=function(l,$){var h=D(l);return this.startOf($)<=h&&h<=this.endOf($)},d.isAfter=function(l,$){return D(l)<this.startOf($)},d.isBefore=function(l,$){return this.endOf($)<D(l)},d.$g=function(l,$,h){return w.u(l)?this[$]:this.set(h,l)},d.unix=function(){return Math.floor(this.valueOf()/1e3)},d.valueOf=function(){return this.$d.getTime()},d.startOf=function(l,$){var h=this,v=!!w.u($)||$,M=w.p(l),k=function(ot,W){var G=w.w(h.$u?Date.UTC(h.$y,W,ot):new Date(h.$y,W,ot),h);return v?G:G.endOf(f)},P=function(ot,W){return w.w(h.toDate()[ot].apply(h.toDate("s"),(v?[0,0,0,0]:[23,59,59,999]).slice(W)),h)},_=this.$W,L=this.$M,q=this.$D,st="set"+(this.$u?"UTC":"");switch(M){case C:return v?k(1,0):k(31,11);case y:return v?k(1,L):k(0,L+1);case S:var it=this.$locale().weekStart||0,ft=(_<it?_+7:_)-it;return k(v?q-ft:q+(6-ft),L);case f:case U:return P(st+"Hours",0);case a:return P(st+"Minutes",1);case o:return P(st+"Seconds",2);case c:return P(st+"Milliseconds",3);default:return this.clone()}},d.endOf=function(l){return this.startOf(l,!1)},d.$set=function(l,$){var h,v=w.p(l),M="set"+(this.$u?"UTC":""),k=(h={},h[f]=M+"Date",h[U]=M+"Date",h[y]=M+"Month",h[C]=M+"FullYear",h[a]=M+"Hours",h[o]=M+"Minutes",h[c]=M+"Seconds",h[s]=M+"Milliseconds",h)[v],P=v===f?this.$D+($-this.$W):$;if(v===y||v===C){var _=this.clone().set(U,1);_.$d[k](P),_.init(),this.$d=_.set(U,Math.min(this.$D,_.daysInMonth())).$d}else k&&this.$d[k](P);return this.init(),this},d.set=function(l,$){return this.clone().$set(l,$)},d.get=function(l){return this[w.p(l)]()},d.add=function(l,$){var h,v=this;l=Number(l);var M=w.p($),k=function(L){var q=D(v);return w.w(q.date(q.date()+Math.round(L*l)),v)};if(M===y)return this.set(y,this.$M+l);if(M===C)return this.set(C,this.$y+l);if(M===f)return k(1);if(M===S)return k(7);var P=(h={},h[o]=n,h[a]=i,h[c]=r,h)[M]||1,_=this.$d.getTime()+l*P;return w.w(_,this)},d.subtract=function(l,$){return this.add(-1*l,$)},d.format=function(l){var $=this,h=this.$locale();if(!this.isValid())return h.invalidDate||A;var v=l||"YYYY-MM-DDTHH:mm:ssZ",M=w.z(this),k=this.$H,P=this.$m,_=this.$M,L=h.weekdays,q=h.months,st=h.meridiem,it=function(W,G,lt,yt){return W&&(W[G]||W($,v))||lt[G].slice(0,yt)},ft=function(W){return w.s(k%12||12,W,"0")},ot=st||function(W,G,lt){var yt=W<12?"AM":"PM";return lt?yt.toLowerCase():yt};return v.replace(F,(function(W,G){return G||(function(lt){switch(lt){case"YY":return String($.$y).slice(-2);case"YYYY":return w.s($.$y,4,"0");case"M":return _+1;case"MM":return w.s(_+1,2,"0");case"MMM":return it(h.monthsShort,_,q,3);case"MMMM":return it(q,_);case"D":return $.$D;case"DD":return w.s($.$D,2,"0");case"d":return String($.$W);case"dd":return it(h.weekdaysMin,$.$W,L,2);case"ddd":return it(h.weekdaysShort,$.$W,L,3);case"dddd":return L[$.$W];case"H":return String(k);case"HH":return w.s(k,2,"0");case"h":return ft(1);case"hh":return ft(2);case"a":return ot(k,P,!0);case"A":return ot(k,P,!1);case"m":return String(P);case"mm":return w.s(P,2,"0");case"s":return String($.$s);case"ss":return w.s($.$s,2,"0");case"SSS":return w.s($.$ms,3,"0");case"Z":return M}return null})(W)||M.replace(":","")}))},d.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},d.diff=function(l,$,h){var v,M=this,k=w.p($),P=D(l),_=(P.utcOffset()-this.utcOffset())*n,L=this-P,q=function(){return w.m(M,P)};switch(k){case C:v=q()/12;break;case y:v=q();break;case E:v=q()/3;break;case S:v=(L-_)/6048e5;break;case f:v=(L-_)/864e5;break;case a:v=L/i;break;case o:v=L/n;break;case c:v=L/r;break;default:v=L}return h?v:w.a(v)},d.daysInMonth=function(){return this.endOf(y).$D},d.$locale=function(){return b[this.$L]},d.locale=function(l,$){if(!l)return this.$L;var h=this.clone(),v=N(l,$,!0);return v&&(h.$L=v),h},d.clone=function(){return w.w(this.$d,this)},d.toDate=function(){return new Date(this.valueOf())},d.toJSON=function(){return this.isValid()?this.toISOString():null},d.toISOString=function(){return this.$d.toISOString()},d.toString=function(){return this.$d.toUTCString()},g})(),R=I.prototype;return D.prototype=R,[["$ms",s],["$s",c],["$m",o],["$H",a],["$W",f],["$M",y],["$y",C],["$D",U]].forEach((function(g){R[g[1]]=function(d){return this.$g(d,g[0],g[1])}})),D.extend=function(g,d){return g.$i||(g(d,I,D),g.$i=!0),D},D.locale=N,D.isDayjs=m,D.unix=function(g){return D(1e3*g)},D.en=b[X],D.Ls=b,D.p={},D}))})(mt)),mt.exports}var Ee=ke();const Z=qt(Ee);var gt={exports:{}},Ce=gt.exports,zt;function Ye(){return zt||(zt=1,(function(t,e){(function(r,n){t.exports=n()})(Ce,(function(){var r,n,i=1e3,s=6e4,c=36e5,o=864e5,a=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,f=31536e6,S=2628e6,y=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,E={years:f,months:S,days:o,hours:c,minutes:s,seconds:i,milliseconds:1,weeks:6048e5},C=function(b){return b instanceof z},U=function(b,p,m){return new z(b,m,p.$l)},A=function(b){return n.p(b)+"s"},T=function(b){return b<0},F=function(b){return T(b)?Math.ceil(b):Math.floor(b)},rt=function(b){return Math.abs(b)},B=function(b,p){return b?T(b)?{negative:!0,format:""+rt(b)+p}:{negative:!1,format:""+b+p}:{negative:!1,format:""}},z=(function(){function b(m,N,D){var w=this;if(this.$d={},this.$l=D,m===void 0&&(this.$ms=0,this.parseFromMilliseconds()),N)return U(m*E[A(N)],this);if(typeof m=="number")return this.$ms=m,this.parseFromMilliseconds(),this;if(typeof m=="object")return Object.keys(m).forEach((function(g){w.$d[A(g)]=m[g]})),this.calMilliseconds(),this;if(typeof m=="string"){var I=m.match(y);if(I){var R=I.slice(2).map((function(g){return g!=null?Number(g):0}));return this.$d.years=R[0],this.$d.months=R[1],this.$d.weeks=R[2],this.$d.days=R[3],this.$d.hours=R[4],this.$d.minutes=R[5],this.$d.seconds=R[6],this.calMilliseconds(),this}}return this}var p=b.prototype;return p.calMilliseconds=function(){var m=this;this.$ms=Object.keys(this.$d).reduce((function(N,D){return N+(m.$d[D]||0)*E[D]}),0)},p.parseFromMilliseconds=function(){var m=this.$ms;this.$d.years=F(m/f),m%=f,this.$d.months=F(m/S),m%=S,this.$d.days=F(m/o),m%=o,this.$d.hours=F(m/c),m%=c,this.$d.minutes=F(m/s),m%=s,this.$d.seconds=F(m/i),m%=i,this.$d.milliseconds=m},p.toISOString=function(){var m=B(this.$d.years,"Y"),N=B(this.$d.months,"M"),D=+this.$d.days||0;this.$d.weeks&&(D+=7*this.$d.weeks);var w=B(D,"D"),I=B(this.$d.hours,"H"),R=B(this.$d.minutes,"M"),g=this.$d.seconds||0;this.$d.milliseconds&&(g+=this.$d.milliseconds/1e3,g=Math.round(1e3*g)/1e3);var d=B(g,"S"),l=m.negative||N.negative||w.negative||I.negative||R.negative||d.negative,$=I.format||R.format||d.format?"T":"",h=(l?"-":"")+"P"+m.format+N.format+w.format+$+I.format+R.format+d.format;return h==="P"||h==="-P"?"P0D":h},p.toJSON=function(){return this.toISOString()},p.format=function(m){var N=m||"YYYY-MM-DDTHH:mm:ss",D={Y:this.$d.years,YY:n.s(this.$d.years,2,"0"),YYYY:n.s(this.$d.years,4,"0"),M:this.$d.months,MM:n.s(this.$d.months,2,"0"),D:this.$d.days,DD:n.s(this.$d.days,2,"0"),H:this.$d.hours,HH:n.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:n.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:n.s(this.$d.seconds,2,"0"),SSS:n.s(this.$d.milliseconds,3,"0")};return N.replace(a,(function(w,I){return I||String(D[w])}))},p.as=function(m){return this.$ms/E[A(m)]},p.get=function(m){var N=this.$ms,D=A(m);return D==="milliseconds"?N%=1e3:N=D==="weeks"?F(N/E[D]):this.$d[D],N||0},p.add=function(m,N,D){var w;return w=N?m*E[A(N)]:C(m)?m.$ms:U(m,this).$ms,U(this.$ms+w*(D?-1:1),this)},p.subtract=function(m,N){return this.add(m,N,!0)},p.locale=function(m){var N=this.clone();return N.$l=m,N},p.clone=function(){return U(this.$ms,this)},p.humanize=function(m){return r().add(this.$ms,"ms").locale(this.$l).fromNow(!m)},p.valueOf=function(){return this.asMilliseconds()},p.milliseconds=function(){return this.get("milliseconds")},p.asMilliseconds=function(){return this.as("milliseconds")},p.seconds=function(){return this.get("seconds")},p.asSeconds=function(){return this.as("seconds")},p.minutes=function(){return this.get("minutes")},p.asMinutes=function(){return this.as("minutes")},p.hours=function(){return this.get("hours")},p.asHours=function(){return this.as("hours")},p.days=function(){return this.get("days")},p.asDays=function(){return this.as("days")},p.weeks=function(){return this.get("weeks")},p.asWeeks=function(){return this.as("weeks")},p.months=function(){return this.get("months")},p.asMonths=function(){return this.as("months")},p.years=function(){return this.get("years")},p.asYears=function(){return this.as("years")},b})(),X=function(b,p,m){return b.add(p.years()*m,"y").add(p.months()*m,"M").add(p.days()*m,"d").add(p.hours()*m,"h").add(p.minutes()*m,"m").add(p.seconds()*m,"s").add(p.milliseconds()*m,"ms")};return function(b,p,m){r=m,n=m().$utils(),m.duration=function(w,I){var R=m.locale();return U(w,{$l:R},I)},m.isDuration=C;var N=p.prototype.add,D=p.prototype.subtract;p.prototype.add=function(w,I){return C(w)?X(this,w,1):N.bind(this)(w,I)},p.prototype.subtract=function(w,I){return C(w)?X(this,w,-1):D.bind(this)(w,I)}}}))})(gt)),gt.exports}var He=Ye();const Pe=qt(He);Z.extend(Pe);const Q=(t,e,r)=>{const n=Number(t),i=isNaN(n)?t:n;return Z(i,e,r)},Zt=(t,e="YYYY-MM-DD HH:mm:ss")=>t===null||t===""?"":Q(t).format(e),Ie=(t,e="YYYY-MM-DD HH:mm")=>t===null||t===""?"":Q(t).format(e),_e=t=>Z(t).daysInMonth();function Te(t=0,e="YYYY-MM-DD"){return Zt(Z().add(t,"day"),e)}function je(t,e,r){if(!t)return 0;e||(e=void 0);const n=Q(t),i=Q(e);return Q(n).diff(i,r)}function Fe(t,e){const r=K({zero:"刚刚",minuteAgo:"${m}分钟前",today:"今天 ${HH:mm}",yesterday:"昨天 ${HH:mm}",other:"${YYYY/MM/DD}",future:"${YYYY/MM/DD}"},e),n=Z(),i=Q(t),s=n.diff(i,"minute"),c=o=>o===r.zero?o:o.replace(/\${(.*?)}/g,(a,f)=>i.format(f));return s<0?c(r.future):s<60?r.minuteAgo.replace("${m}",`${Math.abs(s)}`):i.isSame(n,"day")?c(r.today):i.isSame(n.subtract(1,"day"),"day")?c(r.yesterday):c(r.other)}function Re(t,e,r="YY年MM个月DD天"){const n=Z(t),i=Z(e),s={YY:"year",MM:"month",DD:"day",HH:"hour",mm:"minute",ss:"second"};let c=r,o=n;for(const[a,f]of Object.entries(s))if(c.includes(a)){const S=i.diff(o,f);c=c.replace(a,S>0?""+S:"0"),o=o.add(S,f)}return c.trim().replace(/\s+/g," ")}function Le(t,e){if(!t)return"";const{format:r="HH小时mm分钟",unit:n="ms"}=e||{},i=Z.duration(Number(t),n);return Array.isArray(r)?r.map(s=>i.format(s)):Jt(r,t,n)}function Ue(t,e){if(!t)return"";const{format:r="D天H小时m分钟",unit:n="ms"}=e||{};return Jt(r,t,n).replace(new RegExp("(?<![1-9]\\d*)0+([^\\d]+)","g"),"").trim()}function Jt(t="HH小时mm分钟",e,r){const n=Z.duration(Number(e),r);if(t.includes("D")&&t.includes("H")){const o=Math.floor(n.asHours()%24)+"";t=t.includes("HH")?t.replace("HH",o.padStart(2,"0")):t.replace("H",o)}const i=t.match(/[YMDHms]/g)||[];let s=n.format(t);const c=(o,a)=>o.replace(/\d+/,`${Math.floor(+a)}`);switch(i[0]){case"Y":break;case"M":n.asMonths()>=12&&(s=c(s,`${n.asMonths()}`));break;case"D":n.asDays()>=30&&(s=c(s,`${n.asDays()}`));break;case"H":n.asHours()>=24&&(s=c(s,`${n.asHours()}`));break;case"m":n.asMinutes()>=60&&(s=c(s,`${n.asMinutes()}`));break;case"s":n.asSeconds()>=60&&(s=c(s,`${n.asSeconds()}`));break}return s}function Be(){return navigator.userAgent.indexOf("Android")>-1}function We(){return/(iPhone|iPad|iPod)/i.test(navigator.userAgent)}function qe(){return window.navigator.userAgent.includes("OpenHarmony")}function Kt(){return navigator.userAgent.toLowerCase().indexOf("micromessenger")!==-1}function Ve(){return Kt()&&window.navigator.userAgent.includes("miniProgram")}var Xt=(t=>(t.XIAOMI="xiaomi",t.OPPO="oppo",t.VIVO="vivo",t.HUAWEI="huawei",t.HONOR="honor",t.ONE_PLUS="oneplus",t.SAMSUNG="samsung",t.IPHONE="iphone",t.MEIZU="meizu",t.LENOVO="lenovo",t))(Xt||{});function ze(){const t=navigator.userAgent.toLowerCase();if(t.includes("iphone")||t.includes("ipad")||t.includes("ipod"))return"iphone";if(t.includes("xiaomi")||t.includes("miui")||t.includes("redmi")||t.includes("mix"))return"xiaomi";if(t.includes("oppo")||t.includes("realme")||t.includes("heytap"))return"oppo";if(t.includes("vivo"))return"vivo";if(t.includes("huawei"))return"huawei";if(t.includes("oneplus"))return"oneplus";if(t.includes("honor"))return"honor";if(t.includes("samsung"))return"samsung";if(t.includes("meizu"))return"meizu";if(t.includes("lenovo"))return"lenovo"}const Et=()=>typeof globalThis!="undefined"?globalThis:Bt?window:typeof global!="undefined"?global:self,$t=t=>{const e=Et();return e.requestAnimationFrame?e.requestAnimationFrame(t):e.setTimeout(t)},Ze=t=>{const e=Et();e.cancelAnimationFrame?e.cancelAnimationFrame(t):e.clearTimeout(t)},Je=()=>new Promise(t=>{$t(t)}),Ke=()=>new Promise(t=>{$t(()=>{$t(t)})}),Xe=t=>window.getComputedStyle(t),Ct=t=>{if(Ft(t)){const e=t.innerWidth,r=t.innerHeight,n={x:0,y:0,top:0,left:0,right:e,bottom:r,width:e,height:r};return Tt(K({},n),{toJSON:()=>n})}return t.getBoundingClientRect()},Ge=t=>{const{top:e,bottom:r,left:n,right:i}=Ct(t),{width:s,height:c}=Ct(window),o=n<=s&&i>=0,a=e<=c&&r>=0;return o&&a},Qe=t=>{t.cancelable!==!1&&t.preventDefault()},xe=t=>{const e="scrollTop"in t?t.scrollTop:t.scrollY;return Math.max(e,0)},tn=t=>{const e="scrollLeft"in t?t.scrollLeft:t.scrollX;return Math.max(e,0)};function en(t,e,r=!0){if(!t)return{};if(!r)return e.reduce((i,s)=>{const a=i,{[s]:c}=a;return ce(a,[ue(s)])},t);const n={};for(const i in t)!e.includes(i)&&!ct(t[i])&&(n[i]=t[i]);return n}function nn(t,e,r=!0){return t?e.reduce((n,i)=>{const s=t[i];return(!r||vt(s))&&(n[i]=s),n},{}):{}}function rn(t,e){if(!t)return{};const r={};for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=n,s=t[i];e(s,i)&&(r[i]=s)}return r}function on(t,e){const r=K({},t);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=n,s=t[i];e(s,i)&&delete r[n]}return r}const sn=(t,e=0)=>{let r;return function(...n){r&&window.clearTimeout(r),r=window.setTimeout(()=>{t.apply(this,n)},e)}},un=(t,e=200,r=!0)=>{let n,i=0;return function(...c){const o=Date.now(),a=o-i;a>=e?(t.apply(this,c),i=o):r&&(window.clearTimeout(n),n=window.setTimeout(()=>{t.apply(this,c),i=Date.now()},e-a))}};let Yt=0;function cn(t=16){const e=new Date().getTime().toString(),r=Math.random().toString().replace(".","").slice(1,10),n=t-e.length-Yt.toString().length-r.length,i="0".repeat(n>0?n:0),s=""+`${Yt}${e}${i}${r}`.slice(0,t);return Yt++,s}function an(t,e=!0){return new Promise((r,n)=>{const i=new FileReader;i.onloadend=()=>{if(typeof i.result=="string"){if(e)return r(i.result&&i.result.split(",")[1]);r(i.result)}else n(new Error("Failed to convert Blob to base64"))},i.onerror=n,i.readAsDataURL(t)})}function fn(t,e){const r=e.split(".");let n=t;return r.forEach(i=>{var s;n=ht(n)&&(s=n[i])!=null?s:""}),n}function ln(t){return!t||typeof t!="object"?"":Object.entries(t).map(([e,r])=>{if(r==null)return"";const n=typeof r=="object"?JSON.stringify(r):String(r);return`${e}=${encodeURIComponent(n)}`}).filter(Boolean).join("&")}function hn(t){if(!t||typeof t!="string")return{};if(!t.trim())return{};if(/^https?:\/\/[^?]+$/.test(t))return{};const e=t.includes("?")?t.split("?")[1]:t;if(!e)return{};const r={},n=e.split("&");for(const i of n){const[s,c]=i.split("=");if(!s)continue;const o=decodeURIComponent(s),a=c?decodeURIComponent(c):"";let f=a;try{f=JSON.parse(a)}catch(S){}if(typeof f!="object"||f===null){const S=Number(f);isNaN(S)||(f=S)}r[o]=f}return r}var dn=20,mn=1,x=1e6,Gt=1e6,gn=-7,$n=21,pn=!1,at="[big.js] ",tt=at+"Invalid ",pt=tt+"decimal places",wn=tt+"rounding mode",Qt=at+"Division by zero",O={},V=void 0,yn=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function xt(){function t(e){var r=this;if(!(r instanceof t))return e===V?xt():new t(e);if(e instanceof t)r.s=e.s,r.e=e.e,r.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(tt+"value");e=e===0&&1/e<0?"-0":String(e)}Sn(r,e)}r.constructor=t}return t.prototype=O,t.DP=dn,t.RM=mn,t.NE=gn,t.PE=$n,t.strict=pn,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function Sn(t,e){var r,n,i;if(!yn.test(e))throw Error(tt+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&e.charAt(n)=="0";)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&e.charAt(--i)=="0";);for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}return t}function et(t,e,r,n){var i=t.c;if(r===V&&(r=t.constructor.RM),r!==0&&r!==1&&r!==2&&r!==3)throw Error(wn);if(e<1)n=r===3&&(n||!!i[0])||e===0&&(r===1&&i[0]>=5||r===2&&(i[0]>5||i[0]===5&&(n||i[1]!==V))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=r===1&&i[e]>=5||r===2&&(i[e]>5||i[e]===5&&(n||i[e+1]!==V||i[e-1]&1))||r===3&&(n||!!i[0]),i.length=e,n){for(;++i[--e]>9;)if(i[e]=0,e===0){++t.e,i.unshift(1);break}}for(e=i.length;!i[--e];)i.pop()}return t}function nt(t,e,r){var n=t.e,i=t.c.join(""),s=i.length;if(e)i=i.charAt(0)+(s>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>s)for(n-=s;n--;)i+="0";else n<s&&(i=i.slice(0,n)+"."+i.slice(n));else s>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}O.abs=function(){var t=new this.constructor(this);return t.s=1,t},O.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,s=r.s,c=t.s,o=r.e,a=t.e;if(!n[0]||!i[0])return n[0]?s:i[0]?-c:0;if(s!=c)return s;if(e=s<0,o!=a)return o>a^e?1:-1;for(c=(o=n.length)<(a=i.length)?o:a,s=-1;++s<c;)if(n[s]!=i[s])return n[s]>i[s]^e?1:-1;return o==a?0:o>a^e?1:-1},O.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,s=e.s==t.s?1:-1,c=r.DP;if(c!==~~c||c<0||c>x)throw Error(pt);if(!i[0])throw Error(Qt);if(!n[0])return t.s=s,t.c=[t.e=0],t;var o,a,f,S,y,E=i.slice(),C=o=i.length,U=n.length,A=n.slice(0,o),T=A.length,F=t,rt=F.c=[],B=0,z=c+(F.e=e.e-t.e)+1;for(F.s=s,s=z<0?0:z,E.unshift(0);T++<o;)A.push(0);do{for(f=0;f<10;f++){if(o!=(T=A.length))S=o>T?1:-1;else for(y=-1,S=0;++y<o;)if(i[y]!=A[y]){S=i[y]>A[y]?1:-1;break}if(S<0){for(a=T==o?i:E;T;){if(A[--T]<a[T]){for(y=T;y&&!A[--y];)A[y]=9;--A[y],A[T]+=10}A[T]-=a[T]}for(;!A[0];)A.shift()}else break}rt[B++]=S?f:++f,A[0]&&S?A[T]=n[C]||0:A=[n[C]]}while((C++<U||A[0]!==V)&&s--);return!rt[0]&&B!=1&&(rt.shift(),F.e--,z--),B>z&&et(F,z,r.RM,A[0]!==V),F},O.eq=function(t){return this.cmp(t)===0},O.gt=function(t){return this.cmp(t)>0},O.gte=function(t){return this.cmp(t)>-1},O.lt=function(t){return this.cmp(t)<0},O.lte=function(t){return this.cmp(t)<1},O.minus=O.sub=function(t){var e,r,n,i,s=this,c=s.constructor,o=s.s,a=(t=new c(t)).s;if(o!=a)return t.s=-a,s.plus(t);var f=s.c.slice(),S=s.e,y=t.c,E=t.e;if(!f[0]||!y[0])return y[0]?t.s=-a:f[0]?t=new c(s):t.s=1,t;if(o=S-E){for((i=o<0)?(o=-o,n=f):(E=S,n=y),n.reverse(),a=o;a--;)n.push(0);n.reverse()}else for(r=((i=f.length<y.length)?f:y).length,o=a=0;a<r;a++)if(f[a]!=y[a]){i=f[a]<y[a];break}if(i&&(n=f,f=y,y=n,t.s=-t.s),(a=(r=y.length)-(e=f.length))>0)for(;a--;)f[e++]=0;for(a=e;r>o;){if(f[--r]<y[r]){for(e=r;e&&!f[--e];)f[e]=9;--f[e],f[r]+=10}f[r]-=y[r]}for(;f[--a]===0;)f.pop();for(;f[0]===0;)f.shift(),--E;return f[0]||(t.s=1,f=[E=0]),t.c=f,t.e=E,t},O.mod=function(t){var e,r=this,n=r.constructor,i=r.s,s=(t=new n(t)).s;if(!t.c[0])throw Error(Qt);return r.s=t.s=1,e=t.cmp(r)==1,r.s=i,t.s=s,e?new n(r):(i=n.DP,s=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=s,this.minus(r.times(t)))},O.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},O.plus=O.add=function(t){var e,r,n,i=this,s=i.constructor;if(t=new s(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var c=i.e,o=i.c,a=t.e,f=t.c;if(!o[0]||!f[0])return f[0]||(o[0]?t=new s(i):t.s=i.s),t;if(o=o.slice(),e=c-a){for(e>0?(a=c,n=f):(e=-e,n=o),n.reverse();e--;)n.push(0);n.reverse()}for(o.length-f.length<0&&(n=f,f=o,o=n),e=f.length,r=0;e;o[e]%=10)r=(o[--e]=o[e]+f[e]+r)/10|0;for(r&&(o.unshift(r),++a),e=o.length;o[--e]===0;)o.pop();return t.c=o,t.e=a,t},O.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-Gt||t>Gt)throw Error(tt+"exponent");for(i&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return i?r.div(n):n},O.prec=function(t,e){if(t!==~~t||t<1||t>x)throw Error(tt+"precision");return et(new this.constructor(this),t,e)},O.round=function(t,e){if(t===V)t=0;else if(t!==~~t||t<-x||t>x)throw Error(pt);return et(new this.constructor(this),t+this.e+1,e)},O.sqrt=function(){var t,e,r,n=this,i=n.constructor,s=n.s,c=n.e,o=new i("0.5");if(!n.c[0])return new i(n);if(s<0)throw Error(at+"No square root");s=Math.sqrt(+nt(n,!0,!0)),s===0||s===1/0?(e=n.c.join(""),e.length+c&1||(e+="0"),s=Math.sqrt(e),c=((c+1)/2|0)-(c<0||c&1),t=new i((s==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+c)):t=new i(s+""),c=t.e+(i.DP+=4);do r=t,t=o.times(r.plus(n.div(r)));while(r.c.slice(0,c).join("")!==t.c.slice(0,c).join(""));return et(t,(i.DP-=4)+t.e+1,i.RM)},O.times=O.mul=function(t){var e,r=this,n=r.constructor,i=r.c,s=(t=new n(t)).c,c=i.length,o=s.length,a=r.e,f=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!s[0])return t.c=[t.e=0],t;for(t.e=a+f,c<o&&(e=i,i=s,s=e,f=c,c=o,o=f),e=new Array(f=c+o);f--;)e[f]=0;for(a=o;a--;){for(o=0,f=c+a;f>a;)o=e[f]+s[a]*i[f-a-1]+o,e[f--]=o%10,o=o/10|0;e[f]=o}for(o?++t.e:e.shift(),a=e.length;!e[--a];)e.pop();return t.c=e,t},O.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==V){if(t!==~~t||t<0||t>x)throw Error(pt);for(r=et(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return nt(r,!0,!!n)},O.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==V){if(t!==~~t||t<0||t>x)throw Error(pt);for(r=et(new r.constructor(r),t+r.e+1,e),t=t+r.e+1;r.c.length<t;)r.c.push(0)}return nt(r,!1,!!n)},O[Symbol.for("nodejs.util.inspect.custom")]=O.toJSON=O.toString=function(){var t=this,e=t.constructor;return nt(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},O.toNumber=function(){var t=+nt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(at+"Imprecise conversion");return t},O.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==V){if(t!==~~t||t<1||t>x)throw Error(tt+"precision");for(r=et(new n(r),t,e);r.c.length<t;)r.c.push(0)}return nt(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)},O.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(at+"valueOf disallowed");return nt(t,t.e<=e.NE||t.e>=e.PE,!0)};var te=xt();function ee(t){return new te(t)}function vn(t,e,r=1){return new te(t).round(e,r).toNumber()}function Mn(t,e={}){const{bit:r=3,precision:n=0,thousandSeparator:i=",",roundMode:s=1}=e;if(ct(t))return"";if(isNaN(+t))return t+"";let c=ee(t).toFixed(n,s);const o=c.split(".");c=o[0];const a=new RegExp(`(\\d)(?=(\\d{${r}})+$)`,"g");c=c.replace(a,`$1${i}`);const f=o.length>1?`.${o==null?void 0:o[1]}`:"";return c+f}const Dn={yi:"亿",wan:"万",thousandSeparator:","};function wt(t,e={}){if(ct(t)||isNaN(t))return"";if(t<0)return"-"+wt(-t,e);const{yi:r,wan:n,thousandSeparator:i}=K(K({},Dn),e),s=String(t).length,c=!!i,o=S=>c?S.replace(/\B(?=(\d{3})+(?!\d))/g,i):S;if(s<=4)return o(String(t));if(s<=8){const S=Math.floor(t/1e4),y=t%1e4;return y===0?o(String(S))+n:o(String(S))+n+o(y.toString().padStart(4,"0"))}if(s<=12){const S=Math.floor(t/1e8),y=Math.floor(t%1e8/1e4),E=t%1e4;if(S===0)return wt(t%1e8,e);const C=o(String(S))+r;return y===0&&E===0?C:y===0?C+o(E.toString()):E===0?C+o(String(y))+n:C+o(String(y))+n+o(E.toString())}const a=Math.floor(t/1e8),f=t%1e8;return o(String(a))+r+wt(f,Tt(K({},e),{thousandSeparator:""}))}const J={LOCAl:"localStorage",SESSION:"sessionStorage"};function Ht(t,e,r=J.LOCAl){if(ut(e))return;const n=JSON.stringify({_value_:e});window[r].setItem(t,n)}function Pt(t,e=J.LOCAl){const r=window[e].getItem(t);if(!r)return null;try{const n=JSON.parse(r);return Object.hasOwnProperty.call(n,"_value_")?n._value_:n}catch(n){return r}}function It(t,e=J.LOCAl){window[e].removeItem(t)}function _t(t=J.LOCAl){window[t].clear()}const bn=(t,e)=>Ht(t,e),On=t=>Pt(t),Nn=t=>It(t),An=()=>_t(),kn=(t,e)=>Ht(t,e,J.SESSION),En=t=>Pt(t,J.SESSION),Cn=t=>It(t,J.SESSION),Yn=()=>_t(J.SESSION),Hn=t=>t.replace(/-(\w)/g,(e,r)=>r.toUpperCase()),Pn=t=>t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),In=t=>t.replace(/([A-Z])/g,"_$1").toLowerCase(),_n=t=>t.charAt(0).toLowerCase()+t.slice(1);function Tn(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}var ne=(t=>(t[t.YES=1]="YES",t[t.NO=0]="NO",t))(ne||{}),re=(t=>(t.YES="10",t.NO="20",t))(re||{});u.DefaultCloningStrategy=Nt,u.EnumDeviceBrand=Xt,u.EnumStoreType=J,u.EnumYesNo=ne,u.EnumYesNoPlus=re,u.blobToBase64=an,u.camelize=Hn,u.cancelAnimationFrame=Ze,u.clearLocal=An,u.clearSession=Yn,u.clearStore=_t,u.cloneDeep=Wt,u.copyTextToClipboard=Y,u.dateDiff=je,u.dateDiffFormat=Re,u.dateFormat=Zt,u.dateFromNow=Fe,u.dateMonthDays=_e,u.debounce=sn,u.deepClone=Me,u.doubleRaf=Ke,u.durationFormat=Le,u.durationFormatNoZero=Ue,u.formatMoney=wt,u.formatNumber=Mn,u.get=fn,u.getCookie=Oe,u.getCurrDate=Te,u.getDeviceBrand=ze,u.getGlobalThis=Et,u.getLocal=On,u.getRect=Ct,u.getScrollLeft=tn,u.getScrollTop=xe,u.getSession=En,u.getStore=Pt,u.getStyle=Xe,u.inViewport=Ge,u.is=H,u.isAndroid=Be,u.isArray=Ot,u.isBoolean=$e,u.isClient=Bt,u.isDate=he,u.isDef=vt,u.isElement=we,u.isEmpty=le,u.isEmptyObject=ae,u.isEmptyValue=fe,u.isFunction=bt,u.isHarmony=qe,u.isInteger=Se,u.isIos=We,u.isMap=Rt,u.isNull=Dt,u.isNullAndUnDef=de,u.isNullOrUnDef=ct,u.isNumber=me,u.isNumeric=ve,u.isObject=ht,u.isPlainObject=Mt,u.isPromise=ge,u.isRegExp=pe,u.isServer=Ut,u.isSet=Lt,u.isString=jt,u.isUnDef=ut,u.isUrl=ye,u.isWeChat=Kt,u.isWindow=Ft,u.isWxMiniProgram=Ve,u.kebabCase=Pn,u.lowerFirst=_n,u.minute=Ie,u.objToQString=ln,u.omit=en,u.omitBy=on,u.pick=nn,u.pickBy=rn,u.preventDefault=Qe,u.qStringToObj=hn,u.raf=Je,u.removeCookie=Ne,u.removeLocal=Nn,u.removeSession=Cn,u.removeStore=It,u.requestAnimationFrame=$t,u.round=vn,u.setCookie=be,u.setLocal=bn,u.setSession=kn,u.setStore=Ht,u.sleep=Tn,u.snakeCase=In,u.throttle=un,u.uniqueId=cn,u.useDate=Q,u.useNumber=ee,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,144 @@
1
+ interface Store {
2
+ [key: string]: any;
3
+ }
4
+ /**
5
+ * 存储类型
6
+ */
7
+ type StoreType = Store | string | number | boolean;
8
+ export declare const EnumStoreType: {
9
+ /**
10
+ * localStorage
11
+ */
12
+ readonly LOCAl: "localStorage";
13
+ /**
14
+ * sessionStorage
15
+ */
16
+ readonly SESSION: "sessionStorage";
17
+ };
18
+ export type EnumStoreType = (typeof EnumStoreType)[keyof typeof EnumStoreType];
19
+ /**
20
+ * 设置本地存储, 默认`type` 为`localStorage`
21
+ * @param key - 字符串唯一key
22
+ * @param value - 需要存储的内容
23
+ * @param type - 存储类型 {@link EnumStoreType}
24
+ * @example
25
+ * ```ts
26
+ * let value = { name: '张三', age: 18 }
27
+ * // localStorage
28
+ * setStore('userInfo', value)
29
+ * // sessionStorage
30
+ * setStore('userInfo', value, EnumStoreType.SESSION)
31
+ * ```
32
+ */
33
+ export declare function setStore(key: string, value: StoreType, type?: EnumStoreType): void;
34
+ /**
35
+ * 获取本地存储, 默认`type` 为`localStorage`
36
+ * @param key - 字符串key
37
+ * @param type - 存储类型 {@link EnumStoreType}
38
+ * @returns 获取到的内容
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * // localStorage
43
+ * const value = getStore('token')
44
+ * // sessionStorage
45
+ * const value = getStore('token', EnumStoreType.SESSION)
46
+ * ```
47
+ */
48
+ export declare function getStore<T = any>(key: string, type?: EnumStoreType): T | null;
49
+ /**
50
+ * 删除指定key的Local
51
+ * @param key - 字符串key
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * // localStorage
56
+ * const value = removeStore('token')
57
+ * // sessionStorage
58
+ * const value = removeStore('token', EnumStoreType.SESSION)
59
+ * ```
60
+ */
61
+ export declare function removeStore(key: string, type?: EnumStoreType): void;
62
+ /**
63
+ * 清空所有Local
64
+ */
65
+ export declare function clearStore(type?: EnumStoreType): void;
66
+ /**
67
+ * 设置LocalStorage
68
+ * @param key - 字符串唯一key
69
+ * @param content - 需要存储的内容
70
+ * @returns void
71
+ * @example
72
+ * ```ts
73
+ * // localStorage
74
+ * setLocal('token','123')
75
+ * ```
76
+ */
77
+ export declare const setLocal: (key: string, content: StoreType) => void;
78
+ /**
79
+ * 获取LocalStorage
80
+ * @param key - 字符串key
81
+ * @returns 获取到的内容
82
+ * @example
83
+ * ```ts
84
+ * const value = getLocal('token')
85
+ * ```
86
+ */
87
+ export declare const getLocal: <T = any>(key: string) => T | null;
88
+ /**
89
+ * 删除指定key的LocalStorage
90
+ * @param key - 字符串key
91
+ * @returns void
92
+ * @example
93
+ * ```ts
94
+ * removeLocal('token')
95
+ * ```
96
+ */
97
+ export declare const removeLocal: (key: string) => void;
98
+ /**
99
+ * 清除所有LocalStorage
100
+ * @example
101
+ * ```ts
102
+ * clearLocal()
103
+ * ```
104
+ */
105
+ export declare const clearLocal: () => void;
106
+ /**
107
+ * 设置sessionStorage
108
+ * @param key - 字符串唯一key
109
+ * @param content - 需要存储的内容
110
+ * @returns void
111
+ * @example
112
+ * ```ts
113
+ * setSession('token','123')
114
+ * ```
115
+ */
116
+ export declare const setSession: (key: string, content: StoreType) => void;
117
+ /**
118
+ * 获取sessionStorage
119
+ * @param key - 字符串key
120
+ * @returns - 获取到的内容
121
+ * @example
122
+ * ```ts
123
+ * const value = getSession('token')
124
+ * ```
125
+ */
126
+ export declare const getSession: <T = any>(key: string) => T | null;
127
+ /**
128
+ * 删除指定key的sessionStorage
129
+ * @param key - 字符串key
130
+ * @example
131
+ * ```ts
132
+ * const value = removeSession('token')
133
+ * ```
134
+ */
135
+ export declare const removeSession: (key: string) => void;
136
+ /**
137
+ * 清除所有sessionStorage
138
+ * @example
139
+ * ```ts
140
+ * const value = clearSession()
141
+ * ```
142
+ */
143
+ export declare const clearSession: () => void;
144
+ export {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 中划线转小驼峰
3
+ * @param str - 字符串
4
+ * @returns 驼峰字符串
5
+ * @example
6
+ * ```ts
7
+ * let result=camelize('user-info')
8
+ * ```
9
+ */
10
+ export declare const camelize: (str: string) => string;
11
+ /**
12
+ * 驼峰转中划线
13
+ * @param str - 字符串
14
+ * @returns 中划线字符串
15
+ * @example
16
+ * ```ts
17
+ * let result=kebabCase('userInfo')
18
+ * ```
19
+ */
20
+ export declare const kebabCase: (str: string) => string;
21
+ /**
22
+ * 驼峰转下划线
23
+ * @param str - 字符串
24
+ * @returns 下划线字符串
25
+ * @example
26
+ * ```ts
27
+ * let result=snakeCase('userInfo')
28
+ * ```
29
+ */
30
+ export declare const snakeCase: (str: string) => string;
31
+ /**
32
+ * 首字母小写
33
+ * @param str - 字符串
34
+ * @returns 首字母小写的字符串
35
+ * @example
36
+ * ```ts
37
+ * let result=lowerFirst('ABC')
38
+ * ```
39
+ */
40
+ export declare const lowerFirst: (str: string) => string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 睡眠函数
3
+ * @param timer - 睡眠时间(ms)
4
+ * @example
5
+ * ```ts
6
+ * await sleep(100)
7
+ * ```
8
+ */
9
+ export declare function sleep(timer: number): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import allkitEslintConfig from '@allkit/eslint-config';
2
+
3
+ export default [
4
+ {
5
+ ignores: ['dist/**', 'node_modules/**'],
6
+ },
7
+ ...allkitEslintConfig,
8
+ ];
9
+
10
+
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@allkit/shared",
3
+ "version": "0.0.1",
4
+ "description": "this is a shared package",
5
+ "main": "./src/index.ts",
6
+ "module": "./src/index.ts",
7
+ "type": "module",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "test": "vitest",
13
+ "coverage": "vitest run --coverage",
14
+ "build": "node ./scripts/build.mjs"
15
+ },
16
+ "dependencies": {
17
+ "@types/big.js": "^6.1.6",
18
+ "@types/js-cookie": "^3.0.3",
19
+ "big.js": "^6.2.1",
20
+ "dayjs": "^1.11.10",
21
+ "js-cookie": "^3.0.5"
22
+ },
23
+ "devDependencies": {
24
+ "jsdom": "^26.0.0"
25
+ }
26
+ }
@@ -0,0 +1,92 @@
1
+ import { createReadStream, createWriteStream } from 'fs'
2
+ import { createRequire } from 'module'
3
+ import { dirname, resolve } from 'path'
4
+ import { fileURLToPath } from 'url'
5
+ import fse from 'fs-extra'
6
+ // 引入 vite 的 build 方法,进行编译构建
7
+ import { build } from 'vite'
8
+ import { viteLibConfig } from '@allkit/vite-config'
9
+
10
+ const { outputFile } = fse
11
+
12
+ const require = createRequire(import.meta.url)
13
+
14
+ const __filename = fileURLToPath(import.meta.url)
15
+ const __dirname = dirname(__filename)
16
+
17
+ // 输出目录
18
+ const outputDir = resolve(__dirname, '../dist')
19
+
20
+ const {
21
+ version,
22
+ peerDependencies,
23
+ name,
24
+ description,
25
+ publishConfig,
26
+ dependencies,
27
+ type,
28
+ } = require('../package.json')
29
+ // 生成 package.json
30
+ const createPackageJson = () => {
31
+ const pkgName = name
32
+ const pkgUMD = './shared.umd.js'
33
+ const pkgESM = './shared.es.js'
34
+
35
+ const fileStr = `{
36
+ "name": "${pkgName}",
37
+ "version": "${version}",
38
+ "description": "${description}",
39
+ "main": "${pkgUMD}",
40
+ "module":"${pkgESM}",
41
+ "types": "index.d.ts",
42
+ "exports": {
43
+ ".": {
44
+ "import": "${pkgESM}",
45
+ "require": "${pkgUMD}"
46
+ }
47
+ },
48
+ "keywords": ["lodash", "dayjs", "big.js","${name || ''}"],
49
+ "license": "MIT",
50
+ "author": "Spig",
51
+ "publishConfig":${JSON.stringify(publishConfig)},
52
+ "dependencies":${JSON.stringify(dependencies)},
53
+ "peerDependencies": ${peerDependencies ? JSON.stringify(peerDependencies) : '{}'}
54
+ }
55
+ `
56
+ // 单个组件 or 全量
57
+ const filePath = resolve(outputDir, 'package.json')
58
+ outputFile(filePath, fileStr, 'utf-8')
59
+ }
60
+
61
+ /** 全量构建 */
62
+ const buildAll = async () => {
63
+ const config = viteLibConfig({
64
+ mode: 'production',
65
+ build: {
66
+ target: 'es2015',
67
+ lib: {
68
+ entry: './src/index.ts',
69
+ name: 'shared',
70
+ fileName: (format) => `shared.${format}.js`,
71
+ },
72
+ },
73
+ })
74
+ await build(config)
75
+
76
+ createPackageJson()
77
+ }
78
+
79
+ // copy文件
80
+ // README.md
81
+ // 样式 index.css
82
+ const copyFiles = () => {
83
+ const markdown = createReadStream(resolve(__dirname, '../README.md'))
84
+ markdown.pipe(createWriteStream(resolve(__dirname, '../dist/README.md')))
85
+ }
86
+
87
+ const buildLib = async () => {
88
+ await buildAll()
89
+ copyFiles()
90
+ }
91
+
92
+ buildLib()
package/skill/SKILL.md ADDED
@@ -0,0 +1,240 @@
1
+ ---
2
+ name: shared
3
+ description: 前端通用工具函数库,包含日期、数字、字符串、防抖节流等多种常用工具函数 / A collection of utility functions for frontend development
4
+ author: allkit
5
+ category: utilities
6
+ ---
7
+
8
+ # @allkit/shared
9
+
10
+ 前端通用工具函数库,解决常见的开发问题。Provide a collection of utility functions for frontend development.
11
+
12
+ ## Install / 安装
13
+
14
+ ```bash
15
+ pnpm add @allkit/shared
16
+ ```
17
+
18
+ ## Functions / 函数
19
+
20
+ ### 类型判断 (is)
21
+
22
+ 类型判断工具函数 / Type checking utility functions
23
+
24
+ | Function | Description | 中文说明 |
25
+ |----------|-------------|----------|
26
+ | [is](./references/is.md) | General type checking | 通用类型判断 |
27
+ | [isDef](./references/is.md#isdef) | Check if not undefined | 判断不是 undefined |
28
+ | [isUnDef](./references/is.md#isundef) | Check if undefined | 判断是 undefined |
29
+ | [isObject](./references/is.md#isobject) | Check if is Object (includes Array, Map) | 判断是 Object(含数组、Map) |
30
+ | [isPlainObject](./references/is.md#isplainobject) | Check if is plain Object | 判断是原始 Object(不含数组) |
31
+ | [isEmpty](./references/is.md#isempty) | Check if is empty | 判断是空(含空数组、空对象、空 Map) |
32
+ | [isEmptyValue](./references/is.md#isemptyvalue) | Check if is empty value | 检测是否空值 |
33
+ | [isDate](./references/is.md#isdate) | Check if is Date object | 判断是日期对象 |
34
+ | [isNullOrUnDef](./references/is.md#isnullorundef) | Check if is null or undefined | 判断是 null 或 undefined |
35
+ | [isNumber](./references/is.md#isnumber) | Check if is number | 是否是 number |
36
+ | [isInteger](./references/is.md#isinteger) | Check if is integer | 判断是否为整数 |
37
+ | [isNumeric](./references/is.md#isnumeric) | Check if is numeric | 判断是否为数值 |
38
+ | [isPromise](./references/is.md#ispromise) | Check if is Promise | 是否是 Promise |
39
+ | [isFunction](./references/is.md#isfunction) | Check if is function | 是否是函数 |
40
+ | [isArray](./references/is.md#isarray) | Check if is array | 是否是数组 |
41
+ | [isUrl](./references/is.md#isurl) | Check if is URL | 是否是 URL |
42
+ | [isWindow](./references/is.md#iswindow) | Check if is Window | 是否是 Window |
43
+ | [isMap](./references/is.md#ismap) | Check if is Map | 是否是 Map |
44
+ | [isRegExp](./references/is.md#isregexp) | Check if is RegExp | 是否是正则 |
45
+
46
+ ### 日期处理 (date)
47
+
48
+ 日期处理工具函数,基于 dayjs / Date handling utilities based on dayjs
49
+
50
+ | Function | Description | 中文说明 |
51
+ |----------|-------------|----------|
52
+ | [useDate](./references/date.md#usedate) | Get dayjs instance | 使用 dayjs 实例 |
53
+ | [dateFormat](./references/date.md#dateformat) | Format date to string | 日期转格式字符串 |
54
+ | [minute](./references/date.md#minute) | Get current time (default to minute) | 返回当前时间(默认到分钟) |
55
+ | [dateMonthDays](./references/date.md#datemonthdays) | Get days in month | 返回日期对应月份天数 |
56
+ | [getCurrDate](./references/date.md#getcurrdate) | Get date before/after i days | 返回前后 i 天的日期字符串 |
57
+ | [dateDiff](./references/date.md#datediff) | Get date difference | 返回两个日期时间差 |
58
+ | [dateFromNow](./references/date.md#datefromnow) | Relative time display | 相对时间显示 |
59
+ | [dateDiffFormat](./references/date.md#datediffformat) | Date difference in natural units | 计算两个日期之间的差值 |
60
+ | [durationFormat](./references/date.md#durationformat) | Format duration | 格式化时长 |
61
+ | [durationFormatNoZero](./references/date.md#durationformatnozero) | Format duration without zero | 格式化时长(去掉 0) |
62
+
63
+ ### 字符串操作 (string)
64
+
65
+ 字符串操作工具函数 / String manipulation utilities
66
+
67
+ | Function | Description | 中文说明 |
68
+ |----------|-------------|----------|
69
+ | [camelize](./references/string.md#camelize) | Kebab to camelCase | 中划线转小驼峰 |
70
+ | [kebabCase](./references/string.md#kebabcase) | CamelCase to kebab-case | 驼峰转中划线 |
71
+ | [snakeCase](./references/string.md#snakecase) | CamelCase to snake_case | 驼峰转下划线 |
72
+ | [lowerFirst](./references/string.md#lowerfirst) | First char to lower | 首字母转小写 |
73
+ | [upperFirst](./references/string.md#upperfirst) | First char to upper | 首字母转大写 |
74
+
75
+ ### 数字处理 (number)
76
+
77
+ 数字处理工具函数,基于 big.js / Number utilities based on big.js
78
+
79
+ | Function | Description | 中文说明 |
80
+ |----------|-------------|----------|
81
+ | [useNumber](./references/number.md#usenumber) | Get Big instance | 返回实例化的 Big 对象 |
82
+ | [formatNumber](./references/number.md#formatnumber) | Format number with separator | 格式化数字(千位分隔符) |
83
+ | [formatMoney](./references/number.md#formatmoney) | Format money (万/亿) | 格式化金钱(万、亿) |
84
+
85
+ ### 本地存储 (storage)
86
+
87
+ 本地存储工具函数,自动处理 JSON 序列化 / Storage utilities with JSON serialization
88
+
89
+ | Function | Description | 中文说明 |
90
+ |----------|-------------|----------|
91
+ | [setLocal](./references/storage.md#setlocal) | Set LocalStorage | 设置 LocalStorage |
92
+ | [getLocal](./references/storage.md#getlocal) | Get LocalStorage | 获取 LocalStorage |
93
+ | [removeLocal](./references/storage.md#removelocal) | Remove LocalStorage | 删除 LocalStorage |
94
+ | [setSession](./references/storage.md#setsession) | Set SessionStorage | 设置 SessionStorage |
95
+ | [getSession](./references/storage.md#getsession) | Get SessionStorage | 获取 SessionStorage |
96
+ | [removeSession](./references/storage.md#removesession) | Remove SessionStorage | 删除 SessionStorage |
97
+
98
+ ### Lodash 常用函数 (lodash)
99
+
100
+ Lodash 常用工具函数 / Common Lodash utilities
101
+
102
+ | Function | Description | 中文说明 |
103
+ |----------|-------------|----------|
104
+ | [deepClone](./references/lodash.md#deepclone) | Deep clone | 深拷贝 |
105
+ | [omit](./references/lodash.md#omit) | Omit fields | 删除对象中的某些键值对 |
106
+ | [pick](./references/lodash.md#pick) | Pick fields | 从对象中取出指定的键值对 |
107
+ | [debounce](./references/lodash.md#debounce) | Debounce function | 防抖函数 |
108
+ | [throttle](./references/lodash.md#throttle) | Throttle function | 节流函数 |
109
+ | [uniqueId](./references/lodash.md#uniqueid) | Generate unique ID | 生成浏览器唯一 ID |
110
+ | [get](./references/lodash.md#get) | Get value by path | 从对象中获取指定路径的值 |
111
+ | [objToQString](./references/lodash.md#objtoqstring) | Object to query string | 对象转 URL 字符串 |
112
+ | [qStringToObj](./references/lodash.md#qstringtoobj) | Query string to object | URL 字符串转对象 |
113
+ | [blobToBase64](./references/lodash.md#blobtobase64) | Blob to Base64 | Blob 转 Base64 |
114
+
115
+ ### 定时器 (timer)
116
+
117
+ 定时器工具函数 / Timer utilities
118
+
119
+ | Function | Description | 中文说明 |
120
+ |----------|-------------|----------|
121
+ | [sleep](./references/timer.md#sleep) | Sleep function | 睡眠函数 |
122
+ | [raf](./references/timer.md#raf) | Request animation frame | 监听下一动画帧 |
123
+ | [doubleRaf](./references/timer.md#doubleraf) | Double animation frame | 监听双帧动画帧 |
124
+
125
+ ### 设备判断 (device)
126
+
127
+ 设备判断工具函数 / Device detection utilities
128
+
129
+ | Function | Description | 中文说明 |
130
+ |----------|-------------|----------|
131
+ | [isIos](./references/device.md#isios) | Check if iOS | 是否是 iOS 客户端 |
132
+ | [isAndroid](./references/device.md#isandroid) | Check if Android | 是否是 Android 客户端 |
133
+ | [isWeChat](./references/device.md#iswechat) | Check if WeChat | 是否是微信浏览器 |
134
+ | [isWxMiniProgram](./references/device.md#iswxminiprogram) | Check if WeChat Mini Program | 是否是微信小程序 |
135
+ | [isHarmony](./references/device.md#isharmony) | Check if HarmonyOS | 是否是鸿蒙系统 |
136
+ | [getDeviceBrand](./references/device.md#getdevicebrand) | Get device brand | 获取设备厂商 |
137
+
138
+ ### 剪贴板 (clipboard)
139
+
140
+ 剪贴板操作工具函数 / Clipboard utilities
141
+
142
+ | Function | Description | 中文说明 |
143
+ |----------|-------------|----------|
144
+ | [copyTextToClipboard](./references/clipboard.md#copytexttoclipboard) | Copy text to clipboard | 复制文本到剪贴板 |
145
+
146
+ ### Cookie 操作 (cookie)
147
+
148
+ Cookie 操作工具函数 / Cookie utilities
149
+
150
+ | Function | Description | 中文说明 |
151
+ |----------|-------------|----------|
152
+ | [getCookie](./references/cookie.md#getcookie) | Get cookie value | 获取 Cookie 值 |
153
+ | [setCookie](./references/cookie.md#setcookie) | Set cookie | 设置 Cookie |
154
+ | [removeCookie](./references/cookie.md#removecookie) | Remove cookie | 删除 Cookie |
155
+
156
+ ### DOM 元素操作 (element)
157
+
158
+ DOM 元素操作工具函数 / DOM element utilities
159
+
160
+ | Function | Description | 中文说明 |
161
+ |----------|-------------|----------|
162
+ | [getBoundingClientRect](./references/element.md#getboundingclientrect) | Get element rect | 获取元素的位置和尺寸 |
163
+ | [addClass](./references/element.md#addclass) | Add CSS class | 添加 CSS 类名 |
164
+ | [removeClass](./references/element.md#removeclass) | Remove CSS class | 移除 CSS 类名 |
165
+ | [toggleClass](./references/element.md#toggleclass) | Toggle CSS class | 切换 CSS 类名 |
166
+
167
+ ### 深拷贝 (cloneDeep)
168
+
169
+ 深拷贝工具函数 / Deep clone utilities
170
+
171
+ | Function | Description | 中文说明 |
172
+ |----------|-------------|----------|
173
+ | [cloneDeep](./references/cloneDeep.md#clonedeep) | Deep clone | 深拷贝 |
174
+
175
+ ## Usage / 使用示例
176
+
177
+ ```ts
178
+ import {
179
+ isString, isNumber, isObject, isEmpty, isInteger,
180
+ useDate, dateFormat, dateFromNow, durationFormat,
181
+ camelize, kebabCase, snakeCase,
182
+ useNumber, formatNumber, formatMoney,
183
+ setLocal, getLocal, setSession, getSession,
184
+ deepClone, omit, pick, debounce, throttle, uniqueId,
185
+ sleep, raf, doubleRaf,
186
+ isIos, isAndroid, isWeChat, getDeviceBrand,
187
+ copyTextToClipboard
188
+ } from '@allkit/shared'
189
+
190
+ // 类型判断 / Type checking
191
+ isString('hello') // true
192
+ isNumber(123) // true
193
+ isObject({ name: 1 }) // true
194
+ isEmpty([]) // true
195
+ isInteger('123') // true
196
+
197
+ // 日期处理 / Date handling
198
+ useDate().format('YYYY-MM-DD HH:mm:ss')
199
+ dateFormat(new Date(), 'YYYY-MM-DD')
200
+ dateFromNow('2024-03-02 00:00')
201
+ durationFormat(61, { unit: 'm' })
202
+
203
+ // 字符串操作 / String manipulation
204
+ camelize('user-info') // 'userInfo'
205
+ kebabCase('userInfo') // 'user-info'
206
+ snakeCase('userInfo') // 'user_info'
207
+
208
+ // 数字处理 / Number handling
209
+ useNumber('1').add('2').toNumber() // 3
210
+ formatNumber(1234567) // '1,234,567'
211
+ formatMoney(1234567) // '123万4567'
212
+
213
+ // 本地存储 / Storage
214
+ setLocal('token', '123')
215
+ const token = getLocal<string>('token')
216
+ setSession('userInfo', { name: '张三' })
217
+ const userInfo = getSession<{ name: string }>('userInfo')
218
+
219
+ // Lodash 常用函数 / Lodash utilities
220
+ deepClone({ name: 'a', person: { age: 18 } })
221
+ omit({ a: 1, b: 2, c: 3 }, ['a']) // { b: 2, c: 3 }
222
+ pick({ a: 1, b: 2, c: 3 }, ['a', 'b']) // { a: 1, b: 2 }
223
+ debounce(fn, 300)
224
+ throttle(fn, 100)
225
+ uniqueId() // 16 位
226
+
227
+ // 定时器 / Timer
228
+ await sleep(1000)
229
+ await raf()
230
+ await doubleRaf()
231
+
232
+ // 设备判断 / Device detection
233
+ isIos() // boolean
234
+ isAndroid() // boolean
235
+ isWeChat() // boolean
236
+ getDeviceBrand() // EnumDeviceBrand
237
+
238
+ // 剪贴板 / Clipboard
239
+ copyTextToClipboard('hello') // boolean
240
+ ```