@banmao/hooks 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +482 -285
- package/dist/useList/index.d.ts +0 -1
- package/dist/useTableHeight.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @banmao/hooks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
这是一个基于 Vue Composition API 的自定义 Hooks 库,旨在提高开发效率并简化复杂的状态管理和逻辑处理。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 提供多种实用的 Vue Composition API Hooks
|
|
8
|
+
- 易于集成到 Vue 3 项目中
|
|
9
|
+
- 支持 TypeScript,具有完善的类型定义
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
使用 pnpm 或 yarn 安装:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm install @banmao/hooks
|
|
17
|
+
# 或者
|
|
18
|
+
yarn add @banmao/hooks
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
import { useCustomHook } from '@banmao/hooks';
|
|
22
|
+
<script setup>
|
|
23
|
+
defineComponent({
|
|
24
|
+
setup() {
|
|
25
|
+
const { value, setValue } = useCustomHook();
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
value,
|
|
29
|
+
setValue,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<!-- element -->
|
|
37
|
+
</template>
|
|
38
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("vue");function ee(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Z={exports:{}},te=Z.exports,G;function ne(){return G||(G=1,function(l,b){(function(D,O){l.exports=O()})(te,function(){var D=1e3,O=6e4,g=36e5,E="millisecond",L="second",_="minute",$="hour",v="day",H="week",p="month",U="quarter",x="year",j="date",q="Invalid Date",B=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Q=/\[([^\]]+)]|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,c={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(s){var n=["th","st","nd","rd"],e=s%100;return"["+s+(n[(e-20)%10]||n[e]||n[0])+"]"}},w=function(s,n,e){var r=String(s);return!r||r.length>=n?s:""+Array(n+1-r.length).join(e)+s},C={s:w,z:function(s){var n=-s.utcOffset(),e=Math.abs(n),r=Math.floor(e/60),t=e%60;return(n<=0?"+":"-")+w(r,2,"0")+":"+w(t,2,"0")},m:function s(n,e){if(n.date()<e.date())return-s(e,n);var r=12*(e.year()-n.year())+(e.month()-n.month()),t=n.clone().add(r,p),a=e-t<0,i=n.clone().add(r+(a?-1:1),p);return+(-(r+(e-t)/(a?t-i:i-t))||0)},a:function(s){return s<0?Math.ceil(s)||0:Math.floor(s)},p:function(s){return{M:p,y:x,w:H,d:v,D:j,h:$,m:_,s:L,ms:E,Q:U}[s]||String(s||"").toLowerCase().replace(/s$/,"")},u:function(s){return s===void 0}},S="en",k={};k[S]=c;var R="$isDayjsObject",F=function(s){return s instanceof K||!(!s||!s[R])},I=function s(n,e,r){var t;if(!n)return S;if(typeof n=="string"){var a=n.toLowerCase();k[a]&&(t=a),e&&(k[a]=e,t=a);var i=n.split("-");if(!t&&i.length>1)return s(i[0])}else{var o=n.name;k[o]=n,t=o}return!r&&t&&(S=t),t||!r&&S},d=function(s,n){if(F(s))return s.clone();var e=typeof n=="object"?n:{};return e.date=s,e.args=arguments,new K(e)},u=C;u.l=I,u.i=F,u.w=function(s,n){return d(s,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var K=function(){function s(e){this.$L=I(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[R]=!0}var n=s.prototype;return n.parse=function(e){this.$d=function(r){var t=r.date,a=r.utc;if(t===null)return new Date(NaN);if(u.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){var i=t.match(B);if(i){var o=i[2]-1||0,f=(i[7]||"0").substring(0,3);return a?new Date(Date.UTC(i[1],o,i[3]||1,i[4]||0,i[5]||0,i[6]||0,f)):new Date(i[1],o,i[3]||1,i[4]||0,i[5]||0,i[6]||0,f)}}return new Date(t)}(e),this.init()},n.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()},n.$utils=function(){return u},n.isValid=function(){return this.$d.toString()!==q},n.isSame=function(e,r){var t=d(e);return this.startOf(r)<=t&&t<=this.endOf(r)},n.isAfter=function(e,r){return d(e)<this.startOf(r)},n.isBefore=function(e,r){return this.endOf(r)<d(e)},n.$g=function(e,r,t){return u.u(e)?this[r]:this.set(t,e)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(e,r){var t=this,a=!!u.u(r)||r,i=u.p(e),o=function(z,y){var T=u.w(t.$u?Date.UTC(t.$y,y,z):new Date(t.$y,y,z),t);return a?T:T.endOf(v)},f=function(z,y){return u.w(t.toDate()[z].apply(t.toDate("s"),(a?[0,0,0,0]:[23,59,59,999]).slice(y)),t)},h=this.$W,m=this.$M,M=this.$D,W="set"+(this.$u?"UTC":"");switch(i){case x:return a?o(1,0):o(31,11);case p:return a?o(1,m):o(0,m+1);case H:var Y=this.$locale().weekStart||0,N=(h<Y?h+7:h)-Y;return o(a?M-N:M+(6-N),m);case v:case j:return f(W+"Hours",0);case $:return f(W+"Minutes",1);case _:return f(W+"Seconds",2);case L:return f(W+"Milliseconds",3);default:return this.clone()}},n.endOf=function(e){return this.startOf(e,!1)},n.$set=function(e,r){var t,a=u.p(e),i="set"+(this.$u?"UTC":""),o=(t={},t[v]=i+"Date",t[j]=i+"Date",t[p]=i+"Month",t[x]=i+"FullYear",t[$]=i+"Hours",t[_]=i+"Minutes",t[L]=i+"Seconds",t[E]=i+"Milliseconds",t)[a],f=a===v?this.$D+(r-this.$W):r;if(a===p||a===x){var h=this.clone().set(j,1);h.$d[o](f),h.init(),this.$d=h.set(j,Math.min(this.$D,h.daysInMonth())).$d}else o&&this.$d[o](f);return this.init(),this},n.set=function(e,r){return this.clone().$set(e,r)},n.get=function(e){return this[u.p(e)]()},n.add=function(e,r){var t,a=this;e=Number(e);var i=u.p(r),o=function(m){var M=d(a);return u.w(M.date(M.date()+Math.round(m*e)),a)};if(i===p)return this.set(p,this.$M+e);if(i===x)return this.set(x,this.$y+e);if(i===v)return o(1);if(i===H)return o(7);var f=(t={},t[_]=O,t[$]=g,t[L]=D,t)[i]||1,h=this.$d.getTime()+e*f;return u.w(h,this)},n.subtract=function(e,r){return this.add(-1*e,r)},n.format=function(e){var r=this,t=this.$locale();if(!this.isValid())return t.invalidDate||q;var a=e||"YYYY-MM-DDTHH:mm:ssZ",i=u.z(this),o=this.$H,f=this.$m,h=this.$M,m=t.weekdays,M=t.months,W=t.meridiem,Y=function(y,T,P,J){return y&&(y[T]||y(r,a))||P[T].slice(0,J)},N=function(y){return u.s(o%12||12,y,"0")},z=W||function(y,T,P){var J=y<12?"AM":"PM";return P?J.toLowerCase():J};return a.replace(Q,function(y,T){return T||function(P){switch(P){case"YY":return String(r.$y).slice(-2);case"YYYY":return u.s(r.$y,4,"0");case"M":return h+1;case"MM":return u.s(h+1,2,"0");case"MMM":return Y(t.monthsShort,h,M,3);case"MMMM":return Y(M,h);case"D":return r.$D;case"DD":return u.s(r.$D,2,"0");case"d":return String(r.$W);case"dd":return Y(t.weekdaysMin,r.$W,m,2);case"ddd":return Y(t.weekdaysShort,r.$W,m,3);case"dddd":return m[r.$W];case"H":return String(o);case"HH":return u.s(o,2,"0");case"h":return N(1);case"hh":return N(2);case"a":return z(o,f,!0);case"A":return z(o,f,!1);case"m":return String(f);case"mm":return u.s(f,2,"0");case"s":return String(r.$s);case"ss":return u.s(r.$s,2,"0");case"SSS":return u.s(r.$ms,3,"0");case"Z":return i}return null}(y)||i.replace(":","")})},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(e,r,t){var a,i=this,o=u.p(r),f=d(e),h=(f.utcOffset()-this.utcOffset())*O,m=this-f,M=function(){return u.m(i,f)};switch(o){case x:a=M()/12;break;case p:a=M();break;case U:a=M()/3;break;case H:a=(m-h)/6048e5;break;case v:a=(m-h)/864e5;break;case $:a=m/g;break;case _:a=m/O;break;case L:a=m/D;break;default:a=m}return t?a:u.a(a)},n.daysInMonth=function(){return this.endOf(p).$D},n.$locale=function(){return k[this.$L]},n.locale=function(e,r){if(!e)return this.$L;var t=this.clone(),a=I(e,r,!0);return a&&(t.$L=a),t},n.clone=function(){return u.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},s}(),V=K.prototype;return d.prototype=V,[["$ms",E],["$s",L],["$m",_],["$H",$],["$W",v],["$M",p],["$y",x],["$D",j]].forEach(function(s){V[s[1]]=function(n){return this.$g(n,s[0],s[1])}}),d.extend=function(s,n){return s.$i||(s(n,K,d),s.$i=!0),d},d.locale=I,d.isDayjs=F,d.unix=function(s){return d(1e3*s)},d.en=k[S],d.Ls=k,d.p={},d})}(Z)),Z.exports}var re=ne();const se=ee(re);function ae(l){const b=new Blob([l],{type:"application/vnd.ms-excel"});return window.URL.createObjectURL(b)}function ie(){return document.createElement("a")}function X(l,b){const D=se().format("yyyy-MM-dd hh:mm:ss");function O(){const g=ie(),E=ae(l);g.href=E,b?g.download=b||`${b}-${D}.xlsx`:g.download=`${D}.xlsx`,document.body.appendChild(g),g.click(),document.body.removeChild(g),window.URL.revokeObjectURL(E)}O()}function ue(l,b){throw new Error(`[naive/${l}]: ${b}`)}const oe="n-message-api";function ce(){const l=A.inject(oe,null);return l===null&&ue("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."),l}function fe(l,b={}){const{exportRequestFn:D,filterOption:O=A.ref(),callback:g,immediate:E=!0,code:L=200}=b,_=A.ref(!1),$=A.ref({page:1,pageSize:10,itemCount:0,showSizePicker:!0,pageSizes:[10,20,30,40],showQuickJumper:!0,prefix:c=>`共 ${c.itemCount} 条`}),v=A.ref([]),H=A.computed(()=>O.value),p=async(c=$.value.page,w)=>{_.value=!0;try{const{status:C,data:S}=await l({pageNum:c,pageSize:$.value.pageSize,...H.value,...w}),{list:k,pageNum:R,total:F,pageSize:I}=g&&g(S)||S;if(C===L&&Array.isArray(k))v.value=k,$.value={...$.value,page:R,itemCount:F,pageSize:I};else throw v.value=[],$.value={...$.value,pageSize:10,itemCount:0,page:1},new Error("list的数据类型错误")}catch(C){throw console.error("Error in loadData:",C),C}finally{_.value=!1}},U=ce(),x=async()=>{if(!D||typeof D!="function")throw new Error("当前没有提供exportRequest函数");try{const{data:c,fileName:w}=await D(O.value);X(c,w),U==null||U.success("成功导出")}catch(c){throw console.error("Error in handleExcelData:",c),c}},j=(c,w)=>{w!==void 0&&($.value.pageSize=w),p(c)},q=c=>{j(c)},B=c=>{j(1,c)},Q=c=>{if(c.sorter){const w=[...v.value].sort((C,S)=>c.order==="ascend"?C[c.columnKey]>S[c.columnKey]?1:-1:c.order==="descend"?C[c.columnKey]<S[c.columnKey]?1:-1:0);v.value=w}};return A.onMounted(()=>E&&p($.value.page)),{dataSource:v,loading:_,pagination:$,handleExcelData:x,handlePageChange:q,handlePageSizeChange:B,handleSortChange:Q,loadData:p}}exports.useExportFile=X;exports.useList=fe;
|
|
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;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,389 +1,586 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { inject as de, ref as H, computed as V, onMounted as se, nextTick as me, getCurrentScope as pe, onScopeDispose as ge, getCurrentInstance as ie, hasInjectionContext as he, watch as ee, toValue as q, watchEffect as we } from "vue";
|
|
2
|
+
function $e(t) {
|
|
3
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
4
4
|
}
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
(function(
|
|
9
|
-
|
|
10
|
-
})(
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
return "[" +
|
|
14
|
-
} },
|
|
15
|
-
var
|
|
16
|
-
return !
|
|
17
|
-
},
|
|
18
|
-
var
|
|
19
|
-
return (
|
|
20
|
-
}, m: function
|
|
21
|
-
if (
|
|
22
|
-
var
|
|
23
|
-
return +(-(
|
|
24
|
-
}, a: function(
|
|
25
|
-
return
|
|
26
|
-
}, p: function(
|
|
27
|
-
return { M:
|
|
28
|
-
}, u: function(
|
|
29
|
-
return
|
|
30
|
-
} },
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
return
|
|
34
|
-
},
|
|
35
|
-
var
|
|
36
|
-
if (!
|
|
37
|
-
if (typeof
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
if (!
|
|
5
|
+
var X = { exports: {} }, ye = X.exports, ue;
|
|
6
|
+
function Me() {
|
|
7
|
+
return ue || (ue = 1, function(t, s) {
|
|
8
|
+
(function(l, f) {
|
|
9
|
+
t.exports = f();
|
|
10
|
+
})(ye, function() {
|
|
11
|
+
var l = 1e3, f = 6e4, g = 36e5, $ = "millisecond", d = "second", v = "minute", h = "hour", m = "day", M = "week", o = "month", p = "quarter", b = "year", D = "date", C = "Invalid Date", I = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, te = /\[([^\]]+)]|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, S = { 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) {
|
|
12
|
+
var r = ["th", "st", "nd", "rd"], e = a % 100;
|
|
13
|
+
return "[" + a + (r[(e - 20) % 10] || r[e] || r[0]) + "]";
|
|
14
|
+
} }, L = function(a, r, e) {
|
|
15
|
+
var i = String(a);
|
|
16
|
+
return !i || i.length >= r ? a : "" + Array(r + 1 - i.length).join(e) + a;
|
|
17
|
+
}, T = { s: L, z: function(a) {
|
|
18
|
+
var r = -a.utcOffset(), e = Math.abs(r), i = Math.floor(e / 60), n = e % 60;
|
|
19
|
+
return (r <= 0 ? "+" : "-") + L(i, 2, "0") + ":" + L(n, 2, "0");
|
|
20
|
+
}, m: function a(r, e) {
|
|
21
|
+
if (r.date() < e.date()) return -a(e, r);
|
|
22
|
+
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);
|
|
23
|
+
return +(-(i + (e - n) / (u ? n - c : c - n)) || 0);
|
|
24
|
+
}, a: function(a) {
|
|
25
|
+
return a < 0 ? Math.ceil(a) || 0 : Math.floor(a);
|
|
26
|
+
}, p: function(a) {
|
|
27
|
+
return { M: o, y: b, w: M, d: m, D, h, m: v, s: d, ms: $, Q: p }[a] || String(a || "").toLowerCase().replace(/s$/, "");
|
|
28
|
+
}, u: function(a) {
|
|
29
|
+
return a === void 0;
|
|
30
|
+
} }, j = "en", z = {};
|
|
31
|
+
z[j] = S;
|
|
32
|
+
var Q = "$isDayjsObject", U = function(a) {
|
|
33
|
+
return a instanceof Z || !(!a || !a[Q]);
|
|
34
|
+
}, F = function a(r, e, i) {
|
|
35
|
+
var n;
|
|
36
|
+
if (!r) return j;
|
|
37
|
+
if (typeof r == "string") {
|
|
38
|
+
var u = r.toLowerCase();
|
|
39
|
+
z[u] && (n = u), e && (z[u] = e, n = u);
|
|
40
|
+
var c = r.split("-");
|
|
41
|
+
if (!n && c.length > 1) return a(c[0]);
|
|
42
42
|
} else {
|
|
43
|
-
var
|
|
44
|
-
|
|
43
|
+
var y = r.name;
|
|
44
|
+
z[y] = r, n = y;
|
|
45
45
|
}
|
|
46
|
-
return !
|
|
47
|
-
},
|
|
48
|
-
if (
|
|
49
|
-
var e = typeof
|
|
50
|
-
return e.date =
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
return
|
|
46
|
+
return !i && n && (j = n), n || !i && j;
|
|
47
|
+
}, x = function(a, r) {
|
|
48
|
+
if (U(a)) return a.clone();
|
|
49
|
+
var e = typeof r == "object" ? r : {};
|
|
50
|
+
return e.date = a, e.args = arguments, new Z(e);
|
|
51
|
+
}, w = T;
|
|
52
|
+
w.l = F, w.i = U, w.w = function(a, r) {
|
|
53
|
+
return x(a, { locale: r.$L, utc: r.$u, x: r.$x, $offset: r.$offset });
|
|
54
54
|
};
|
|
55
|
-
var
|
|
56
|
-
function
|
|
57
|
-
this.$L =
|
|
55
|
+
var Z = function() {
|
|
56
|
+
function a(e) {
|
|
57
|
+
this.$L = F(e.locale, null, !0), this.parse(e), this.$x = this.$x || e.x || {}, this[Q] = !0;
|
|
58
58
|
}
|
|
59
|
-
var
|
|
60
|
-
return
|
|
61
|
-
this.$d = function(
|
|
62
|
-
var
|
|
63
|
-
if (
|
|
64
|
-
if (
|
|
65
|
-
if (
|
|
66
|
-
if (typeof
|
|
67
|
-
var
|
|
68
|
-
if (
|
|
69
|
-
var
|
|
70
|
-
return
|
|
59
|
+
var r = a.prototype;
|
|
60
|
+
return r.parse = function(e) {
|
|
61
|
+
this.$d = function(i) {
|
|
62
|
+
var n = i.date, u = i.utc;
|
|
63
|
+
if (n === null) return /* @__PURE__ */ new Date(NaN);
|
|
64
|
+
if (w.u(n)) return /* @__PURE__ */ new Date();
|
|
65
|
+
if (n instanceof Date) return new Date(n);
|
|
66
|
+
if (typeof n == "string" && !/Z$/i.test(n)) {
|
|
67
|
+
var c = n.match(I);
|
|
68
|
+
if (c) {
|
|
69
|
+
var y = c[2] - 1 || 0, O = (c[7] || "0").substring(0, 3);
|
|
70
|
+
return u ? new Date(Date.UTC(c[1], y, c[3] || 1, c[4] || 0, c[5] || 0, c[6] || 0, O)) : new Date(c[1], y, c[3] || 1, c[4] || 0, c[5] || 0, c[6] || 0, O);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
return new Date(
|
|
73
|
+
return new Date(n);
|
|
74
74
|
}(e), this.init();
|
|
75
|
-
},
|
|
75
|
+
}, r.init = function() {
|
|
76
76
|
var e = this.$d;
|
|
77
77
|
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();
|
|
78
|
-
},
|
|
79
|
-
return
|
|
80
|
-
},
|
|
81
|
-
return this.$d.toString() !==
|
|
82
|
-
},
|
|
83
|
-
var
|
|
84
|
-
return this.startOf(
|
|
85
|
-
},
|
|
86
|
-
return
|
|
87
|
-
},
|
|
88
|
-
return this.endOf(
|
|
89
|
-
},
|
|
90
|
-
return
|
|
91
|
-
},
|
|
78
|
+
}, r.$utils = function() {
|
|
79
|
+
return w;
|
|
80
|
+
}, r.isValid = function() {
|
|
81
|
+
return this.$d.toString() !== C;
|
|
82
|
+
}, r.isSame = function(e, i) {
|
|
83
|
+
var n = x(e);
|
|
84
|
+
return this.startOf(i) <= n && n <= this.endOf(i);
|
|
85
|
+
}, r.isAfter = function(e, i) {
|
|
86
|
+
return x(e) < this.startOf(i);
|
|
87
|
+
}, r.isBefore = function(e, i) {
|
|
88
|
+
return this.endOf(i) < x(e);
|
|
89
|
+
}, r.$g = function(e, i, n) {
|
|
90
|
+
return w.u(e) ? this[i] : this.set(n, e);
|
|
91
|
+
}, r.unix = function() {
|
|
92
92
|
return Math.floor(this.valueOf() / 1e3);
|
|
93
|
-
},
|
|
93
|
+
}, r.valueOf = function() {
|
|
94
94
|
return this.$d.getTime();
|
|
95
|
-
},
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
return
|
|
99
|
-
},
|
|
100
|
-
return
|
|
101
|
-
},
|
|
102
|
-
switch (
|
|
103
|
-
case
|
|
104
|
-
return
|
|
105
|
-
case
|
|
106
|
-
return
|
|
107
|
-
case
|
|
108
|
-
var
|
|
109
|
-
return
|
|
95
|
+
}, r.startOf = function(e, i) {
|
|
96
|
+
var n = this, u = !!w.u(i) || i, c = w.p(e), y = function(N, W) {
|
|
97
|
+
var A = w.w(n.$u ? Date.UTC(n.$y, W, N) : new Date(n.$y, W, N), n);
|
|
98
|
+
return u ? A : A.endOf(m);
|
|
99
|
+
}, O = function(N, W) {
|
|
100
|
+
return w.w(n.toDate()[N].apply(n.toDate("s"), (u ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(W)), n);
|
|
101
|
+
}, _ = this.$W, E = this.$M, k = this.$D, P = "set" + (this.$u ? "UTC" : "");
|
|
102
|
+
switch (c) {
|
|
103
|
+
case b:
|
|
104
|
+
return u ? y(1, 0) : y(31, 11);
|
|
105
|
+
case o:
|
|
106
|
+
return u ? y(1, E) : y(0, E + 1);
|
|
107
|
+
case M:
|
|
108
|
+
var R = this.$locale().weekStart || 0, B = (_ < R ? _ + 7 : _) - R;
|
|
109
|
+
return y(u ? k - B : k + (6 - B), E);
|
|
110
|
+
case m:
|
|
111
|
+
case D:
|
|
112
|
+
return O(P + "Hours", 0);
|
|
113
|
+
case h:
|
|
114
|
+
return O(P + "Minutes", 1);
|
|
110
115
|
case v:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return f(I + "Minutes", 1);
|
|
115
|
-
case _:
|
|
116
|
-
return f(I + "Seconds", 2);
|
|
117
|
-
case L:
|
|
118
|
-
return f(I + "Milliseconds", 3);
|
|
116
|
+
return O(P + "Seconds", 2);
|
|
117
|
+
case d:
|
|
118
|
+
return O(P + "Milliseconds", 3);
|
|
119
119
|
default:
|
|
120
120
|
return this.clone();
|
|
121
121
|
}
|
|
122
|
-
},
|
|
122
|
+
}, r.endOf = function(e) {
|
|
123
123
|
return this.startOf(e, !1);
|
|
124
|
-
},
|
|
125
|
-
var
|
|
126
|
-
if (
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
} else
|
|
124
|
+
}, r.$set = function(e, i) {
|
|
125
|
+
var n, u = w.p(e), c = "set" + (this.$u ? "UTC" : ""), y = (n = {}, n[m] = c + "Date", n[D] = c + "Date", n[o] = c + "Month", n[b] = c + "FullYear", n[h] = c + "Hours", n[v] = c + "Minutes", n[d] = c + "Seconds", n[$] = c + "Milliseconds", n)[u], O = u === m ? this.$D + (i - this.$W) : i;
|
|
126
|
+
if (u === o || u === b) {
|
|
127
|
+
var _ = this.clone().set(D, 1);
|
|
128
|
+
_.$d[y](O), _.init(), this.$d = _.set(D, Math.min(this.$D, _.daysInMonth())).$d;
|
|
129
|
+
} else y && this.$d[y](O);
|
|
130
130
|
return this.init(), this;
|
|
131
|
-
},
|
|
132
|
-
return this.clone().$set(e,
|
|
133
|
-
},
|
|
134
|
-
return this[
|
|
135
|
-
},
|
|
136
|
-
var
|
|
131
|
+
}, r.set = function(e, i) {
|
|
132
|
+
return this.clone().$set(e, i);
|
|
133
|
+
}, r.get = function(e) {
|
|
134
|
+
return this[w.p(e)]();
|
|
135
|
+
}, r.add = function(e, i) {
|
|
136
|
+
var n, u = this;
|
|
137
137
|
e = Number(e);
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
return
|
|
138
|
+
var c = w.p(i), y = function(E) {
|
|
139
|
+
var k = x(u);
|
|
140
|
+
return w.w(k.date(k.date() + Math.round(E * e)), u);
|
|
141
141
|
};
|
|
142
|
-
if (
|
|
143
|
-
if (
|
|
144
|
-
if (
|
|
145
|
-
if (
|
|
146
|
-
var
|
|
147
|
-
return
|
|
148
|
-
},
|
|
149
|
-
return this.add(-1 * e,
|
|
150
|
-
},
|
|
151
|
-
var
|
|
152
|
-
if (!this.isValid()) return
|
|
153
|
-
var
|
|
154
|
-
return
|
|
155
|
-
},
|
|
156
|
-
return
|
|
157
|
-
},
|
|
158
|
-
var
|
|
159
|
-
return
|
|
142
|
+
if (c === o) return this.set(o, this.$M + e);
|
|
143
|
+
if (c === b) return this.set(b, this.$y + e);
|
|
144
|
+
if (c === m) return y(1);
|
|
145
|
+
if (c === M) return y(7);
|
|
146
|
+
var O = (n = {}, n[v] = f, n[h] = g, n[d] = l, n)[c] || 1, _ = this.$d.getTime() + e * O;
|
|
147
|
+
return w.w(_, this);
|
|
148
|
+
}, r.subtract = function(e, i) {
|
|
149
|
+
return this.add(-1 * e, i);
|
|
150
|
+
}, r.format = function(e) {
|
|
151
|
+
var i = this, n = this.$locale();
|
|
152
|
+
if (!this.isValid()) return n.invalidDate || C;
|
|
153
|
+
var u = e || "YYYY-MM-DDTHH:mm:ssZ", c = w.z(this), y = this.$H, O = this.$m, _ = this.$M, E = n.weekdays, k = n.months, P = n.meridiem, R = function(W, A, K, G) {
|
|
154
|
+
return W && (W[A] || W(i, u)) || K[A].slice(0, G);
|
|
155
|
+
}, B = function(W) {
|
|
156
|
+
return w.s(y % 12 || 12, W, "0");
|
|
157
|
+
}, N = P || function(W, A, K) {
|
|
158
|
+
var G = W < 12 ? "AM" : "PM";
|
|
159
|
+
return K ? G.toLowerCase() : G;
|
|
160
160
|
};
|
|
161
|
-
return
|
|
162
|
-
return
|
|
163
|
-
switch (
|
|
161
|
+
return u.replace(te, function(W, A) {
|
|
162
|
+
return A || function(K) {
|
|
163
|
+
switch (K) {
|
|
164
164
|
case "YY":
|
|
165
|
-
return String(
|
|
165
|
+
return String(i.$y).slice(-2);
|
|
166
166
|
case "YYYY":
|
|
167
|
-
return
|
|
167
|
+
return w.s(i.$y, 4, "0");
|
|
168
168
|
case "M":
|
|
169
|
-
return
|
|
169
|
+
return _ + 1;
|
|
170
170
|
case "MM":
|
|
171
|
-
return
|
|
171
|
+
return w.s(_ + 1, 2, "0");
|
|
172
172
|
case "MMM":
|
|
173
|
-
return
|
|
173
|
+
return R(n.monthsShort, _, k, 3);
|
|
174
174
|
case "MMMM":
|
|
175
|
-
return
|
|
175
|
+
return R(k, _);
|
|
176
176
|
case "D":
|
|
177
|
-
return
|
|
177
|
+
return i.$D;
|
|
178
178
|
case "DD":
|
|
179
|
-
return
|
|
179
|
+
return w.s(i.$D, 2, "0");
|
|
180
180
|
case "d":
|
|
181
|
-
return String(
|
|
181
|
+
return String(i.$W);
|
|
182
182
|
case "dd":
|
|
183
|
-
return
|
|
183
|
+
return R(n.weekdaysMin, i.$W, E, 2);
|
|
184
184
|
case "ddd":
|
|
185
|
-
return
|
|
185
|
+
return R(n.weekdaysShort, i.$W, E, 3);
|
|
186
186
|
case "dddd":
|
|
187
|
-
return
|
|
187
|
+
return E[i.$W];
|
|
188
188
|
case "H":
|
|
189
|
-
return String(
|
|
189
|
+
return String(y);
|
|
190
190
|
case "HH":
|
|
191
|
-
return
|
|
191
|
+
return w.s(y, 2, "0");
|
|
192
192
|
case "h":
|
|
193
|
-
return
|
|
193
|
+
return B(1);
|
|
194
194
|
case "hh":
|
|
195
|
-
return
|
|
195
|
+
return B(2);
|
|
196
196
|
case "a":
|
|
197
|
-
return
|
|
197
|
+
return N(y, O, !0);
|
|
198
198
|
case "A":
|
|
199
|
-
return
|
|
199
|
+
return N(y, O, !1);
|
|
200
200
|
case "m":
|
|
201
|
-
return String(
|
|
201
|
+
return String(O);
|
|
202
202
|
case "mm":
|
|
203
|
-
return
|
|
203
|
+
return w.s(O, 2, "0");
|
|
204
204
|
case "s":
|
|
205
|
-
return String(
|
|
205
|
+
return String(i.$s);
|
|
206
206
|
case "ss":
|
|
207
|
-
return
|
|
207
|
+
return w.s(i.$s, 2, "0");
|
|
208
208
|
case "SSS":
|
|
209
|
-
return
|
|
209
|
+
return w.s(i.$ms, 3, "0");
|
|
210
210
|
case "Z":
|
|
211
|
-
return
|
|
211
|
+
return c;
|
|
212
212
|
}
|
|
213
213
|
return null;
|
|
214
|
-
}(
|
|
214
|
+
}(W) || c.replace(":", "");
|
|
215
215
|
});
|
|
216
|
-
},
|
|
216
|
+
}, r.utcOffset = function() {
|
|
217
217
|
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
218
|
-
},
|
|
219
|
-
var
|
|
220
|
-
return
|
|
218
|
+
}, r.diff = function(e, i, n) {
|
|
219
|
+
var u, c = this, y = w.p(i), O = x(e), _ = (O.utcOffset() - this.utcOffset()) * f, E = this - O, k = function() {
|
|
220
|
+
return w.m(c, O);
|
|
221
221
|
};
|
|
222
|
-
switch (
|
|
223
|
-
case
|
|
224
|
-
|
|
222
|
+
switch (y) {
|
|
223
|
+
case b:
|
|
224
|
+
u = k() / 12;
|
|
225
|
+
break;
|
|
226
|
+
case o:
|
|
227
|
+
u = k();
|
|
225
228
|
break;
|
|
226
229
|
case p:
|
|
227
|
-
|
|
230
|
+
u = k() / 3;
|
|
228
231
|
break;
|
|
229
|
-
case
|
|
230
|
-
|
|
232
|
+
case M:
|
|
233
|
+
u = (E - _) / 6048e5;
|
|
231
234
|
break;
|
|
232
|
-
case
|
|
233
|
-
|
|
235
|
+
case m:
|
|
236
|
+
u = (E - _) / 864e5;
|
|
234
237
|
break;
|
|
235
|
-
case
|
|
236
|
-
|
|
238
|
+
case h:
|
|
239
|
+
u = E / g;
|
|
237
240
|
break;
|
|
238
|
-
case
|
|
239
|
-
|
|
240
|
-
break;
|
|
241
|
-
case _:
|
|
242
|
-
a = m / b;
|
|
241
|
+
case v:
|
|
242
|
+
u = E / f;
|
|
243
243
|
break;
|
|
244
|
-
case
|
|
245
|
-
|
|
244
|
+
case d:
|
|
245
|
+
u = E / l;
|
|
246
246
|
break;
|
|
247
247
|
default:
|
|
248
|
-
|
|
248
|
+
u = E;
|
|
249
249
|
}
|
|
250
|
-
return
|
|
251
|
-
},
|
|
252
|
-
return this.endOf(
|
|
253
|
-
},
|
|
254
|
-
return
|
|
255
|
-
},
|
|
250
|
+
return n ? u : w.a(u);
|
|
251
|
+
}, r.daysInMonth = function() {
|
|
252
|
+
return this.endOf(o).$D;
|
|
253
|
+
}, r.$locale = function() {
|
|
254
|
+
return z[this.$L];
|
|
255
|
+
}, r.locale = function(e, i) {
|
|
256
256
|
if (!e) return this.$L;
|
|
257
|
-
var
|
|
258
|
-
return
|
|
259
|
-
},
|
|
260
|
-
return
|
|
261
|
-
},
|
|
257
|
+
var n = this.clone(), u = F(e, i, !0);
|
|
258
|
+
return u && (n.$L = u), n;
|
|
259
|
+
}, r.clone = function() {
|
|
260
|
+
return w.w(this.$d, this);
|
|
261
|
+
}, r.toDate = function() {
|
|
262
262
|
return new Date(this.valueOf());
|
|
263
|
-
},
|
|
263
|
+
}, r.toJSON = function() {
|
|
264
264
|
return this.isValid() ? this.toISOString() : null;
|
|
265
|
-
},
|
|
265
|
+
}, r.toISOString = function() {
|
|
266
266
|
return this.$d.toISOString();
|
|
267
|
-
},
|
|
267
|
+
}, r.toString = function() {
|
|
268
268
|
return this.$d.toUTCString();
|
|
269
|
-
},
|
|
270
|
-
}(),
|
|
271
|
-
return
|
|
272
|
-
|
|
273
|
-
return this.$g(
|
|
269
|
+
}, a;
|
|
270
|
+
}(), ae = Z.prototype;
|
|
271
|
+
return x.prototype = ae, [["$ms", $], ["$s", d], ["$m", v], ["$H", h], ["$W", m], ["$M", o], ["$y", b], ["$D", D]].forEach(function(a) {
|
|
272
|
+
ae[a[1]] = function(r) {
|
|
273
|
+
return this.$g(r, a[0], a[1]);
|
|
274
274
|
};
|
|
275
|
-
}),
|
|
276
|
-
return
|
|
277
|
-
},
|
|
278
|
-
return
|
|
279
|
-
},
|
|
275
|
+
}), x.extend = function(a, r) {
|
|
276
|
+
return a.$i || (a(r, Z, x), a.$i = !0), x;
|
|
277
|
+
}, x.locale = F, x.isDayjs = U, x.unix = function(a) {
|
|
278
|
+
return x(1e3 * a);
|
|
279
|
+
}, x.en = z[j], x.Ls = z, x.p = {}, x;
|
|
280
280
|
});
|
|
281
|
-
}(
|
|
281
|
+
}(X)), X.exports;
|
|
282
282
|
}
|
|
283
|
-
var
|
|
284
|
-
const
|
|
285
|
-
function
|
|
286
|
-
const
|
|
283
|
+
var Se = Me();
|
|
284
|
+
const be = /* @__PURE__ */ $e(Se);
|
|
285
|
+
function De(t) {
|
|
286
|
+
const s = new Blob([t], {
|
|
287
287
|
type: "application/vnd.ms-excel"
|
|
288
288
|
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
289
289
|
});
|
|
290
|
-
return window.URL.createObjectURL(
|
|
290
|
+
return window.URL.createObjectURL(s);
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function Oe() {
|
|
293
293
|
return document.createElement("a");
|
|
294
294
|
}
|
|
295
|
-
function
|
|
296
|
-
const
|
|
297
|
-
function
|
|
298
|
-
const g =
|
|
299
|
-
g.href =
|
|
295
|
+
function xe(t, s) {
|
|
296
|
+
const l = be().format("yyyy-MM-dd hh:mm:ss");
|
|
297
|
+
function f() {
|
|
298
|
+
const g = Oe(), $ = De(t);
|
|
299
|
+
g.href = $, s ? g.download = s || `${s}-${l}.xlsx` : g.download = `${l}.xlsx`, document.body.appendChild(g), g.click(), document.body.removeChild(g), window.URL.revokeObjectURL($);
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
f();
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
throw new Error(`[naive/${
|
|
303
|
+
function _e(t, s) {
|
|
304
|
+
throw new Error(`[naive/${t}]: ${s}`);
|
|
305
305
|
}
|
|
306
|
-
const
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
return
|
|
306
|
+
const Ee = "n-message-api";
|
|
307
|
+
function We() {
|
|
308
|
+
const t = de(Ee, null);
|
|
309
|
+
return t === 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."), t;
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function Pe(t, s = {}) {
|
|
312
312
|
const {
|
|
313
|
-
exportRequestFn:
|
|
314
|
-
filterOption:
|
|
313
|
+
exportRequestFn: l,
|
|
314
|
+
filterOption: f = H(),
|
|
315
315
|
callback: g,
|
|
316
|
-
immediate:
|
|
317
|
-
code:
|
|
318
|
-
} =
|
|
316
|
+
immediate: $ = !0,
|
|
317
|
+
code: d = 200
|
|
318
|
+
} = s, v = H(!1), h = H({
|
|
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: (S) => `共 ${S.itemCount} 条`
|
|
326
|
+
}), m = H([]), M = V(() => f.value), o = async (S = h.value.page, L) => {
|
|
327
|
+
v.value = !0;
|
|
328
328
|
try {
|
|
329
|
-
const { status:
|
|
330
|
-
pageNum:
|
|
331
|
-
pageSize:
|
|
332
|
-
...
|
|
333
|
-
...
|
|
334
|
-
}), { list:
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
page:
|
|
339
|
-
itemCount:
|
|
340
|
-
pageSize:
|
|
329
|
+
const { status: T, data: j } = await t({
|
|
330
|
+
pageNum: S,
|
|
331
|
+
pageSize: h.value.pageSize,
|
|
332
|
+
...M.value,
|
|
333
|
+
...L
|
|
334
|
+
}), { list: z, pageNum: Q, total: U, pageSize: F } = g && g(j) || j;
|
|
335
|
+
if (T === d && Array.isArray(z))
|
|
336
|
+
m.value = z, h.value = {
|
|
337
|
+
...h.value,
|
|
338
|
+
page: Q,
|
|
339
|
+
itemCount: U,
|
|
340
|
+
pageSize: F
|
|
341
341
|
};
|
|
342
342
|
else
|
|
343
|
-
throw
|
|
344
|
-
|
|
343
|
+
throw m.value = [], h.value = {
|
|
344
|
+
...h.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 (T) {
|
|
350
|
+
throw console.error("Error in loadData:", T), T;
|
|
351
351
|
} finally {
|
|
352
|
-
|
|
352
|
+
v.value = !1;
|
|
353
353
|
}
|
|
354
|
-
},
|
|
355
|
-
if (!
|
|
354
|
+
}, p = We(), b = async () => {
|
|
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: S, fileName: L } = await l(f.value);
|
|
359
|
+
xe(S, L), p == null || p.success("成功导出");
|
|
360
|
+
} catch (S) {
|
|
361
|
+
throw console.error("Error in handleExcelData:", S), S;
|
|
362
362
|
}
|
|
363
|
-
},
|
|
364
|
-
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
},
|
|
368
|
-
|
|
369
|
-
},
|
|
370
|
-
if (
|
|
371
|
-
const
|
|
372
|
-
|
|
363
|
+
}, D = (S, L) => {
|
|
364
|
+
L !== void 0 && (h.value.pageSize = L), o(S);
|
|
365
|
+
}, C = (S) => {
|
|
366
|
+
D(S);
|
|
367
|
+
}, I = (S) => {
|
|
368
|
+
D(1, S);
|
|
369
|
+
}, te = (S) => {
|
|
370
|
+
if (S.sorter) {
|
|
371
|
+
const L = [...m.value].sort((T, j) => S.order === "ascend" ? T[S.columnKey] > j[S.columnKey] ? 1 : -1 : S.order === "descend" ? T[S.columnKey] < j[S.columnKey] ? 1 : -1 : 0);
|
|
372
|
+
m.value = L;
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
return
|
|
376
|
-
dataSource:
|
|
377
|
-
loading:
|
|
378
|
-
pagination:
|
|
379
|
-
handleExcelData:
|
|
380
|
-
handlePageChange:
|
|
381
|
-
handlePageSizeChange:
|
|
382
|
-
handleSortChange:
|
|
383
|
-
loadData:
|
|
375
|
+
return se(() => $ && o(h.value.page)), {
|
|
376
|
+
dataSource: m,
|
|
377
|
+
loading: v,
|
|
378
|
+
pagination: h,
|
|
379
|
+
handleExcelData: b,
|
|
380
|
+
handlePageChange: C,
|
|
381
|
+
handlePageSizeChange: I,
|
|
382
|
+
handleSortChange: te,
|
|
383
|
+
loadData: o
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function oe(t) {
|
|
387
|
+
return pe() ? (ge(t), !0) : !1;
|
|
388
|
+
}
|
|
389
|
+
const ne = /* @__PURE__ */ new WeakMap(), Ce = (...t) => {
|
|
390
|
+
var s;
|
|
391
|
+
const l = t[0], f = (s = ie()) == null ? void 0 : s.proxy;
|
|
392
|
+
if (f == null && !he())
|
|
393
|
+
throw new Error("injectLocal must be called in setup");
|
|
394
|
+
return f && ne.has(f) && l in ne.get(f) ? ne.get(f)[l] : de(...t);
|
|
395
|
+
}, Le = typeof window < "u" && typeof document < "u";
|
|
396
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
397
|
+
const ke = Object.prototype.toString, je = (t) => ke.call(t) === "[object Object]", He = () => {
|
|
398
|
+
};
|
|
399
|
+
function ce(t) {
|
|
400
|
+
return t.endsWith("rem") ? Number.parseFloat(t) * 16 : Number.parseFloat(t);
|
|
401
|
+
}
|
|
402
|
+
function Ie(t) {
|
|
403
|
+
return ie();
|
|
404
|
+
}
|
|
405
|
+
function re(t) {
|
|
406
|
+
return Array.isArray(t) ? t : [t];
|
|
407
|
+
}
|
|
408
|
+
function fe(t, s = !0, l) {
|
|
409
|
+
Ie() ? se(t, l) : s ? t() : me(t);
|
|
410
|
+
}
|
|
411
|
+
const J = Le ? window : void 0;
|
|
412
|
+
function Y(t) {
|
|
413
|
+
var s;
|
|
414
|
+
const l = q(t);
|
|
415
|
+
return (s = l == null ? void 0 : l.$el) != null ? s : l;
|
|
416
|
+
}
|
|
417
|
+
function le(...t) {
|
|
418
|
+
let s, l, f, g;
|
|
419
|
+
if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([l, f, g] = t, s = J) : [s, l, f, g] = t, !s)
|
|
420
|
+
return He;
|
|
421
|
+
l = re(l), f = re(f);
|
|
422
|
+
const $ = [], d = () => {
|
|
423
|
+
$.forEach((M) => M()), $.length = 0;
|
|
424
|
+
}, v = (M, o, p, b) => (M.addEventListener(o, p, b), () => M.removeEventListener(o, p, b)), h = ee(
|
|
425
|
+
() => [Y(s), q(g)],
|
|
426
|
+
([M, o]) => {
|
|
427
|
+
if (d(), !M)
|
|
428
|
+
return;
|
|
429
|
+
const p = je(o) ? { ...o } : o;
|
|
430
|
+
$.push(
|
|
431
|
+
...l.flatMap((b) => f.map((D) => v(M, b, D, p)))
|
|
432
|
+
);
|
|
433
|
+
},
|
|
434
|
+
{ immediate: !0, flush: "post" }
|
|
435
|
+
), m = () => {
|
|
436
|
+
h(), d();
|
|
437
|
+
};
|
|
438
|
+
return oe(m), m;
|
|
439
|
+
}
|
|
440
|
+
function ze() {
|
|
441
|
+
const t = H(!1), s = ie();
|
|
442
|
+
return s && se(() => {
|
|
443
|
+
t.value = !0;
|
|
444
|
+
}, s), t;
|
|
445
|
+
}
|
|
446
|
+
function ve(t) {
|
|
447
|
+
const s = ze();
|
|
448
|
+
return V(() => (s.value, !!t()));
|
|
449
|
+
}
|
|
450
|
+
const Te = Symbol("vueuse-ssr-width");
|
|
451
|
+
function Ae() {
|
|
452
|
+
const t = he() ? Ce(Te, null) : null;
|
|
453
|
+
return typeof t == "number" ? t : void 0;
|
|
454
|
+
}
|
|
455
|
+
function Re(t, s = {}) {
|
|
456
|
+
const { window: l = J, ssrWidth: f = Ae() } = s, g = ve(() => l && "matchMedia" in l && typeof l.matchMedia == "function"), $ = H(typeof f == "number");
|
|
457
|
+
let d;
|
|
458
|
+
const v = H(!1), h = (o) => {
|
|
459
|
+
v.value = o.matches;
|
|
460
|
+
}, m = () => {
|
|
461
|
+
d && ("removeEventListener" in d ? d.removeEventListener("change", h) : d.removeListener(h));
|
|
462
|
+
}, M = we(() => {
|
|
463
|
+
if ($.value) {
|
|
464
|
+
$.value = !g.value;
|
|
465
|
+
const o = q(t).split(",");
|
|
466
|
+
v.value = o.some((p) => {
|
|
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;
|
|
470
|
+
});
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
g.value && (m(), d = l.matchMedia(q(t)), "addEventListener" in d ? d.addEventListener("change", h) : d.addListener(h), v.value = d.matches);
|
|
474
|
+
});
|
|
475
|
+
return oe(() => {
|
|
476
|
+
M(), m(), d = void 0;
|
|
477
|
+
}), V(() => v.value);
|
|
478
|
+
}
|
|
479
|
+
function Ne(t, s, l = {}) {
|
|
480
|
+
const { window: f = J, ...g } = l;
|
|
481
|
+
let $;
|
|
482
|
+
const d = ve(() => f && "ResizeObserver" in f), v = () => {
|
|
483
|
+
$ && ($.disconnect(), $ = void 0);
|
|
484
|
+
}, h = V(() => {
|
|
485
|
+
const o = q(t);
|
|
486
|
+
return Array.isArray(o) ? o.map((p) => Y(p)) : [Y(o)];
|
|
487
|
+
}), m = ee(
|
|
488
|
+
h,
|
|
489
|
+
(o) => {
|
|
490
|
+
if (v(), d.value && f) {
|
|
491
|
+
$ = new ResizeObserver(s);
|
|
492
|
+
for (const p of o)
|
|
493
|
+
p && $.observe(p, g);
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{ immediate: !0, flush: "post" }
|
|
497
|
+
), M = () => {
|
|
498
|
+
v(), m();
|
|
499
|
+
};
|
|
500
|
+
return oe(M), {
|
|
501
|
+
isSupported: d,
|
|
502
|
+
stop: M
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function Ye(t, s = { width: 0, height: 0 }, l = {}) {
|
|
506
|
+
const { window: f = J, box: g = "content-box" } = l, $ = V(() => {
|
|
507
|
+
var o, p;
|
|
508
|
+
return (p = (o = Y(t)) == null ? void 0 : o.namespaceURI) == null ? void 0 : p.includes("svg");
|
|
509
|
+
}), d = H(s.width), v = H(s.height), { stop: h } = Ne(
|
|
510
|
+
t,
|
|
511
|
+
([o]) => {
|
|
512
|
+
const p = g === "border-box" ? o.borderBoxSize : g === "content-box" ? o.contentBoxSize : o.devicePixelContentBoxSize;
|
|
513
|
+
if (f && $.value) {
|
|
514
|
+
const b = Y(t);
|
|
515
|
+
if (b) {
|
|
516
|
+
const D = b.getBoundingClientRect();
|
|
517
|
+
d.value = D.width, v.value = D.height;
|
|
518
|
+
}
|
|
519
|
+
} else if (p) {
|
|
520
|
+
const b = re(p);
|
|
521
|
+
d.value = b.reduce((D, { inlineSize: C }) => D + C, 0), v.value = b.reduce((D, { blockSize: C }) => D + C, 0);
|
|
522
|
+
} else
|
|
523
|
+
d.value = o.contentRect.width, v.value = o.contentRect.height;
|
|
524
|
+
},
|
|
525
|
+
l
|
|
526
|
+
);
|
|
527
|
+
fe(() => {
|
|
528
|
+
const o = Y(t);
|
|
529
|
+
o && (d.value = "offsetWidth" in o ? o.offsetWidth : s.width, v.value = "offsetHeight" in o ? o.offsetHeight : s.height);
|
|
530
|
+
});
|
|
531
|
+
const m = ee(
|
|
532
|
+
() => Y(t),
|
|
533
|
+
(o) => {
|
|
534
|
+
d.value = o ? s.width : 0, v.value = o ? s.height : 0;
|
|
535
|
+
}
|
|
536
|
+
);
|
|
537
|
+
function M() {
|
|
538
|
+
h(), m();
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
width: d,
|
|
542
|
+
height: v,
|
|
543
|
+
stop: M
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function Ve(t = {}) {
|
|
547
|
+
const {
|
|
548
|
+
window: s = J,
|
|
549
|
+
initialWidth: l = Number.POSITIVE_INFINITY,
|
|
550
|
+
initialHeight: f = Number.POSITIVE_INFINITY,
|
|
551
|
+
listenOrientation: g = !0,
|
|
552
|
+
includeScrollbar: $ = !0,
|
|
553
|
+
type: d = "inner"
|
|
554
|
+
} = t, v = H(l), h = H(f), m = () => {
|
|
555
|
+
if (s)
|
|
556
|
+
if (d === "outer")
|
|
557
|
+
v.value = s.outerWidth, h.value = s.outerHeight;
|
|
558
|
+
else if (d === "visual" && s.visualViewport) {
|
|
559
|
+
const { width: M, height: o, scale: p } = s.visualViewport;
|
|
560
|
+
v.value = Math.round(M * p), h.value = Math.round(o * p);
|
|
561
|
+
} else $ ? (v.value = s.innerWidth, h.value = s.innerHeight) : (v.value = s.document.documentElement.clientWidth, h.value = s.document.documentElement.clientHeight);
|
|
562
|
+
};
|
|
563
|
+
if (m(), fe(m), le("resize", m, { passive: !0 }), s && d === "visual" && s.visualViewport && le(s.visualViewport, "resize", m, { passive: !0 }), g) {
|
|
564
|
+
const M = Re("(orientation: portrait)");
|
|
565
|
+
ee(M, () => m());
|
|
566
|
+
}
|
|
567
|
+
return { width: v, height: h };
|
|
568
|
+
}
|
|
569
|
+
function Ue(t, s) {
|
|
570
|
+
if (!t) throw new Error("tableRef are required");
|
|
571
|
+
const l = V(() => {
|
|
572
|
+
var h;
|
|
573
|
+
return (h = t.value) == null ? void 0 : h.searchRef;
|
|
574
|
+
}), { height: f } = Ve(), { height: g } = Ye(l), { height: $ = 0, minHeight: d = 600 } = s || {};
|
|
575
|
+
return {
|
|
576
|
+
height: V(() => {
|
|
577
|
+
const h = f.value - g.value - $;
|
|
578
|
+
return h > d ? h : d;
|
|
579
|
+
})
|
|
384
580
|
};
|
|
385
581
|
}
|
|
386
582
|
export {
|
|
387
|
-
|
|
388
|
-
|
|
583
|
+
xe as useExportFile,
|
|
584
|
+
Pe as useList,
|
|
585
|
+
Ue as useTableHeight
|
|
389
586
|
};
|
package/dist/useList/index.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
height?: number;
|
|
3
|
+
minHeight?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* useTableHeight
|
|
7
|
+
*
|
|
8
|
+
* @description 计算表格高度
|
|
9
|
+
* @example const { height } = useTableHeight(tableRef, { height: 100, minHeight: 600 })
|
|
10
|
+
*
|
|
11
|
+
* @param tableRef - 表格元素引用
|
|
12
|
+
* @param options - 表格高度配置
|
|
13
|
+
* @param options.height - 表格之外的高度值
|
|
14
|
+
* @param options.minHeight - 表格的最小高度
|
|
15
|
+
* @returns { height } - 表格高度
|
|
16
|
+
*/
|
|
17
|
+
export declare function useTableHeight(tableRef: any, options?: Options): {
|
|
18
|
+
height: import('vue').ComputedRef<number>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|