2 lines
3.9 KiB
JavaScript
2 lines
3.9 KiB
JavaScript
import{x as L,u as D,v,H as y,af as Y,a5 as b}from"./vendor-wTuFzYxX.js";function H(t){return typeof t=="function"?t():D(t)}typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const w=()=>{};function k(t,r){function e(...a){return new Promise((o,l)=>{Promise.resolve(t(()=>r.apply(this,a),{fn:r,thisArg:this,args:a})).then(o).catch(l)})}return e}function x(...t){let r=0,e,a=!0,o=w,l,i,s,n,c;!L(t[0])&&typeof t[0]=="object"?{delay:i,trailing:s=!0,leading:n=!0,rejectOnCancel:c=!1}=t[0]:[i,s=!0,n=!0,c=!1]=t;const M=()=>{e&&(clearTimeout(e),e=void 0,o(),o=w)};return d=>{const u=H(i),g=Date.now()-r,m=()=>l=d();return M(),u<=0?(r=Date.now(),m()):(g>u&&(n||!a)?(r=Date.now(),m()):s&&(l=new Promise((h,p)=>{o=c?p:h,e=setTimeout(()=>{r=Date.now(),a=!0,h(m()),M()},Math.max(0,u-g))})),!n&&!e&&(e=setTimeout(()=>a=!0,u)),a=!1,l)}}function P(t,r=200,e=!1,a=!0,o=!1){return k(x(r,e,a,o),t)}const T=/[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;function W(t,r,e,a){let o=t<12?"AM":"PM";return a&&(o=o.split("").reduce((l,i)=>l+=`${i}.`,"")),e?o.toLowerCase():o}function f(t){const r=["th","st","nd","rd"],e=t%100;return t+(r[(e-20)%10]||r[e]||r[0])}function $(t,r,e={}){var a;const o=t.getFullYear(),l=t.getMonth(),i=t.getDate(),s=t.getHours(),n=t.getMinutes(),c=t.getSeconds(),M=t.getMilliseconds(),S=t.getDay(),d=(a=e.customMeridiem)!=null?a:W,u={Yo:()=>f(o),YY:()=>String(o).slice(-2),YYYY:()=>o,M:()=>l+1,Mo:()=>f(l+1),MM:()=>`${l+1}`.padStart(2,"0"),MMM:()=>t.toLocaleDateString(e.locales,{month:"short"}),MMMM:()=>t.toLocaleDateString(e.locales,{month:"long"}),D:()=>String(i),Do:()=>f(i),DD:()=>`${i}`.padStart(2,"0"),H:()=>String(s),Ho:()=>f(s),HH:()=>`${s}`.padStart(2,"0"),h:()=>`${s%12||12}`.padStart(1,"0"),ho:()=>f(s%12||12),hh:()=>`${s%12||12}`.padStart(2,"0"),m:()=>String(n),mo:()=>f(n),mm:()=>`${n}`.padStart(2,"0"),s:()=>String(c),so:()=>f(c),ss:()=>`${c}`.padStart(2,"0"),SSS:()=>`${M}`.padStart(3,"0"),d:()=>S,dd:()=>t.toLocaleDateString(e.locales,{weekday:"narrow"}),ddd:()=>t.toLocaleDateString(e.locales,{weekday:"short"}),dddd:()=>t.toLocaleDateString(e.locales,{weekday:"long"}),A:()=>d(s,n),AA:()=>d(s,n,!1,!0),a:()=>d(s,n,!0),aa:()=>d(s,n,!0,!0)};return r.replace(T,(g,m)=>{var h,p;return(p=m??((h=u[g])==null?void 0:h.call(u)))!=null?p:g})}const E=t=>/,\s*\{/.test(t)||!(t.startsWith("http")||t.startsWith("data:")||t.startsWith("blob:")),R=t=>{let r=new Date().getTime(),e=Math.floor((r-t)/1e3),a="";return e<=30?a="刚刚":e<60?a=e+"秒前":e<3600?a=Math.floor(e/60)+"分钟前":e<86400?a=Math.floor(e/3600)+"小时前":e<2592e3?a=Math.floor(e/86400)+"天前":a=$(new Date(t),"YYYY-MM-DD"),a},A='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path fill="currentColor" d="M512 64a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V96a32 32 0 0 1 32-32m0 640a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V736a32 32 0 0 1 32-32m448-192a32 32 0 0 1-32 32H736a32 32 0 1 1 0-64h192a32 32 0 0 1 32 32m-640 0a32 32 0 0 1-32 32H96a32 32 0 0 1 0-64h192a32 32 0 0 1 32 32M195.2 195.2a32 32 0 0 1 45.248 0L376.32 331.008a32 32 0 0 1-45.248 45.248L195.2 240.448a32 32 0 0 1 0-45.248zm452.544 452.544a32 32 0 0 1 45.248 0L828.8 783.552a32 32 0 0 1-45.248 45.248L647.744 692.992a32 32 0 0 1 0-45.248zM828.8 195.264a32 32 0 0 1 0 45.184L692.992 376.32a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0m-452.544 452.48a32 32 0 0 1 0 45.248L240.448 828.8a32 32 0 0 1-45.248-45.248l135.808-135.808a32 32 0 0 1 45.248 0z"/></svg>',V=(t,r,e=A)=>{const a=v(!1);let o=null;const l=()=>a.value=!1,i=()=>a.value=!0;y(a,n=>{if(!n)return o==null?void 0:o.close();o=Y.service({target:D(t),spinner:e,text:r,lock:!0,background:"rgba(0, 0, 0, 0)"})});const s=n=>{if(!(n instanceof Promise))throw TypeError("loadingWrapper argument must be Promise");return i(),n.finally(l)};return b(()=>{l()}),{isLoading:a,showLoading:i,closeLoading:l,loadingWrapper:s}};export{P as a,R as d,E as i,V as u};
|