@banmao/hooks 0.0.4 → 0.0.6
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/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +422 -385
- package/dist/useAsyncData/index.d.ts +9 -0
- package/dist/useAsyncData/types.d.ts +3 -0
- package/package.json +5 -9
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("vue");function ce(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Z={exports:{}},le=Z.exports,re;function de(){return re||(re=1,function(t,s){(function(d,m){t.exports=m()})(le,function(){var d=1e3,m=6e4,w=36e5,y="millisecond",f="second",v="minute",h="hour",p="day",S="week",o="month",g="quarter",D="year",O="date",j="Invalid Date",I=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,G=/\[([^\]]+)]|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,b={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(a){var r=["th","st","nd","rd"],e=a%100;return"["+a+(r[(e-20)%10]||r[e]||r[0])+"]"}},L=function(a,r,e){var i=String(a);return!i||i.length>=r?a:""+Array(r+1-i.length).join(e)+a},z={s:L,z:function(a){var r=-a.utcOffset(),e=Math.abs(r),i=Math.floor(e/60),n=e%60;return(r<=0?"+":"-")+L(i,2,"0")+":"+L(n,2,"0")},m:function a(r,e){if(r.date()<e.date())return-a(e,r);var i=12*(e.year()-r.year())+(e.month()-r.month()),n=r.clone().add(i,o),u=e-n<0,c=r.clone().add(i+(u?-1:1),o);return+(-(i+(e-n)/(u?n-c:c-n))||0)},a:function(a){return a<0?Math.ceil(a)||0:Math.floor(a)},p:function(a){return{M:o,y:D,w:S,d:p,D:O,h,m:v,s:f,ms:y,Q:g}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(a){return a===void 0}},H="en",T={};T[H]=b;var K="$isDayjsObject",P=function(a){return a instanceof J||!(!a||!a[K])},Y=function a(r,e,i){var n;if(!r)return H;if(typeof r=="string"){var u=r.toLowerCase();T[u]&&(n=u),e&&(T[u]=e,n=u);var c=r.split("-");if(!n&&c.length>1)return a(c[0])}else{var M=r.name;T[M]=r,n=M}return!i&&n&&(H=n),n||!i&&H},_=function(a,r){if(P(a))return a.clone();var e=typeof r=="object"?r:{};return e.date=a,e.args=arguments,new J(e)},$=z;$.l=Y,$.i=P,$.w=function(a,r){return _(a,{locale:r.$L,utc:r.$u,x:r.$x,$offset:r.$offset})};var J=function(){function a(e){this.$L=Y(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[K]=!0}var r=a.prototype;return r.parse=function(e){this.$d=function(i){var n=i.date,u=i.utc;if(n===null)return new Date(NaN);if($.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var c=n.match(I);if(c){var M=c[2]-1||0,x=(c[7]||"0").substring(0,3);return u?new Date(Date.UTC(c[1],M,c[3]||1,c[4]||0,c[5]||0,c[6]||0,x)):new Date(c[1],M,c[3]||1,c[4]||0,c[5]||0,c[6]||0,x)}}return new Date(n)}(e),this.init()},r.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},r.$utils=function(){return $},r.isValid=function(){return this.$d.toString()!==j},r.isSame=function(e,i){var n=_(e);return this.startOf(i)<=n&&n<=this.endOf(i)},r.isAfter=function(e,i){return _(e)<this.startOf(i)},r.isBefore=function(e,i){return this.endOf(i)<_(e)},r.$g=function(e,i,n){return $.u(e)?this[i]:this.set(n,e)},r.unix=function(){return Math.floor(this.valueOf()/1e3)},r.valueOf=function(){return this.$d.getTime()},r.startOf=function(e,i){var n=this,u=!!$.u(i)||i,c=$.p(e),M=function(R,C){var A=$.w(n.$u?Date.UTC(n.$y,C,R):new Date(n.$y,C,R),n);return u?A:A.endOf(p)},x=function(R,C){return $.w(n.toDate()[R].apply(n.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(C)),n)},E=this.$W,W=this.$M,k=this.$D,F="set"+(this.$u?"UTC":"");switch(c){case D:return u?M(1,0):M(31,11);case o:return u?M(1,W):M(0,W+1);case S:var V=this.$locale().weekStart||0,U=(E<V?E+7:E)-V;return M(u?k-U:k+(6-U),W);case p:case O:return x(F+"Hours",0);case h:return x(F+"Minutes",1);case v:return x(F+"Seconds",2);case f:return x(F+"Milliseconds",3);default:return this.clone()}},r.endOf=function(e){return this.startOf(e,!1)},r.$set=function(e,i){var n,u=$.p(e),c="set"+(this.$u?"UTC":""),M=(n={},n[p]=c+"Date",n[O]=c+"Date",n[o]=c+"Month",n[D]=c+"FullYear",n[h]=c+"Hours",n[v]=c+"Minutes",n[f]=c+"Seconds",n[y]=c+"Milliseconds",n)[u],x=u===p?this.$D+(i-this.$W):i;if(u===o||u===D){var E=this.clone().set(O,1);E.$d[M](x),E.init(),this.$d=E.set(O,Math.min(this.$D,E.daysInMonth())).$d}else M&&this.$d[M](x);return this.init(),this},r.set=function(e,i){return this.clone().$set(e,i)},r.get=function(e){return this[$.p(e)]()},r.add=function(e,i){var n,u=this;e=Number(e);var c=$.p(i),M=function(W){var k=_(u);return $.w(k.date(k.date()+Math.round(W*e)),u)};if(c===o)return this.set(o,this.$M+e);if(c===D)return this.set(D,this.$y+e);if(c===p)return M(1);if(c===S)return M(7);var x=(n={},n[v]=m,n[h]=w,n[f]=d,n)[c]||1,E=this.$d.getTime()+e*x;return $.w(E,this)},r.subtract=function(e,i){return this.add(-1*e,i)},r.format=function(e){var i=this,n=this.$locale();if(!this.isValid())return n.invalidDate||j;var u=e||"YYYY-MM-DDTHH:mm:ssZ",c=$.z(this),M=this.$H,x=this.$m,E=this.$M,W=n.weekdays,k=n.months,F=n.meridiem,V=function(C,A,B,Q){return C&&(C[A]||C(i,u))||B[A].slice(0,Q)},U=function(C){return $.s(M%12||12,C,"0")},R=F||function(C,A,B){var Q=C<12?"AM":"PM";return B?Q.toLowerCase():Q};return u.replace(G,function(C,A){return A||function(B){switch(B){case"YY":return String(i.$y).slice(-2);case"YYYY":return $.s(i.$y,4,"0");case"M":return E+1;case"MM":return $.s(E+1,2,"0");case"MMM":return V(n.monthsShort,E,k,3);case"MMMM":return V(k,E);case"D":return i.$D;case"DD":return $.s(i.$D,2,"0");case"d":return String(i.$W);case"dd":return V(n.weekdaysMin,i.$W,W,2);case"ddd":return V(n.weekdaysShort,i.$W,W,3);case"dddd":return W[i.$W];case"H":return String(M);case"HH":return $.s(M,2,"0");case"h":return U(1);case"hh":return U(2);case"a":return R(M,x,!0);case"A":return R(M,x,!1);case"m":return String(x);case"mm":return $.s(x,2,"0");case"s":return String(i.$s);case"ss":return $.s(i.$s,2,"0");case"SSS":return $.s(i.$ms,3,"0");case"Z":return c}return null}(C)||c.replace(":","")})},r.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},r.diff=function(e,i,n){var u,c=this,M=$.p(i),x=_(e),E=(x.utcOffset()-this.utcOffset())*m,W=this-x,k=function(){return $.m(c,x)};switch(M){case D:u=k()/12;break;case o:u=k();break;case g:u=k()/3;break;case S:u=(W-E)/6048e5;break;case p:u=(W-E)/864e5;break;case h:u=W/w;break;case v:u=W/m;break;case f:u=W/d;break;default:u=W}return n?u:$.a(u)},r.daysInMonth=function(){return this.endOf(o).$D},r.$locale=function(){return T[this.$L]},r.locale=function(e,i){if(!e)return this.$L;var n=this.clone(),u=Y(e,i,!0);return u&&(n.$L=u),n},r.clone=function(){return $.w(this.$d,this)},r.toDate=function(){return new Date(this.valueOf())},r.toJSON=function(){return this.isValid()?this.toISOString():null},r.toISOString=function(){return this.$d.toISOString()},r.toString=function(){return this.$d.toUTCString()},a}(),ne=J.prototype;return _.prototype=ne,[["$ms",y],["$s",f],["$m",v],["$H",h],["$W",p],["$M",o],["$y",D],["$D",O]].forEach(function(a){ne[a[1]]=function(r){return this.$g(r,a[0],a[1])}}),_.extend=function(a,r){return a.$i||(a(r,J,_),a.$i=!0),_},_.locale=Y,_.isDayjs=P,_.unix=function(a){return _(1e3*a)},_.en=T[H],_.Ls=T,_.p={},_})}(Z)),Z.exports}var fe=de();const he=ce(fe);function me(t){const s=new Blob([t],{type:"application/vnd.ms-excel"});return window.URL.createObjectURL(s)}function ve(){return document.createElement("a")}function oe(t,s){const d=he().format("yyyy-MM-dd hh:mm:ss");function m(){const w=ve(),y=me(t);w.href=y,s?w.download=s||`${s}-${d}.xlsx`:w.download=`${d}.xlsx`,document.body.appendChild(w),w.click(),document.body.removeChild(w),window.URL.revokeObjectURL(y)}m()}function pe(t,s){throw new Error(`[naive/${t}]: ${s}`)}const ge="n-message-api";function we(){const t=l.inject(ge,null);return t===null&&pe("use-message","No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),t}function $e(t,s={}){const{exportRequestFn:d,filterOption:m=l.ref(),callback:w,immediate:y=!0,code:f=200}=s,v=l.ref(!1),h=l.ref({page:1,pageSize:10,itemCount:0,showSizePicker:!0,pageSizes:[10,20,30,40],showQuickJumper:!0,prefix:b=>`共 ${b.itemCount} 条`}),p=l.ref([]),S=l.computed(()=>m.value),o=async(b=h.value.page,L)=>{v.value=!0;try{const{status:z,data:H}=await t({pageNum:b,pageSize:h.value.pageSize,...S.value,...L}),{list:T,pageNum:K,total:P,pageSize:Y}=w&&w(H)||H;if(z===f&&Array.isArray(T))p.value=T,h.value={...h.value,page:K,itemCount:P,pageSize:Y};else throw p.value=[],h.value={...h.value,pageSize:10,itemCount:0,page:1},new Error("list的数据类型错误")}catch(z){throw console.error("Error in loadData:",z),z}finally{v.value=!1}},g=we(),D=async()=>{if(!d||typeof d!="function")throw new Error("当前没有提供exportRequest函数");try{const{data:b,fileName:L}=await d(m.value);oe(b,L),g==null||g.success("成功导出")}catch(b){throw console.error("Error in handleExcelData:",b),b}},O=(b,L)=>{L!==void 0&&(h.value.pageSize=L),o(b)},j=b=>{O(b)},I=b=>{O(1,b)},G=b=>{if(b.sorter){const L=[...p.value].sort((z,H)=>b.order==="ascend"?z[b.columnKey]>H[b.columnKey]?1:-1:b.order==="descend"?z[b.columnKey]<H[b.columnKey]?1:-1:0);p.value=L}};return l.onMounted(()=>y&&o(h.value.page)),{dataSource:p,loading:v,pagination:h,handleExcelData:D,handlePageChange:j,handlePageSizeChange:I,handleSortChange:G,loadData:o}}function te(t){return l.getCurrentScope()?(l.onScopeDispose(t),!0):!1}const X=new WeakMap,ye=(...t)=>{var s;const d=t[0],m=(s=l.getCurrentInstance())==null?void 0:s.proxy;if(m==null&&!l.hasInjectionContext())throw new Error("injectLocal must be called in setup");return m&&X.has(m)&&d in X.get(m)?X.get(m)[d]:l.inject(...t)},Me=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Se=Object.prototype.toString,be=t=>Se.call(t)==="[object Object]",De=()=>{};function se(t){return t.endsWith("rem")?Number.parseFloat(t)*16:Number.parseFloat(t)}function Oe(t){return l.getCurrentInstance()}function ee(t){return Array.isArray(t)?t:[t]}function ae(t,s=!0,d){Oe()?l.onMounted(t,d):s?t():l.nextTick(t)}const q=Me?window:void 0;function N(t){var s;const d=l.toValue(t);return(s=d==null?void 0:d.$el)!=null?s:d}function ie(...t){let s,d,m,w;if(typeof t[0]=="string"||Array.isArray(t[0])?([d,m,w]=t,s=q):[s,d,m,w]=t,!s)return De;d=ee(d),m=ee(m);const y=[],f=()=>{y.forEach(S=>S()),y.length=0},v=(S,o,g,D)=>(S.addEventListener(o,g,D),()=>S.removeEventListener(o,g,D)),h=l.watch(()=>[N(s),l.toValue(w)],([S,o])=>{if(f(),!S)return;const g=be(o)?{...o}:o;y.push(...d.flatMap(D=>m.map(O=>v(S,D,O,g))))},{immediate:!0,flush:"post"}),p=()=>{h(),f()};return te(p),p}function xe(){const t=l.ref(!1),s=l.getCurrentInstance();return s&&l.onMounted(()=>{t.value=!0},s),t}function ue(t){const s=xe();return l.computed(()=>(s.value,!!t()))}const _e=Symbol("vueuse-ssr-width");function Ee(){const t=l.hasInjectionContext()?ye(_e,null):null;return typeof t=="number"?t:void 0}function We(t,s={}){const{window:d=q,ssrWidth:m=Ee()}=s,w=ue(()=>d&&"matchMedia"in d&&typeof d.matchMedia=="function"),y=l.ref(typeof m=="number");let f;const v=l.ref(!1),h=o=>{v.value=o.matches},p=()=>{f&&("removeEventListener"in f?f.removeEventListener("change",h):f.removeListener(h))},S=l.watchEffect(()=>{if(y.value){y.value=!w.value;const o=l.toValue(t).split(",");v.value=o.some(g=>{const D=g.includes("not all"),O=g.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),j=g.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);let I=!!(O||j);return O&&I&&(I=m>=se(O[1])),j&&I&&(I=m<=se(j[1])),D?!I:I});return}w.value&&(p(),f=d.matchMedia(l.toValue(t)),"addEventListener"in f?f.addEventListener("change",h):f.addListener(h),v.value=f.matches)});return te(()=>{S(),p(),f=void 0}),l.computed(()=>v.value)}function Ce(t,s,d={}){const{window:m=q,...w}=d;let y;const f=ue(()=>m&&"ResizeObserver"in m),v=()=>{y&&(y.disconnect(),y=void 0)},h=l.computed(()=>{const o=l.toValue(t);return Array.isArray(o)?o.map(g=>N(g)):[N(o)]}),p=l.watch(h,o=>{if(v(),f.value&&m){y=new ResizeObserver(s);for(const g of o)g&&y.observe(g,w)}},{immediate:!0,flush:"post"}),S=()=>{v(),p()};return te(S),{isSupported:f,stop:S}}function je(t,s={width:0,height:0},d={}){const{window:m=q,box:w="content-box"}=d,y=l.computed(()=>{var o,g;return(g=(o=N(t))==null?void 0:o.namespaceURI)==null?void 0:g.includes("svg")}),f=l.ref(s.width),v=l.ref(s.height),{stop:h}=Ce(t,([o])=>{const g=w==="border-box"?o.borderBoxSize:w==="content-box"?o.contentBoxSize:o.devicePixelContentBoxSize;if(m&&y.value){const D=N(t);if(D){const O=D.getBoundingClientRect();f.value=O.width,v.value=O.height}}else if(g){const D=ee(g);f.value=D.reduce((O,{inlineSize:j})=>O+j,0),v.value=D.reduce((O,{blockSize:j})=>O+j,0)}else f.value=o.contentRect.width,v.value=o.contentRect.height},d);ae(()=>{const o=N(t);o&&(f.value="offsetWidth"in o?o.offsetWidth:s.width,v.value="offsetHeight"in o?o.offsetHeight:s.height)});const p=l.watch(()=>N(t),o=>{f.value=o?s.width:0,v.value=o?s.height:0});function S(){h(),p()}return{width:f,height:v,stop:S}}function Le(t={}){const{window:s=q,initialWidth:d=Number.POSITIVE_INFINITY,initialHeight:m=Number.POSITIVE_INFINITY,listenOrientation:w=!0,includeScrollbar:y=!0,type:f="inner"}=t,v=l.ref(d),h=l.ref(m),p=()=>{if(s)if(f==="outer")v.value=s.outerWidth,h.value=s.outerHeight;else if(f==="visual"&&s.visualViewport){const{width:S,height:o,scale:g}=s.visualViewport;v.value=Math.round(S*g),h.value=Math.round(o*g)}else y?(v.value=s.innerWidth,h.value=s.innerHeight):(v.value=s.document.documentElement.clientWidth,h.value=s.document.documentElement.clientHeight)};if(p(),ae(p),ie("resize",p,{passive:!0}),s&&f==="visual"&&s.visualViewport&&ie(s.visualViewport,"resize",p,{passive:!0}),w){const S=We("(orientation: portrait)");l.watch(S,()=>p())}return{width:v,height:h}}function ke(t,s){if(!t)throw new Error("tableRef are required");const d=l.computed(()=>{var h;return(h=t.value)==null?void 0:h.searchRef}),{height:m}=Le(),{height:w}=je(d),{height:y=0,minHeight:f=600}=s||{};return{height:l.computed(()=>{const h=m.value-w.value-y;return h>f?h:f})}}exports.useExportFile=oe;exports.useList=$e;exports.useTableHeight=ke;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue");function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q={exports:{}},le=Q.exports,re;function de(){return re||(re=1,function(e,s){(function(d,m){e.exports=m()})(le,function(){var d=1e3,m=6e4,g=36e5,w="millisecond",p="second",i="minute",a="hour",v="day",M="week",c="month",S="quarter",b="year",D="date",T="Invalid Date",G=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,X=/\[([^\]]+)]|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,O={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(l){var r=["th","st","nd","rd"],t=l%100;return"["+l+(r[(t-20)%10]||r[t]||r[0])+"]"}},j=function(l,r,t){var o=String(l);return!o||o.length>=r?l:""+Array(r+1-o.length).join(t)+l},R={s:j,z:function(l){var r=-l.utcOffset(),t=Math.abs(r),o=Math.floor(t/60),n=t%60;return(r<=0?"+":"-")+j(o,2,"0")+":"+j(n,2,"0")},m:function l(r,t){if(r.date()<t.date())return-l(t,r);var o=12*(t.year()-r.year())+(t.month()-r.month()),n=r.clone().add(o,c),f=t-n<0,h=r.clone().add(o+(f?-1:1),c);return+(-(o+(t-n)/(f?n-h:h-n))||0)},a:function(l){return l<0?Math.ceil(l)||0:Math.floor(l)},p:function(l){return{M:c,y:b,w:M,d:v,D,h:a,m:i,s:p,ms:w,Q:S}[l]||String(l||"").toLowerCase().replace(/s$/,"")},u:function(l){return l===void 0}},H="en",I={};I[H]=O;var q="$isDayjsObject",P=function(l){return l instanceof K||!(!l||!l[q])},N=function l(r,t,o){var n;if(!r)return H;if(typeof r=="string"){var f=r.toLowerCase();I[f]&&(n=f),t&&(I[f]=t,n=f);var h=r.split("-");if(!n&&h.length>1)return l(h[0])}else{var y=r.name;I[y]=r,n=y}return!o&&n&&(H=n),n||!o&&H},C=function(l,r){if(P(l))return l.clone();var t=typeof r=="object"?r:{};return t.date=l,t.args=arguments,new K(t)},$=R;$.l=N,$.i=P,$.w=function(l,r){return C(l,{locale:r.$L,utc:r.$u,x:r.$x,$offset:r.$offset})};var K=function(){function l(t){this.$L=N(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[q]=!0}var r=l.prototype;return r.parse=function(t){this.$d=function(o){var n=o.date,f=o.utc;if(n===null)return new Date(NaN);if($.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var h=n.match(G);if(h){var y=h[2]-1||0,x=(h[7]||"0").substring(0,3);return f?new Date(Date.UTC(h[1],y,h[3]||1,h[4]||0,h[5]||0,h[6]||0,x)):new Date(h[1],y,h[3]||1,h[4]||0,h[5]||0,h[6]||0,x)}}return new Date(n)}(t),this.init()},r.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},r.$utils=function(){return $},r.isValid=function(){return this.$d.toString()!==T},r.isSame=function(t,o){var n=C(t);return this.startOf(o)<=n&&n<=this.endOf(o)},r.isAfter=function(t,o){return C(t)<this.startOf(o)},r.isBefore=function(t,o){return this.endOf(o)<C(t)},r.$g=function(t,o,n){return $.u(t)?this[o]:this.set(n,t)},r.unix=function(){return Math.floor(this.valueOf()/1e3)},r.valueOf=function(){return this.$d.getTime()},r.startOf=function(t,o){var n=this,f=!!$.u(o)||o,h=$.p(t),y=function(V,_){var L=$.w(n.$u?Date.UTC(n.$y,_,V):new Date(n.$y,_,V),n);return f?L:L.endOf(v)},x=function(V,_){return $.w(n.toDate()[V].apply(n.toDate("s"),(f?[0,0,0,0]:[23,59,59,999]).slice(_)),n)},E=this.$W,W=this.$M,k=this.$D,Y="set"+(this.$u?"UTC":"");switch(h){case b:return f?y(1,0):y(31,11);case c:return f?y(1,W):y(0,W+1);case M:var z=this.$locale().weekStart||0,F=(E<z?E+7:E)-z;return y(f?k-F:k+(6-F),W);case v:case D:return x(Y+"Hours",0);case a:return x(Y+"Minutes",1);case i:return x(Y+"Seconds",2);case p:return x(Y+"Milliseconds",3);default:return this.clone()}},r.endOf=function(t){return this.startOf(t,!1)},r.$set=function(t,o){var n,f=$.p(t),h="set"+(this.$u?"UTC":""),y=(n={},n[v]=h+"Date",n[D]=h+"Date",n[c]=h+"Month",n[b]=h+"FullYear",n[a]=h+"Hours",n[i]=h+"Minutes",n[p]=h+"Seconds",n[w]=h+"Milliseconds",n)[f],x=f===v?this.$D+(o-this.$W):o;if(f===c||f===b){var E=this.clone().set(D,1);E.$d[y](x),E.init(),this.$d=E.set(D,Math.min(this.$D,E.daysInMonth())).$d}else y&&this.$d[y](x);return this.init(),this},r.set=function(t,o){return this.clone().$set(t,o)},r.get=function(t){return this[$.p(t)]()},r.add=function(t,o){var n,f=this;t=Number(t);var h=$.p(o),y=function(W){var k=C(f);return $.w(k.date(k.date()+Math.round(W*t)),f)};if(h===c)return this.set(c,this.$M+t);if(h===b)return this.set(b,this.$y+t);if(h===v)return y(1);if(h===M)return y(7);var x=(n={},n[i]=m,n[a]=g,n[p]=d,n)[h]||1,E=this.$d.getTime()+t*x;return $.w(E,this)},r.subtract=function(t,o){return this.add(-1*t,o)},r.format=function(t){var o=this,n=this.$locale();if(!this.isValid())return n.invalidDate||T;var f=t||"YYYY-MM-DDTHH:mm:ssZ",h=$.z(this),y=this.$H,x=this.$m,E=this.$M,W=n.weekdays,k=n.months,Y=n.meridiem,z=function(_,L,U,J){return _&&(_[L]||_(o,f))||U[L].slice(0,J)},F=function(_){return $.s(y%12||12,_,"0")},V=Y||function(_,L,U){var J=_<12?"AM":"PM";return U?J.toLowerCase():J};return f.replace(X,function(_,L){return L||function(U){switch(U){case"YY":return String(o.$y).slice(-2);case"YYYY":return $.s(o.$y,4,"0");case"M":return E+1;case"MM":return $.s(E+1,2,"0");case"MMM":return z(n.monthsShort,E,k,3);case"MMMM":return z(k,E);case"D":return o.$D;case"DD":return $.s(o.$D,2,"0");case"d":return String(o.$W);case"dd":return z(n.weekdaysMin,o.$W,W,2);case"ddd":return z(n.weekdaysShort,o.$W,W,3);case"dddd":return W[o.$W];case"H":return String(y);case"HH":return $.s(y,2,"0");case"h":return F(1);case"hh":return F(2);case"a":return V(y,x,!0);case"A":return V(y,x,!1);case"m":return String(x);case"mm":return $.s(x,2,"0");case"s":return String(o.$s);case"ss":return $.s(o.$s,2,"0");case"SSS":return $.s(o.$ms,3,"0");case"Z":return h}return null}(_)||h.replace(":","")})},r.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},r.diff=function(t,o,n){var f,h=this,y=$.p(o),x=C(t),E=(x.utcOffset()-this.utcOffset())*m,W=this-x,k=function(){return $.m(h,x)};switch(y){case b:f=k()/12;break;case c:f=k();break;case S:f=k()/3;break;case M:f=(W-E)/6048e5;break;case v:f=(W-E)/864e5;break;case a:f=W/g;break;case i:f=W/m;break;case p:f=W/d;break;default:f=W}return n?f:$.a(f)},r.daysInMonth=function(){return this.endOf(c).$D},r.$locale=function(){return I[this.$L]},r.locale=function(t,o){if(!t)return this.$L;var n=this.clone(),f=N(t,o,!0);return f&&(n.$L=f),n},r.clone=function(){return $.w(this.$d,this)},r.toDate=function(){return new Date(this.valueOf())},r.toJSON=function(){return this.isValid()?this.toISOString():null},r.toISOString=function(){return this.$d.toISOString()},r.toString=function(){return this.$d.toUTCString()},l}(),ne=K.prototype;return C.prototype=ne,[["$ms",w],["$s",p],["$m",i],["$H",a],["$W",v],["$M",c],["$y",b],["$D",D]].forEach(function(l){ne[l[1]]=function(r){return this.$g(r,l[0],l[1])}}),C.extend=function(l,r){return l.$i||(l(r,K,C),l.$i=!0),C},C.locale=N,C.isDayjs=P,C.unix=function(l){return C(1e3*l)},C.en=I[H],C.Ls=I,C.p={},C})}(Q)),Q.exports}var fe=de();const he=ce(fe);function ve(e){const s=new Blob([e],{type:"application/vnd.ms-excel"});return window.URL.createObjectURL(s)}function me(){return document.createElement("a")}function oe(e,s){const d=he().format("yyyy-MM-dd hh:mm:ss");function m(){const g=me(),w=ve(e);g.href=w,s?g.download=s||`${s}-${d}.xlsx`:g.download=`${d}.xlsx`,document.body.appendChild(g),g.click(),document.body.removeChild(g),window.URL.revokeObjectURL(w)}m()}function pe(e,s){throw new Error(`[naive/${e}]: ${s}`)}const ge="n-message-api";function we(){const e=u.inject(ge,null);return e===null&&pe("use-message","No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),e}function $e(e,s={}){const{exportRequestFn:d,filterOption:m=u.ref(),callback:g,immediate:w=!0,code:p=200}=s,i=u.ref(!1),a=u.ref({page:1,pageSize:10,itemCount:0,showSizePicker:!0,pageSizes:[10,20,30,40],showQuickJumper:!0,prefix:O=>`共 ${O.itemCount} 条`}),v=u.ref([]),M=u.computed(()=>m.value),c=async(O=a.value.page,j)=>{i.value=!0;try{const{status:R,data:H}=await e({pageNum:O,pageSize:a.value.pageSize,...M.value,...j}),{list:I,pageNum:q,total:P,pageSize:N}=g&&g(H)||H;if(R===p&&Array.isArray(I))v.value=I,a.value={...a.value,page:q,itemCount:P,pageSize:N};else throw v.value=[],a.value={...a.value,pageSize:10,itemCount:0,page:1},new Error("list的数据类型错误")}catch(R){throw console.error("Error in loadData:",R),R}finally{i.value=!1}},S=we(),b=async()=>{if(!d||typeof d!="function")throw new Error("当前没有提供exportRequest函数");try{const{data:O,fileName:j}=await d(m.value);oe(O,j),S==null||S.success("成功导出")}catch(O){throw console.error("Error in handleExcelData:",O),O}},D=(O,j)=>{j!==void 0&&(a.value.pageSize=j),c(O)},T=O=>{D(O)},G=O=>{D(1,O)},X=O=>{if(O.sorter){const j=[...v.value].sort((R,H)=>O.order==="ascend"?R[O.columnKey]>H[O.columnKey]?1:-1:O.order==="descend"?R[O.columnKey]<H[O.columnKey]?1:-1:0);v.value=j}};return u.onMounted(()=>w&&c(a.value.page)),{dataSource:v,loading:i,pagination:a,handleExcelData:b,handlePageChange:T,handlePageSizeChange:G,handleSortChange:X,loadData:c}}function ie(e){return u.getCurrentScope()?(u.onScopeDispose(e),!0):!1}const ee=new WeakMap,ye=(...e)=>{var s;const d=e[0],m=(s=u.getCurrentInstance())==null?void 0:s.proxy;if(m==null&&!u.hasInjectionContext())throw new Error("injectLocal must be called in setup");return m&&ee.has(m)&&d in ee.get(m)?ee.get(m)[d]:u.inject(...e)},Me=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Se=Object.prototype.toString,be=e=>Se.call(e)==="[object Object]";function se(e){return e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e)}function Z(e){return Array.isArray(e)?e:[e]}function De(e){return u.getCurrentInstance()}function ue(e,s=!0,d){De()?u.onMounted(e,d):s?e():u.nextTick(e)}function Oe(e,s,d){return u.watch(e,s,{...d,immediate:!0})}const B=Me?window:void 0;function A(e){var s;const d=u.toValue(e);return(s=d==null?void 0:d.$el)!=null?s:d}function te(...e){const s=[],d=()=>{s.forEach(i=>i()),s.length=0},m=(i,a,v,M)=>(i.addEventListener(a,v,M),()=>i.removeEventListener(a,v,M)),g=u.computed(()=>{const i=Z(u.toValue(e[0])).filter(a=>a!=null);return i.every(a=>typeof a!="string")?i:void 0}),w=Oe(()=>{var i,a;return[(a=(i=g.value)==null?void 0:i.map(v=>A(v)))!=null?a:[B].filter(v=>v!=null),Z(u.toValue(g.value?e[1]:e[0])),Z(u.unref(g.value?e[2]:e[1])),u.toValue(g.value?e[3]:e[2])]},([i,a,v,M])=>{if(d(),!(i!=null&&i.length)||!(a!=null&&a.length)||!(v!=null&&v.length))return;const c=be(M)?{...M}:M;s.push(...i.flatMap(S=>a.flatMap(b=>v.map(D=>m(S,b,D,c)))))},{flush:"post"}),p=()=>{w(),d()};return ie(d),p}function xe(){const e=u.shallowRef(!1),s=u.getCurrentInstance();return s&&u.onMounted(()=>{e.value=!0},s),e}function ae(e){const s=xe();return u.computed(()=>(s.value,!!e()))}const Ce=Symbol("vueuse-ssr-width");function Ee(){const e=u.hasInjectionContext()?ye(Ce,null):null;return typeof e=="number"?e:void 0}function We(e,s={}){const{window:d=B,ssrWidth:m=Ee()}=s,g=ae(()=>d&&"matchMedia"in d&&typeof d.matchMedia=="function"),w=u.shallowRef(typeof m=="number"),p=u.shallowRef(),i=u.shallowRef(!1),a=v=>{i.value=v.matches};return u.watchEffect(()=>{if(w.value){w.value=!g.value;const v=u.toValue(e).split(",");i.value=v.some(M=>{const c=M.includes("not all"),S=M.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),b=M.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);let D=!!(S||b);return S&&D&&(D=m>=se(S[1])),b&&D&&(D=m<=se(b[1])),c?!D:D});return}g.value&&(p.value=d.matchMedia(u.toValue(e)),i.value=p.value.matches)}),te(p,"change",a,{passive:!0}),u.computed(()=>i.value)}function _e(e,s,d={}){const{window:m=B,...g}=d;let w;const p=ae(()=>m&&"ResizeObserver"in m),i=()=>{w&&(w.disconnect(),w=void 0)},a=u.computed(()=>{const c=u.toValue(e);return Array.isArray(c)?c.map(S=>A(S)):[A(c)]}),v=u.watch(a,c=>{if(i(),p.value&&m){w=new ResizeObserver(s);for(const S of c)S&&w.observe(S,g)}},{immediate:!0,flush:"post"}),M=()=>{i(),v()};return ie(M),{isSupported:p,stop:M}}function je(e,s={width:0,height:0},d={}){const{window:m=B,box:g="content-box"}=d,w=u.computed(()=>{var c,S;return(S=(c=A(e))==null?void 0:c.namespaceURI)==null?void 0:S.includes("svg")}),p=u.shallowRef(s.width),i=u.shallowRef(s.height),{stop:a}=_e(e,([c])=>{const S=g==="border-box"?c.borderBoxSize:g==="content-box"?c.contentBoxSize:c.devicePixelContentBoxSize;if(m&&w.value){const b=A(e);if(b){const D=b.getBoundingClientRect();p.value=D.width,i.value=D.height}}else if(S){const b=Z(S);p.value=b.reduce((D,{inlineSize:T})=>D+T,0),i.value=b.reduce((D,{blockSize:T})=>D+T,0)}else p.value=c.contentRect.width,i.value=c.contentRect.height},d);ue(()=>{const c=A(e);c&&(p.value="offsetWidth"in c?c.offsetWidth:s.width,i.value="offsetHeight"in c?c.offsetHeight:s.height)});const v=u.watch(()=>A(e),c=>{p.value=c?s.width:0,i.value=c?s.height:0});function M(){a(),v()}return{width:p,height:i,stop:M}}function ke(e={}){const{window:s=B,initialWidth:d=Number.POSITIVE_INFINITY,initialHeight:m=Number.POSITIVE_INFINITY,listenOrientation:g=!0,includeScrollbar:w=!0,type:p="inner"}=e,i=u.shallowRef(d),a=u.shallowRef(m),v=()=>{if(s)if(p==="outer")i.value=s.outerWidth,a.value=s.outerHeight;else if(p==="visual"&&s.visualViewport){const{width:c,height:S,scale:b}=s.visualViewport;i.value=Math.round(c*b),a.value=Math.round(S*b)}else w?(i.value=s.innerWidth,a.value=s.innerHeight):(i.value=s.document.documentElement.clientWidth,a.value=s.document.documentElement.clientHeight)};v(),ue(v);const M={passive:!0};if(te("resize",v,M),s&&p==="visual"&&s.visualViewport&&te(s.visualViewport,"resize",v,M),g){const c=We("(orientation: portrait)");u.watch(c,()=>v())}return{width:i,height:a}}function He(e,s){if(!e)throw new Error("tableRef are required");const d=u.computed(()=>{var a;return(a=e.value)==null?void 0:a.searchRef}),{height:m}=ke(),{height:g}=je(d),{height:w=0,minHeight:p=600}=s||{};return{height:u.computed(()=>{const a=m.value-g.value-w;return a>p?a:p})}}function Ie(e,s){const{immediate:d=!0}=s||{},m=u.ref(null),g=u.ref(!1),w=u.ref(null),p=async()=>{g.value=!0,w.value=null;try{const i=await e();m.value=i}catch(i){w.value=i}finally{g.value=!1}};return d&&p(),{data:m,loading:g,error:w,fetchData:p}}exports.useAsyncData=Ie;exports.useExportFile=oe;exports.useList=$e;exports.useTableHeight=He;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import { inject as de, ref as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { inject as de, ref as Y, computed as A, onMounted as oe, nextTick as pe, getCurrentInstance as ue, watch as te, getCurrentScope as ge, onScopeDispose as we, hasInjectionContext as fe, shallowRef as T, toValue as P, watchEffect as $e, unref as ye } from "vue";
|
|
2
|
+
function Me(e) {
|
|
3
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
4
|
}
|
|
5
|
-
var X = { exports: {} },
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
(function(l,
|
|
9
|
-
|
|
10
|
-
})(
|
|
11
|
-
var l = 1e3,
|
|
12
|
-
var r = ["th", "st", "nd", "rd"],
|
|
13
|
-
return "[" +
|
|
14
|
-
} },
|
|
15
|
-
var i = String(
|
|
16
|
-
return !i || i.length >= r ?
|
|
17
|
-
},
|
|
18
|
-
var r = -
|
|
19
|
-
return (r <= 0 ? "+" : "-") +
|
|
20
|
-
}, m: function
|
|
21
|
-
if (r.date() <
|
|
22
|
-
var i = 12 * (
|
|
23
|
-
return +(-(i + (
|
|
24
|
-
}, a: function(
|
|
25
|
-
return
|
|
26
|
-
}, p: function(
|
|
27
|
-
return { M:
|
|
28
|
-
}, u: function(
|
|
29
|
-
return
|
|
30
|
-
} }, j = "en",
|
|
31
|
-
|
|
32
|
-
var Q = "$isDayjsObject",
|
|
33
|
-
return
|
|
34
|
-
}, F = function
|
|
5
|
+
var X = { exports: {} }, Se = X.exports, ce;
|
|
6
|
+
function be() {
|
|
7
|
+
return ce || (ce = 1, function(e, s) {
|
|
8
|
+
(function(l, v) {
|
|
9
|
+
e.exports = v();
|
|
10
|
+
})(Se, function() {
|
|
11
|
+
var l = 1e3, v = 6e4, p = 36e5, g = "millisecond", m = "second", o = "minute", u = "hour", h = "day", y = "week", a = "month", M = "quarter", S = "year", b = "date", z = "Invalid Date", ne = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, re = /\[([^\]]+)]|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, D = { 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(c) {
|
|
12
|
+
var r = ["th", "st", "nd", "rd"], t = c % 100;
|
|
13
|
+
return "[" + c + (r[(t - 20) % 10] || r[t] || r[0]) + "]";
|
|
14
|
+
} }, C = function(c, r, t) {
|
|
15
|
+
var i = String(c);
|
|
16
|
+
return !i || i.length >= r ? c : "" + Array(r + 1 - i.length).join(t) + c;
|
|
17
|
+
}, I = { s: C, z: function(c) {
|
|
18
|
+
var r = -c.utcOffset(), t = Math.abs(r), i = Math.floor(t / 60), n = t % 60;
|
|
19
|
+
return (r <= 0 ? "+" : "-") + C(i, 2, "0") + ":" + C(n, 2, "0");
|
|
20
|
+
}, m: function c(r, t) {
|
|
21
|
+
if (r.date() < t.date()) return -c(t, r);
|
|
22
|
+
var i = 12 * (t.year() - r.year()) + (t.month() - r.month()), n = r.clone().add(i, a), d = t - n < 0, f = r.clone().add(i + (d ? -1 : 1), a);
|
|
23
|
+
return +(-(i + (t - n) / (d ? n - f : f - n)) || 0);
|
|
24
|
+
}, a: function(c) {
|
|
25
|
+
return c < 0 ? Math.ceil(c) || 0 : Math.floor(c);
|
|
26
|
+
}, p: function(c) {
|
|
27
|
+
return { M: a, y: S, w: y, d: h, D: b, h: u, m: o, s: m, ms: g, Q: M }[c] || String(c || "").toLowerCase().replace(/s$/, "");
|
|
28
|
+
}, u: function(c) {
|
|
29
|
+
return c === void 0;
|
|
30
|
+
} }, j = "en", H = {};
|
|
31
|
+
H[j] = D;
|
|
32
|
+
var Q = "$isDayjsObject", B = function(c) {
|
|
33
|
+
return c instanceof Z || !(!c || !c[Q]);
|
|
34
|
+
}, F = function c(r, t, i) {
|
|
35
35
|
var n;
|
|
36
36
|
if (!r) return j;
|
|
37
37
|
if (typeof r == "string") {
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
if (!n &&
|
|
38
|
+
var d = r.toLowerCase();
|
|
39
|
+
H[d] && (n = d), t && (H[d] = t, n = d);
|
|
40
|
+
var f = r.split("-");
|
|
41
|
+
if (!n && f.length > 1) return c(f[0]);
|
|
42
42
|
} else {
|
|
43
|
-
var
|
|
44
|
-
|
|
43
|
+
var $ = r.name;
|
|
44
|
+
H[$] = r, n = $;
|
|
45
45
|
}
|
|
46
46
|
return !i && n && (j = n), n || !i && j;
|
|
47
|
-
}, x = function(
|
|
48
|
-
if (
|
|
49
|
-
var
|
|
50
|
-
return
|
|
51
|
-
}, w =
|
|
52
|
-
w.l = F, w.i =
|
|
53
|
-
return x(
|
|
47
|
+
}, x = function(c, r) {
|
|
48
|
+
if (B(c)) return c.clone();
|
|
49
|
+
var t = typeof r == "object" ? r : {};
|
|
50
|
+
return t.date = c, t.args = arguments, new Z(t);
|
|
51
|
+
}, w = I;
|
|
52
|
+
w.l = F, w.i = B, w.w = function(c, r) {
|
|
53
|
+
return x(c, { locale: r.$L, utc: r.$u, x: r.$x, $offset: r.$offset });
|
|
54
54
|
};
|
|
55
55
|
var Z = function() {
|
|
56
|
-
function
|
|
57
|
-
this.$L = F(
|
|
56
|
+
function c(t) {
|
|
57
|
+
this.$L = F(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[Q] = !0;
|
|
58
58
|
}
|
|
59
|
-
var r =
|
|
60
|
-
return r.parse = function(
|
|
59
|
+
var r = c.prototype;
|
|
60
|
+
return r.parse = function(t) {
|
|
61
61
|
this.$d = function(i) {
|
|
62
|
-
var n = i.date,
|
|
62
|
+
var n = i.date, d = i.utc;
|
|
63
63
|
if (n === null) return /* @__PURE__ */ new Date(NaN);
|
|
64
64
|
if (w.u(n)) return /* @__PURE__ */ new Date();
|
|
65
65
|
if (n instanceof Date) return new Date(n);
|
|
66
66
|
if (typeof n == "string" && !/Z$/i.test(n)) {
|
|
67
|
-
var
|
|
68
|
-
if (
|
|
69
|
-
var
|
|
70
|
-
return
|
|
67
|
+
var f = n.match(ne);
|
|
68
|
+
if (f) {
|
|
69
|
+
var $ = f[2] - 1 || 0, O = (f[7] || "0").substring(0, 3);
|
|
70
|
+
return d ? new Date(Date.UTC(f[1], $, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, O)) : new Date(f[1], $, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, O);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
return new Date(n);
|
|
74
|
-
}(
|
|
74
|
+
}(t), this.init();
|
|
75
75
|
}, r.init = function() {
|
|
76
|
-
var
|
|
77
|
-
this.$y =
|
|
76
|
+
var t = this.$d;
|
|
77
|
+
this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
|
|
78
78
|
}, r.$utils = function() {
|
|
79
79
|
return w;
|
|
80
80
|
}, r.isValid = function() {
|
|
81
|
-
return this.$d.toString() !==
|
|
82
|
-
}, r.isSame = function(
|
|
83
|
-
var n = x(
|
|
81
|
+
return this.$d.toString() !== z;
|
|
82
|
+
}, r.isSame = function(t, i) {
|
|
83
|
+
var n = x(t);
|
|
84
84
|
return this.startOf(i) <= n && n <= this.endOf(i);
|
|
85
|
-
}, r.isAfter = function(
|
|
86
|
-
return x(
|
|
87
|
-
}, r.isBefore = function(
|
|
88
|
-
return this.endOf(i) < x(
|
|
89
|
-
}, r.$g = function(
|
|
90
|
-
return w.u(
|
|
85
|
+
}, r.isAfter = function(t, i) {
|
|
86
|
+
return x(t) < this.startOf(i);
|
|
87
|
+
}, r.isBefore = function(t, i) {
|
|
88
|
+
return this.endOf(i) < x(t);
|
|
89
|
+
}, r.$g = function(t, i, n) {
|
|
90
|
+
return w.u(t) ? this[i] : this.set(n, t);
|
|
91
91
|
}, r.unix = function() {
|
|
92
92
|
return Math.floor(this.valueOf() / 1e3);
|
|
93
93
|
}, r.valueOf = function() {
|
|
94
94
|
return this.$d.getTime();
|
|
95
|
-
}, r.startOf = function(
|
|
96
|
-
var n = this,
|
|
97
|
-
var
|
|
98
|
-
return
|
|
99
|
-
}, O = function(N,
|
|
100
|
-
return w.w(n.toDate()[N].apply(n.toDate("s"), (
|
|
101
|
-
},
|
|
102
|
-
switch (
|
|
95
|
+
}, r.startOf = function(t, i) {
|
|
96
|
+
var n = this, d = !!w.u(i) || i, f = w.p(t), $ = function(N, _) {
|
|
97
|
+
var L = w.w(n.$u ? Date.UTC(n.$y, _, N) : new Date(n.$y, _, N), n);
|
|
98
|
+
return d ? L : L.endOf(h);
|
|
99
|
+
}, O = function(N, _) {
|
|
100
|
+
return w.w(n.toDate()[N].apply(n.toDate("s"), (d ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(_)), n);
|
|
101
|
+
}, W = this.$W, E = this.$M, k = this.$D, U = "set" + (this.$u ? "UTC" : "");
|
|
102
|
+
switch (f) {
|
|
103
|
+
case S:
|
|
104
|
+
return d ? $(1, 0) : $(31, 11);
|
|
105
|
+
case a:
|
|
106
|
+
return d ? $(1, E) : $(0, E + 1);
|
|
107
|
+
case y:
|
|
108
|
+
var R = this.$locale().weekStart || 0, K = (W < R ? W + 7 : W) - R;
|
|
109
|
+
return $(d ? k - K : k + (6 - K), E);
|
|
110
|
+
case h:
|
|
103
111
|
case b:
|
|
104
|
-
return
|
|
112
|
+
return O(U + "Hours", 0);
|
|
113
|
+
case u:
|
|
114
|
+
return O(U + "Minutes", 1);
|
|
105
115
|
case o:
|
|
106
|
-
return
|
|
107
|
-
case M:
|
|
108
|
-
var R = this.$locale().weekStart || 0, B = (_ < R ? _ + 7 : _) - R;
|
|
109
|
-
return y(u ? k - B : k + (6 - B), E);
|
|
116
|
+
return O(U + "Seconds", 2);
|
|
110
117
|
case m:
|
|
111
|
-
|
|
112
|
-
return O(P + "Hours", 0);
|
|
113
|
-
case h:
|
|
114
|
-
return O(P + "Minutes", 1);
|
|
115
|
-
case v:
|
|
116
|
-
return O(P + "Seconds", 2);
|
|
117
|
-
case d:
|
|
118
|
-
return O(P + "Milliseconds", 3);
|
|
118
|
+
return O(U + "Milliseconds", 3);
|
|
119
119
|
default:
|
|
120
120
|
return this.clone();
|
|
121
121
|
}
|
|
122
|
-
}, r.endOf = function(
|
|
123
|
-
return this.startOf(
|
|
124
|
-
}, r.$set = function(
|
|
125
|
-
var n,
|
|
126
|
-
if (
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
} else
|
|
122
|
+
}, r.endOf = function(t) {
|
|
123
|
+
return this.startOf(t, !1);
|
|
124
|
+
}, r.$set = function(t, i) {
|
|
125
|
+
var n, d = w.p(t), f = "set" + (this.$u ? "UTC" : ""), $ = (n = {}, n[h] = f + "Date", n[b] = f + "Date", n[a] = f + "Month", n[S] = f + "FullYear", n[u] = f + "Hours", n[o] = f + "Minutes", n[m] = f + "Seconds", n[g] = f + "Milliseconds", n)[d], O = d === h ? this.$D + (i - this.$W) : i;
|
|
126
|
+
if (d === a || d === S) {
|
|
127
|
+
var W = this.clone().set(b, 1);
|
|
128
|
+
W.$d[$](O), W.init(), this.$d = W.set(b, Math.min(this.$D, W.daysInMonth())).$d;
|
|
129
|
+
} else $ && this.$d[$](O);
|
|
130
130
|
return this.init(), this;
|
|
131
|
-
}, r.set = function(
|
|
132
|
-
return this.clone().$set(
|
|
133
|
-
}, r.get = function(
|
|
134
|
-
return this[w.p(
|
|
135
|
-
}, r.add = function(
|
|
136
|
-
var n,
|
|
137
|
-
|
|
138
|
-
var
|
|
139
|
-
var k = x(
|
|
140
|
-
return w.w(k.date(k.date() + Math.round(E *
|
|
131
|
+
}, r.set = function(t, i) {
|
|
132
|
+
return this.clone().$set(t, i);
|
|
133
|
+
}, r.get = function(t) {
|
|
134
|
+
return this[w.p(t)]();
|
|
135
|
+
}, r.add = function(t, i) {
|
|
136
|
+
var n, d = this;
|
|
137
|
+
t = Number(t);
|
|
138
|
+
var f = w.p(i), $ = function(E) {
|
|
139
|
+
var k = x(d);
|
|
140
|
+
return w.w(k.date(k.date() + Math.round(E * t)), d);
|
|
141
141
|
};
|
|
142
|
-
if (
|
|
143
|
-
if (
|
|
144
|
-
if (
|
|
145
|
-
if (
|
|
146
|
-
var O = (n = {}, n[
|
|
147
|
-
return w.w(
|
|
148
|
-
}, r.subtract = function(
|
|
149
|
-
return this.add(-1 *
|
|
150
|
-
}, r.format = function(
|
|
142
|
+
if (f === a) return this.set(a, this.$M + t);
|
|
143
|
+
if (f === S) return this.set(S, this.$y + t);
|
|
144
|
+
if (f === h) return $(1);
|
|
145
|
+
if (f === y) return $(7);
|
|
146
|
+
var O = (n = {}, n[o] = v, n[u] = p, n[m] = l, n)[f] || 1, W = this.$d.getTime() + t * O;
|
|
147
|
+
return w.w(W, this);
|
|
148
|
+
}, r.subtract = function(t, i) {
|
|
149
|
+
return this.add(-1 * t, i);
|
|
150
|
+
}, r.format = function(t) {
|
|
151
151
|
var i = this, n = this.$locale();
|
|
152
|
-
if (!this.isValid()) return n.invalidDate ||
|
|
153
|
-
var
|
|
154
|
-
return
|
|
155
|
-
},
|
|
156
|
-
return w.s(
|
|
157
|
-
}, N =
|
|
158
|
-
var G =
|
|
159
|
-
return
|
|
152
|
+
if (!this.isValid()) return n.invalidDate || z;
|
|
153
|
+
var d = t || "YYYY-MM-DDTHH:mm:ssZ", f = w.z(this), $ = this.$H, O = this.$m, W = this.$M, E = n.weekdays, k = n.months, U = n.meridiem, R = function(_, L, q, G) {
|
|
154
|
+
return _ && (_[L] || _(i, d)) || q[L].slice(0, G);
|
|
155
|
+
}, K = function(_) {
|
|
156
|
+
return w.s($ % 12 || 12, _, "0");
|
|
157
|
+
}, N = U || function(_, L, q) {
|
|
158
|
+
var G = _ < 12 ? "AM" : "PM";
|
|
159
|
+
return q ? G.toLowerCase() : G;
|
|
160
160
|
};
|
|
161
|
-
return
|
|
162
|
-
return
|
|
163
|
-
switch (
|
|
161
|
+
return d.replace(re, function(_, L) {
|
|
162
|
+
return L || function(q) {
|
|
163
|
+
switch (q) {
|
|
164
164
|
case "YY":
|
|
165
165
|
return String(i.$y).slice(-2);
|
|
166
166
|
case "YYYY":
|
|
167
167
|
return w.s(i.$y, 4, "0");
|
|
168
168
|
case "M":
|
|
169
|
-
return
|
|
169
|
+
return W + 1;
|
|
170
170
|
case "MM":
|
|
171
|
-
return w.s(
|
|
171
|
+
return w.s(W + 1, 2, "0");
|
|
172
172
|
case "MMM":
|
|
173
|
-
return R(n.monthsShort,
|
|
173
|
+
return R(n.monthsShort, W, k, 3);
|
|
174
174
|
case "MMMM":
|
|
175
|
-
return R(k,
|
|
175
|
+
return R(k, W);
|
|
176
176
|
case "D":
|
|
177
177
|
return i.$D;
|
|
178
178
|
case "DD":
|
|
@@ -186,17 +186,17 @@ function Me() {
|
|
|
186
186
|
case "dddd":
|
|
187
187
|
return E[i.$W];
|
|
188
188
|
case "H":
|
|
189
|
-
return String(
|
|
189
|
+
return String($);
|
|
190
190
|
case "HH":
|
|
191
|
-
return w.s(
|
|
191
|
+
return w.s($, 2, "0");
|
|
192
192
|
case "h":
|
|
193
|
-
return
|
|
193
|
+
return K(1);
|
|
194
194
|
case "hh":
|
|
195
|
-
return
|
|
195
|
+
return K(2);
|
|
196
196
|
case "a":
|
|
197
|
-
return N(
|
|
197
|
+
return N($, O, !0);
|
|
198
198
|
case "A":
|
|
199
|
-
return N(
|
|
199
|
+
return N($, O, !1);
|
|
200
200
|
case "m":
|
|
201
201
|
return String(O);
|
|
202
202
|
case "mm":
|
|
@@ -208,54 +208,54 @@ function Me() {
|
|
|
208
208
|
case "SSS":
|
|
209
209
|
return w.s(i.$ms, 3, "0");
|
|
210
210
|
case "Z":
|
|
211
|
-
return
|
|
211
|
+
return f;
|
|
212
212
|
}
|
|
213
213
|
return null;
|
|
214
|
-
}(
|
|
214
|
+
}(_) || f.replace(":", "");
|
|
215
215
|
});
|
|
216
216
|
}, r.utcOffset = function() {
|
|
217
217
|
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
218
|
-
}, r.diff = function(
|
|
219
|
-
var
|
|
220
|
-
return w.m(
|
|
218
|
+
}, r.diff = function(t, i, n) {
|
|
219
|
+
var d, f = this, $ = w.p(i), O = x(t), W = (O.utcOffset() - this.utcOffset()) * v, E = this - O, k = function() {
|
|
220
|
+
return w.m(f, O);
|
|
221
221
|
};
|
|
222
|
-
switch (
|
|
223
|
-
case
|
|
224
|
-
|
|
222
|
+
switch ($) {
|
|
223
|
+
case S:
|
|
224
|
+
d = k() / 12;
|
|
225
225
|
break;
|
|
226
|
-
case
|
|
227
|
-
|
|
228
|
-
break;
|
|
229
|
-
case p:
|
|
230
|
-
u = k() / 3;
|
|
226
|
+
case a:
|
|
227
|
+
d = k();
|
|
231
228
|
break;
|
|
232
229
|
case M:
|
|
233
|
-
|
|
230
|
+
d = k() / 3;
|
|
234
231
|
break;
|
|
235
|
-
case
|
|
236
|
-
|
|
232
|
+
case y:
|
|
233
|
+
d = (E - W) / 6048e5;
|
|
237
234
|
break;
|
|
238
235
|
case h:
|
|
239
|
-
|
|
236
|
+
d = (E - W) / 864e5;
|
|
240
237
|
break;
|
|
241
|
-
case
|
|
242
|
-
|
|
238
|
+
case u:
|
|
239
|
+
d = E / p;
|
|
243
240
|
break;
|
|
244
|
-
case
|
|
245
|
-
|
|
241
|
+
case o:
|
|
242
|
+
d = E / v;
|
|
243
|
+
break;
|
|
244
|
+
case m:
|
|
245
|
+
d = E / l;
|
|
246
246
|
break;
|
|
247
247
|
default:
|
|
248
|
-
|
|
248
|
+
d = E;
|
|
249
249
|
}
|
|
250
|
-
return n ?
|
|
250
|
+
return n ? d : w.a(d);
|
|
251
251
|
}, r.daysInMonth = function() {
|
|
252
|
-
return this.endOf(
|
|
252
|
+
return this.endOf(a).$D;
|
|
253
253
|
}, r.$locale = function() {
|
|
254
|
-
return
|
|
255
|
-
}, r.locale = function(
|
|
256
|
-
if (!
|
|
257
|
-
var n = this.clone(),
|
|
258
|
-
return
|
|
254
|
+
return H[this.$L];
|
|
255
|
+
}, r.locale = function(t, i) {
|
|
256
|
+
if (!t) return this.$L;
|
|
257
|
+
var n = this.clone(), d = F(t, i, !0);
|
|
258
|
+
return d && (n.$L = d), n;
|
|
259
259
|
}, r.clone = function() {
|
|
260
260
|
return w.w(this.$d, this);
|
|
261
261
|
}, r.toDate = function() {
|
|
@@ -266,321 +266,358 @@ function Me() {
|
|
|
266
266
|
return this.$d.toISOString();
|
|
267
267
|
}, r.toString = function() {
|
|
268
268
|
return this.$d.toUTCString();
|
|
269
|
-
},
|
|
269
|
+
}, c;
|
|
270
270
|
}(), ae = Z.prototype;
|
|
271
|
-
return x.prototype = ae, [["$ms",
|
|
272
|
-
ae[
|
|
273
|
-
return this.$g(r,
|
|
271
|
+
return x.prototype = ae, [["$ms", g], ["$s", m], ["$m", o], ["$H", u], ["$W", h], ["$M", a], ["$y", S], ["$D", b]].forEach(function(c) {
|
|
272
|
+
ae[c[1]] = function(r) {
|
|
273
|
+
return this.$g(r, c[0], c[1]);
|
|
274
274
|
};
|
|
275
|
-
}), x.extend = function(
|
|
276
|
-
return
|
|
277
|
-
}, x.locale = F, x.isDayjs =
|
|
278
|
-
return x(1e3 *
|
|
279
|
-
}, x.en =
|
|
275
|
+
}), x.extend = function(c, r) {
|
|
276
|
+
return c.$i || (c(r, Z, x), c.$i = !0), x;
|
|
277
|
+
}, x.locale = F, x.isDayjs = B, x.unix = function(c) {
|
|
278
|
+
return x(1e3 * c);
|
|
279
|
+
}, x.en = H[j], x.Ls = H, x.p = {}, x;
|
|
280
280
|
});
|
|
281
281
|
}(X)), X.exports;
|
|
282
282
|
}
|
|
283
|
-
var
|
|
284
|
-
const
|
|
285
|
-
function
|
|
286
|
-
const s = new Blob([
|
|
283
|
+
var De = be();
|
|
284
|
+
const Oe = /* @__PURE__ */ Me(De);
|
|
285
|
+
function xe(e) {
|
|
286
|
+
const s = new Blob([e], {
|
|
287
287
|
type: "application/vnd.ms-excel"
|
|
288
288
|
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
289
289
|
});
|
|
290
290
|
return window.URL.createObjectURL(s);
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function We() {
|
|
293
293
|
return document.createElement("a");
|
|
294
294
|
}
|
|
295
|
-
function
|
|
296
|
-
const l =
|
|
297
|
-
function
|
|
298
|
-
const
|
|
299
|
-
|
|
295
|
+
function Ee(e, s) {
|
|
296
|
+
const l = Oe().format("yyyy-MM-dd hh:mm:ss");
|
|
297
|
+
function v() {
|
|
298
|
+
const p = We(), g = xe(e);
|
|
299
|
+
p.href = g, s ? p.download = s || `${s}-${l}.xlsx` : p.download = `${l}.xlsx`, document.body.appendChild(p), p.click(), document.body.removeChild(p), window.URL.revokeObjectURL(g);
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
v();
|
|
302
302
|
}
|
|
303
|
-
function _e(
|
|
304
|
-
throw new Error(`[naive/${
|
|
303
|
+
function _e(e, s) {
|
|
304
|
+
throw new Error(`[naive/${e}]: ${s}`);
|
|
305
305
|
}
|
|
306
|
-
const
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
return
|
|
306
|
+
const Ce = "n-message-api";
|
|
307
|
+
function ke() {
|
|
308
|
+
const e = de(Ce, null);
|
|
309
|
+
return e === null && _e("use-message", "No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."), e;
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function Be(e, s = {}) {
|
|
312
312
|
const {
|
|
313
313
|
exportRequestFn: l,
|
|
314
|
-
filterOption:
|
|
315
|
-
callback:
|
|
316
|
-
immediate:
|
|
317
|
-
code:
|
|
318
|
-
} = s,
|
|
314
|
+
filterOption: v = Y(),
|
|
315
|
+
callback: p,
|
|
316
|
+
immediate: g = !0,
|
|
317
|
+
code: m = 200
|
|
318
|
+
} = s, o = Y(!1), u = Y({
|
|
319
319
|
page: 1,
|
|
320
320
|
pageSize: 10,
|
|
321
321
|
itemCount: 0,
|
|
322
322
|
showSizePicker: !0,
|
|
323
323
|
pageSizes: [10, 20, 30, 40],
|
|
324
324
|
showQuickJumper: !0,
|
|
325
|
-
prefix: (
|
|
326
|
-
}),
|
|
327
|
-
|
|
325
|
+
prefix: (D) => `共 ${D.itemCount} 条`
|
|
326
|
+
}), h = Y([]), y = A(() => v.value), a = async (D = u.value.page, C) => {
|
|
327
|
+
o.value = !0;
|
|
328
328
|
try {
|
|
329
|
-
const { status:
|
|
330
|
-
pageNum:
|
|
331
|
-
pageSize:
|
|
332
|
-
...
|
|
333
|
-
...
|
|
334
|
-
}), { list:
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
...
|
|
329
|
+
const { status: I, data: j } = await e({
|
|
330
|
+
pageNum: D,
|
|
331
|
+
pageSize: u.value.pageSize,
|
|
332
|
+
...y.value,
|
|
333
|
+
...C
|
|
334
|
+
}), { list: H, pageNum: Q, total: B, pageSize: F } = p && p(j) || j;
|
|
335
|
+
if (I === m && Array.isArray(H))
|
|
336
|
+
h.value = H, u.value = {
|
|
337
|
+
...u.value,
|
|
338
338
|
page: Q,
|
|
339
|
-
itemCount:
|
|
339
|
+
itemCount: B,
|
|
340
340
|
pageSize: F
|
|
341
341
|
};
|
|
342
342
|
else
|
|
343
|
-
throw
|
|
344
|
-
...
|
|
343
|
+
throw h.value = [], u.value = {
|
|
344
|
+
...u.value,
|
|
345
345
|
pageSize: 10,
|
|
346
346
|
itemCount: 0,
|
|
347
347
|
page: 1
|
|
348
348
|
}, new Error("list的数据类型错误");
|
|
349
|
-
} catch (
|
|
350
|
-
throw console.error("Error in loadData:",
|
|
349
|
+
} catch (I) {
|
|
350
|
+
throw console.error("Error in loadData:", I), I;
|
|
351
351
|
} finally {
|
|
352
|
-
|
|
352
|
+
o.value = !1;
|
|
353
353
|
}
|
|
354
|
-
},
|
|
354
|
+
}, M = ke(), S = async () => {
|
|
355
355
|
if (!l || typeof l != "function")
|
|
356
356
|
throw new Error("当前没有提供exportRequest函数");
|
|
357
357
|
try {
|
|
358
|
-
const { data:
|
|
359
|
-
|
|
360
|
-
} catch (
|
|
361
|
-
throw console.error("Error in handleExcelData:",
|
|
358
|
+
const { data: D, fileName: C } = await l(v.value);
|
|
359
|
+
Ee(D, C), M == null || M.success("成功导出");
|
|
360
|
+
} catch (D) {
|
|
361
|
+
throw console.error("Error in handleExcelData:", D), D;
|
|
362
362
|
}
|
|
363
|
-
},
|
|
364
|
-
|
|
365
|
-
},
|
|
366
|
-
D
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
},
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
|
|
363
|
+
}, b = (D, C) => {
|
|
364
|
+
C !== void 0 && (u.value.pageSize = C), a(D);
|
|
365
|
+
}, z = (D) => {
|
|
366
|
+
b(D);
|
|
367
|
+
}, ne = (D) => {
|
|
368
|
+
b(1, D);
|
|
369
|
+
}, re = (D) => {
|
|
370
|
+
if (D.sorter) {
|
|
371
|
+
const C = [...h.value].sort((I, j) => D.order === "ascend" ? I[D.columnKey] > j[D.columnKey] ? 1 : -1 : D.order === "descend" ? I[D.columnKey] < j[D.columnKey] ? 1 : -1 : 0);
|
|
372
|
+
h.value = C;
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
return
|
|
376
|
-
dataSource:
|
|
377
|
-
loading:
|
|
378
|
-
pagination:
|
|
379
|
-
handleExcelData:
|
|
380
|
-
handlePageChange:
|
|
381
|
-
handlePageSizeChange:
|
|
382
|
-
handleSortChange:
|
|
383
|
-
loadData:
|
|
375
|
+
return oe(() => g && a(u.value.page)), {
|
|
376
|
+
dataSource: h,
|
|
377
|
+
loading: o,
|
|
378
|
+
pagination: u,
|
|
379
|
+
handleExcelData: S,
|
|
380
|
+
handlePageChange: z,
|
|
381
|
+
handlePageSizeChange: ne,
|
|
382
|
+
handleSortChange: re,
|
|
383
|
+
loadData: a
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
|
-
function
|
|
387
|
-
return
|
|
386
|
+
function he(e) {
|
|
387
|
+
return ge() ? (we(e), !0) : !1;
|
|
388
388
|
}
|
|
389
|
-
const
|
|
389
|
+
const se = /* @__PURE__ */ new WeakMap(), je = (...e) => {
|
|
390
390
|
var s;
|
|
391
|
-
const l =
|
|
392
|
-
if (
|
|
391
|
+
const l = e[0], v = (s = ue()) == null ? void 0 : s.proxy;
|
|
392
|
+
if (v == null && !fe())
|
|
393
393
|
throw new Error("injectLocal must be called in setup");
|
|
394
|
-
return
|
|
395
|
-
},
|
|
394
|
+
return v && se.has(v) && l in se.get(v) ? se.get(v)[l] : de(...e);
|
|
395
|
+
}, He = typeof window < "u" && typeof document < "u";
|
|
396
396
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
397
|
+
const Ie = Object.prototype.toString, ze = (e) => Ie.call(e) === "[object Object]";
|
|
398
|
+
function le(e) {
|
|
399
|
+
return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
|
|
400
|
+
}
|
|
401
|
+
function ee(e) {
|
|
402
|
+
return Array.isArray(e) ? e : [e];
|
|
401
403
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
404
|
+
function Le(e) {
|
|
405
|
+
return ue();
|
|
404
406
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
+
function ve(e, s = !0, l) {
|
|
408
|
+
Le() ? oe(e, l) : s ? e() : pe(e);
|
|
407
409
|
}
|
|
408
|
-
function
|
|
409
|
-
|
|
410
|
+
function Te(e, s, l) {
|
|
411
|
+
return te(
|
|
412
|
+
e,
|
|
413
|
+
s,
|
|
414
|
+
{
|
|
415
|
+
...l,
|
|
416
|
+
immediate: !0
|
|
417
|
+
}
|
|
418
|
+
);
|
|
410
419
|
}
|
|
411
|
-
const J =
|
|
412
|
-
function
|
|
420
|
+
const J = He ? window : void 0;
|
|
421
|
+
function V(e) {
|
|
413
422
|
var s;
|
|
414
|
-
const l =
|
|
423
|
+
const l = P(e);
|
|
415
424
|
return (s = l == null ? void 0 : l.$el) != null ? s : l;
|
|
416
425
|
}
|
|
417
|
-
function
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
426
|
+
function ie(...e) {
|
|
427
|
+
const s = [], l = () => {
|
|
428
|
+
s.forEach((o) => o()), s.length = 0;
|
|
429
|
+
}, v = (o, u, h, y) => (o.addEventListener(u, h, y), () => o.removeEventListener(u, h, y)), p = A(() => {
|
|
430
|
+
const o = ee(P(e[0])).filter((u) => u != null);
|
|
431
|
+
return o.every((u) => typeof u != "string") ? o : void 0;
|
|
432
|
+
}), g = Te(
|
|
433
|
+
() => {
|
|
434
|
+
var o, u;
|
|
435
|
+
return [
|
|
436
|
+
(u = (o = p.value) == null ? void 0 : o.map((h) => V(h))) != null ? u : [J].filter((h) => h != null),
|
|
437
|
+
ee(P(p.value ? e[1] : e[0])),
|
|
438
|
+
ee(ye(p.value ? e[2] : e[1])),
|
|
439
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
440
|
+
P(p.value ? e[3] : e[2])
|
|
441
|
+
];
|
|
442
|
+
},
|
|
443
|
+
([o, u, h, y]) => {
|
|
444
|
+
if (l(), !(o != null && o.length) || !(u != null && u.length) || !(h != null && h.length))
|
|
428
445
|
return;
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
...
|
|
446
|
+
const a = ze(y) ? { ...y } : y;
|
|
447
|
+
s.push(
|
|
448
|
+
...o.flatMap(
|
|
449
|
+
(M) => u.flatMap(
|
|
450
|
+
(S) => h.map((b) => v(M, S, b, a))
|
|
451
|
+
)
|
|
452
|
+
)
|
|
432
453
|
);
|
|
433
454
|
},
|
|
434
|
-
{
|
|
455
|
+
{ flush: "post" }
|
|
435
456
|
), m = () => {
|
|
436
|
-
|
|
457
|
+
g(), l();
|
|
437
458
|
};
|
|
438
|
-
return
|
|
459
|
+
return he(l), m;
|
|
439
460
|
}
|
|
440
|
-
function
|
|
441
|
-
const
|
|
442
|
-
return s &&
|
|
443
|
-
|
|
444
|
-
}, s),
|
|
461
|
+
function Ae() {
|
|
462
|
+
const e = T(!1), s = ue();
|
|
463
|
+
return s && oe(() => {
|
|
464
|
+
e.value = !0;
|
|
465
|
+
}, s), e;
|
|
445
466
|
}
|
|
446
|
-
function
|
|
447
|
-
const s =
|
|
448
|
-
return
|
|
467
|
+
function me(e) {
|
|
468
|
+
const s = Ae();
|
|
469
|
+
return A(() => (s.value, !!e()));
|
|
449
470
|
}
|
|
450
|
-
const
|
|
451
|
-
function
|
|
452
|
-
const
|
|
453
|
-
return typeof
|
|
471
|
+
const Re = Symbol("vueuse-ssr-width");
|
|
472
|
+
function Ne() {
|
|
473
|
+
const e = fe() ? je(Re, null) : null;
|
|
474
|
+
return typeof e == "number" ? e : void 0;
|
|
454
475
|
}
|
|
455
|
-
function
|
|
456
|
-
const { window: l = J, ssrWidth:
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
const b = p.includes("not all"), D = p.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), C = p.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
468
|
-
let I = !!(D || C);
|
|
469
|
-
return D && I && (I = f >= ce(D[1])), C && I && (I = f <= ce(C[1])), b ? !I : I;
|
|
476
|
+
function Ye(e, s = {}) {
|
|
477
|
+
const { window: l = J, ssrWidth: v = Ne() } = s, p = me(() => l && "matchMedia" in l && typeof l.matchMedia == "function"), g = T(typeof v == "number"), m = T(), o = T(!1), u = (h) => {
|
|
478
|
+
o.value = h.matches;
|
|
479
|
+
};
|
|
480
|
+
return $e(() => {
|
|
481
|
+
if (g.value) {
|
|
482
|
+
g.value = !p.value;
|
|
483
|
+
const h = P(e).split(",");
|
|
484
|
+
o.value = h.some((y) => {
|
|
485
|
+
const a = y.includes("not all"), M = y.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), S = y.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
486
|
+
let b = !!(M || S);
|
|
487
|
+
return M && b && (b = v >= le(M[1])), S && b && (b = v <= le(S[1])), a ? !b : b;
|
|
470
488
|
});
|
|
471
489
|
return;
|
|
472
490
|
}
|
|
473
|
-
|
|
474
|
-
});
|
|
475
|
-
return oe(() => {
|
|
476
|
-
M(), m(), d = void 0;
|
|
477
|
-
}), V(() => v.value);
|
|
491
|
+
p.value && (m.value = l.matchMedia(P(e)), o.value = m.value.matches);
|
|
492
|
+
}), ie(m, "change", u, { passive: !0 }), A(() => o.value);
|
|
478
493
|
}
|
|
479
|
-
function
|
|
480
|
-
const { window:
|
|
481
|
-
let
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
},
|
|
485
|
-
const
|
|
486
|
-
return Array.isArray(
|
|
487
|
-
}),
|
|
488
|
-
|
|
489
|
-
(
|
|
490
|
-
if (
|
|
491
|
-
|
|
492
|
-
for (const
|
|
493
|
-
|
|
494
|
+
function Ve(e, s, l = {}) {
|
|
495
|
+
const { window: v = J, ...p } = l;
|
|
496
|
+
let g;
|
|
497
|
+
const m = me(() => v && "ResizeObserver" in v), o = () => {
|
|
498
|
+
g && (g.disconnect(), g = void 0);
|
|
499
|
+
}, u = A(() => {
|
|
500
|
+
const a = P(e);
|
|
501
|
+
return Array.isArray(a) ? a.map((M) => V(M)) : [V(a)];
|
|
502
|
+
}), h = te(
|
|
503
|
+
u,
|
|
504
|
+
(a) => {
|
|
505
|
+
if (o(), m.value && v) {
|
|
506
|
+
g = new ResizeObserver(s);
|
|
507
|
+
for (const M of a)
|
|
508
|
+
M && g.observe(M, p);
|
|
494
509
|
}
|
|
495
510
|
},
|
|
496
511
|
{ immediate: !0, flush: "post" }
|
|
497
|
-
),
|
|
498
|
-
|
|
512
|
+
), y = () => {
|
|
513
|
+
o(), h();
|
|
499
514
|
};
|
|
500
|
-
return
|
|
501
|
-
isSupported:
|
|
502
|
-
stop:
|
|
515
|
+
return he(y), {
|
|
516
|
+
isSupported: m,
|
|
517
|
+
stop: y
|
|
503
518
|
};
|
|
504
519
|
}
|
|
505
|
-
function
|
|
506
|
-
const { window:
|
|
507
|
-
var
|
|
508
|
-
return (
|
|
509
|
-
}),
|
|
510
|
-
|
|
511
|
-
([
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
const
|
|
515
|
-
if (
|
|
516
|
-
const
|
|
517
|
-
|
|
520
|
+
function Pe(e, s = { width: 0, height: 0 }, l = {}) {
|
|
521
|
+
const { window: v = J, box: p = "content-box" } = l, g = A(() => {
|
|
522
|
+
var a, M;
|
|
523
|
+
return (M = (a = V(e)) == null ? void 0 : a.namespaceURI) == null ? void 0 : M.includes("svg");
|
|
524
|
+
}), m = T(s.width), o = T(s.height), { stop: u } = Ve(
|
|
525
|
+
e,
|
|
526
|
+
([a]) => {
|
|
527
|
+
const M = p === "border-box" ? a.borderBoxSize : p === "content-box" ? a.contentBoxSize : a.devicePixelContentBoxSize;
|
|
528
|
+
if (v && g.value) {
|
|
529
|
+
const S = V(e);
|
|
530
|
+
if (S) {
|
|
531
|
+
const b = S.getBoundingClientRect();
|
|
532
|
+
m.value = b.width, o.value = b.height;
|
|
518
533
|
}
|
|
519
|
-
} else if (
|
|
520
|
-
const
|
|
521
|
-
|
|
534
|
+
} else if (M) {
|
|
535
|
+
const S = ee(M);
|
|
536
|
+
m.value = S.reduce((b, { inlineSize: z }) => b + z, 0), o.value = S.reduce((b, { blockSize: z }) => b + z, 0);
|
|
522
537
|
} else
|
|
523
|
-
|
|
538
|
+
m.value = a.contentRect.width, o.value = a.contentRect.height;
|
|
524
539
|
},
|
|
525
540
|
l
|
|
526
541
|
);
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
|
|
542
|
+
ve(() => {
|
|
543
|
+
const a = V(e);
|
|
544
|
+
a && (m.value = "offsetWidth" in a ? a.offsetWidth : s.width, o.value = "offsetHeight" in a ? a.offsetHeight : s.height);
|
|
530
545
|
});
|
|
531
|
-
const
|
|
532
|
-
() =>
|
|
533
|
-
(
|
|
534
|
-
|
|
546
|
+
const h = te(
|
|
547
|
+
() => V(e),
|
|
548
|
+
(a) => {
|
|
549
|
+
m.value = a ? s.width : 0, o.value = a ? s.height : 0;
|
|
535
550
|
}
|
|
536
551
|
);
|
|
537
|
-
function
|
|
538
|
-
|
|
552
|
+
function y() {
|
|
553
|
+
u(), h();
|
|
539
554
|
}
|
|
540
555
|
return {
|
|
541
|
-
width:
|
|
542
|
-
height:
|
|
543
|
-
stop:
|
|
556
|
+
width: m,
|
|
557
|
+
height: o,
|
|
558
|
+
stop: y
|
|
544
559
|
};
|
|
545
560
|
}
|
|
546
|
-
function
|
|
561
|
+
function Fe(e = {}) {
|
|
547
562
|
const {
|
|
548
563
|
window: s = J,
|
|
549
564
|
initialWidth: l = Number.POSITIVE_INFINITY,
|
|
550
|
-
initialHeight:
|
|
551
|
-
listenOrientation:
|
|
552
|
-
includeScrollbar:
|
|
553
|
-
type:
|
|
554
|
-
} =
|
|
565
|
+
initialHeight: v = Number.POSITIVE_INFINITY,
|
|
566
|
+
listenOrientation: p = !0,
|
|
567
|
+
includeScrollbar: g = !0,
|
|
568
|
+
type: m = "inner"
|
|
569
|
+
} = e, o = T(l), u = T(v), h = () => {
|
|
555
570
|
if (s)
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
else if (
|
|
559
|
-
const { width:
|
|
560
|
-
|
|
561
|
-
} else
|
|
571
|
+
if (m === "outer")
|
|
572
|
+
o.value = s.outerWidth, u.value = s.outerHeight;
|
|
573
|
+
else if (m === "visual" && s.visualViewport) {
|
|
574
|
+
const { width: a, height: M, scale: S } = s.visualViewport;
|
|
575
|
+
o.value = Math.round(a * S), u.value = Math.round(M * S);
|
|
576
|
+
} else g ? (o.value = s.innerWidth, u.value = s.innerHeight) : (o.value = s.document.documentElement.clientWidth, u.value = s.document.documentElement.clientHeight);
|
|
562
577
|
};
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
578
|
+
h(), ve(h);
|
|
579
|
+
const y = { passive: !0 };
|
|
580
|
+
if (ie("resize", h, y), s && m === "visual" && s.visualViewport && ie(s.visualViewport, "resize", h, y), p) {
|
|
581
|
+
const a = Ye("(orientation: portrait)");
|
|
582
|
+
te(a, () => h());
|
|
566
583
|
}
|
|
567
|
-
return { width:
|
|
584
|
+
return { width: o, height: u };
|
|
568
585
|
}
|
|
569
|
-
function
|
|
570
|
-
if (!
|
|
571
|
-
const l =
|
|
572
|
-
var
|
|
573
|
-
return (
|
|
574
|
-
}), { height:
|
|
586
|
+
function Ke(e, s) {
|
|
587
|
+
if (!e) throw new Error("tableRef are required");
|
|
588
|
+
const l = A(() => {
|
|
589
|
+
var u;
|
|
590
|
+
return (u = e.value) == null ? void 0 : u.searchRef;
|
|
591
|
+
}), { height: v } = Fe(), { height: p } = Pe(l), { height: g = 0, minHeight: m = 600 } = s || {};
|
|
575
592
|
return {
|
|
576
|
-
height:
|
|
577
|
-
const
|
|
578
|
-
return
|
|
593
|
+
height: A(() => {
|
|
594
|
+
const u = v.value - p.value - g;
|
|
595
|
+
return u > m ? u : m;
|
|
579
596
|
})
|
|
580
597
|
};
|
|
581
598
|
}
|
|
599
|
+
function qe(e, s) {
|
|
600
|
+
const { immediate: l = !0 } = s || {}, v = Y(null), p = Y(!1), g = Y(null), m = async () => {
|
|
601
|
+
p.value = !0, g.value = null;
|
|
602
|
+
try {
|
|
603
|
+
const o = await e();
|
|
604
|
+
v.value = o;
|
|
605
|
+
} catch (o) {
|
|
606
|
+
g.value = o;
|
|
607
|
+
} finally {
|
|
608
|
+
p.value = !1;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
return l && m(), {
|
|
612
|
+
data: v,
|
|
613
|
+
loading: p,
|
|
614
|
+
error: g,
|
|
615
|
+
fetchData: m
|
|
616
|
+
};
|
|
617
|
+
}
|
|
582
618
|
export {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
619
|
+
qe as useAsyncData,
|
|
620
|
+
Ee as useExportFile,
|
|
621
|
+
Be as useList,
|
|
622
|
+
Ke as useTableHeight
|
|
586
623
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OptionsType } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 异步请求数据的 Hook
|
|
4
|
+
* @param requestFn - 请求函数
|
|
5
|
+
* @param options - 配置
|
|
6
|
+
* @param options.immediate - 是否立即执行,默认为 true
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function useAsyncData<T>(requestFn: () => Promise<T>, options?: OptionsType): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@banmao/hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -17,21 +17,17 @@
|
|
|
17
17
|
],
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@vue/tsconfig": "^0.7.0",
|
|
20
|
-
"echarts": "^5.6.0",
|
|
21
20
|
"glob": "^11.0.0",
|
|
22
21
|
"naive-ui": "^2.41.0",
|
|
23
22
|
"typescript": "~5.6.2",
|
|
24
|
-
"vite": "^6.
|
|
23
|
+
"vite": "^6.3.5",
|
|
25
24
|
"vite-plugin-compression": "^0.5.1",
|
|
26
|
-
"vue": "^3.5.
|
|
27
|
-
"vue-
|
|
28
|
-
"vue-tsc": "^2.2.0"
|
|
25
|
+
"vue": "^3.5.14",
|
|
26
|
+
"vue-tsc": "^2.2.10"
|
|
29
27
|
},
|
|
30
28
|
"peerDependencies": {
|
|
31
|
-
"echarts": "^5.6.0",
|
|
32
29
|
"naive-ui": "^2.41.0",
|
|
33
|
-
"vue": "^3.5.13"
|
|
34
|
-
"vue-echarts": "^7.0.3"
|
|
30
|
+
"vue": "^3.5.13"
|
|
35
31
|
},
|
|
36
32
|
"dependencies": {
|
|
37
33
|
"dayjs": "^1.11.13",
|