@duxweb/dvha-core 0.1.12 → 0.1.14
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/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/overlay.cjs +1 -1
- package/dist/cjs/hooks/upload/local.cjs +1 -0
- package/dist/cjs/hooks/upload/s3.cjs +1 -0
- package/dist/cjs/hooks/upload.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/esm/components/auth/can.js +5 -4
- package/dist/esm/directive/permission.js +3 -2
- package/dist/esm/hooks/overlay.js +3 -2
- package/dist/esm/hooks/upload/local.js +31 -0
- package/dist/esm/hooks/upload/s3.js +72 -0
- package/dist/esm/hooks/upload.js +271 -0
- package/dist/esm/index.js +64 -58
- package/dist/esm/preset/dataProvider.js +67 -48
- package/dist/esm/provider/app.js +3 -2
- package/dist/types/hooks/data.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/theme.d.ts +0 -4
- package/dist/types/hooks/upload/index.d.ts +3 -0
- package/dist/types/hooks/upload/local.d.ts +2 -0
- package/dist/types/hooks/upload/s3.d.ts +12 -0
- package/dist/types/hooks/upload/types.d.ts +14 -0
- package/dist/types/hooks/upload.d.ts +141 -0
- package/dist/types/types/data.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),q=require("../../hooks/auth.cjs");require("@tanstack/vue-query");require("lodash-es");require("pinia");require("vue-router");require("@vueuse/core");require("@overlastic/vue");require("clsx");require("json-2-csv");const t=i.defineComponent({name:"DuxCan",props:{name:{type:String,required:!0},params:{type:Object}},setup(r,{slots:e}){const a=q.useCan();return()=>{var u,n;return a(r.name,r.params)?(u=e.default)==null?void 0:u.call(e):((n=e.fallback)==null?void 0:n.call(e))||null}}});exports.DuxCan=t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),q=require("../../hooks/auth.cjs");require("@tanstack/vue-query");require("lodash-es");require("pinia");require("vue-router");require("@vueuse/core");require("@overlastic/vue");require("clsx");require("json-2-csv");require("axios");const t=i.defineComponent({name:"DuxCan",props:{name:{type:String,required:!0},params:{type:Object}},setup(r,{slots:e}){const a=q.useCan();return()=>{var u,n;return a(r.name,r.params)?(u=e.default)==null?void 0:u.call(e):((n=e.fallback)==null?void 0:n.call(e))||null}}});exports.DuxCan=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../hooks/auth.cjs");require("vue");require("@tanstack/vue-query");require("lodash-es");require("pinia");require("vue-router");require("@vueuse/core");require("@overlastic/vue");require("clsx");require("json-2-csv");const n={mounted(e,u){var i;const{value:r}=u;if(!r)return;t.useCan()(r)||(i=e.parentElement)==null||i.removeChild(e)}};exports.permissionDirective=n;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../hooks/auth.cjs");require("vue");require("@tanstack/vue-query");require("lodash-es");require("pinia");require("vue-router");require("@vueuse/core");require("@overlastic/vue");require("clsx");require("json-2-csv");require("axios");const n={mounted(e,u){var i;const{value:r}=u;if(!r)return;t.useCan()(r)||(i=e.parentElement)==null||i.removeChild(e)}};exports.permissionDirective=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@overlastic/vue");require("vue");require("clsx");require("vue-router");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@overlastic/vue");require("vue");require("clsx");require("vue-router");const i=require("../components/overlay/overlay.cjs");require("pinia");require("lodash-es");require("@tanstack/vue-query");require("@vueuse/core");require("json-2-csv");require("axios");function t(){const e=u.useOverlayInject(i.DuxOverlay);return{show:r=>e(r)}}exports.useOverlay=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../data.cjs"),s=()=>{const d=o.useClient();return{upload(l,e){const c=e.query||{};let a=null;if(e.method==="PUT")Object.entries(e.params||{}).forEach(([r,t])=>{c[r]=t}),a=l;else{const r=new FormData;r.append("file",l),Object.entries(e.params||{}).forEach(([t,n])=>{r.append(t,n)}),a=r}return d.request({...e,query:c,method:e.method||"POST",payload:a,signal:e.signal,onUploadProgress:e.onUploadProgress})}}};exports.createLocalUploadDriver=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../data.cjs"),w=require("axios");function g(s){const h=P.useClient();return{async upload(a,t){var i,c,m,U;const o=await h.request({method:"GET",path:s.signPath,query:{name:a.name,size:a.size,mime:a.type,...t.params},signal:t.signal,onUploadProgress:t.onUploadProgress}),r=((i=s.signCallback)==null?void 0:i.call(s,o))||{uploadUrl:(c=o.data)==null?void 0:c.uploadUrl,url:(m=o.data)==null?void 0:m.url,params:(U=o.data)==null?void 0:U.params};if(!r.uploadUrl)throw new Error("Upload URL is required");if(!r.url)throw new Error("File URL is required");const u=t.method||"POST";let l=null;const p=t.headers||{};if(u==="PUT")l=a,p["Content-Type"]=a.type||"application/octet-stream";else{const e=new FormData;e.append("Content-Type",a.type||"application/octet-stream"),e.append("file",a),r.params&&Object.entries(r.params).forEach(([n,y])=>{e.append(n,String(y))}),l=e}const d=await w.request({method:u,url:r.uploadUrl,data:l,signal:t.signal,headers:p,onUploadProgress:e=>{if(t.onUploadProgress&&e.total){const n=Math.round(e.loaded*100/e.total);t.onUploadProgress({loaded:e.loaded,total:e.total,percent:n})}}});if(d.status<200||d.status>=300)throw new Error(`S3 upload failed: ${d.statusText}`);return{data:{url:r.url,filename:a.name,size:a.size,mime:a.type},message:"upload successful"}}}}exports.createS3UploadDriver=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@vueuse/core"),R=require("lodash-es"),u=require("vue"),V=require("./upload/local.cjs");function W(l){const v=u.ref(!1),i=u.ref([]),d=u.ref(-1),f=u.ref(new Map),A=l.driver||V.createLocalUploadDriver(),$=u.computed(()=>{const{onProgress:e,onDataCallback:n,onCancel:a,onComplete:t,maxFileSize:c,maxFileCount:o,accept:s,multiple:r,autoUpload:m,options:U,onSuccess:P,onError:F,method:X,driver:Y,...J}=l;return J}),I=u.computed(()=>l.method||"POST"),b=u.computed(()=>{const e=i.value.length,n=i.value.reduce((o,s)=>o+(s.filesize||0),0);let a=0,t=0;return i.value.forEach((o,s)=>{var r;s<d.value?a+=o.filesize||0:s===d.value&&(a+=((r=o.progress)==null?void 0:r.loaded)||0)}),n>0&&(t=Math.round(a/n*100)),{index:d.value>=0?d.value+1:0,totalFiles:e,currentFile:i.value[d.value],totalPercent:t,totalLoaded:a,totalSize:n}}),w=e=>{if(e===0)return"0 Bytes";const n=1024,a=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(n));return`${Number.parseFloat((e/n**t).toFixed(2))} ${a[t]}`},h=e=>{if(e===0)return"0 B/s";const n=1024,a=["B/s","KB/s","MB/s","GB/s"],t=Math.floor(Math.log(e)/Math.log(n));return`${Number.parseFloat((e/n**t).toFixed(2))} ${a[t]}`},x=()=>R.uniqueId("upload-"),k=async(e,n,a)=>{switch(n){case"file":{if(!(e instanceof File))throw new TypeError('Payload must be a File when type is "file"');return e}case"blob":{if(!(e instanceof Blob))throw new TypeError('Payload must be a Blob when type is "blob"');return new File([e],"blob-file",{type:e.type})}case"base64":{if(typeof e!="string")throw new TypeError('Payload must be a string when type is "base64"');const t=e.includes(",")?e.split(",")[1]:e,c=e.includes(",")?e.split(",")[0].split(":")[1].split(";")[0]:"application/octet-stream",o=atob(t),s=new Uint8Array(o.length);for(let m=0;m<o.length;m++)s[m]=o.charCodeAt(m);const r=new Blob([s],{type:c});return new File([r],"base64-file",{type:c})}case"arrayBuffer":{if(!(e instanceof ArrayBuffer))throw new TypeError('Payload must be ArrayBuffer when type is "arrayBuffer"');const t=new Blob([e]);return new File([t],"array-buffer-file",{type:"application/octet-stream"})}default:throw new Error(`Unsupported upload type: ${n}`)}},T=e=>{if(l.maxFileSize&&e.size>l.maxFileSize)throw new Error(`File size cannot exceed ${w(l.maxFileSize)}`);if(l.maxFileCount&&i.value.length>=l.maxFileCount)throw new Error(`File count cannot exceed ${l.maxFileCount}`)},q=async(e,n,a)=>{const t=await k(e,n);T(t);const c={id:x(),file:t,filename:t.name,filesize:t.size,filetype:t.type,filesizeText:w(t.size),status:"pending",progress:{loaded:0,total:t.size,percent:0,speed:0,speedText:h(0),remainingTime:0,uploadTime:0}};return i.value.push(c),c},g=(e,n)=>{const a=i.value.findIndex(t=>t.id===e);a!==-1&&(i.value[a]={...i.value[a],...n})},z=()=>{var n;i.value.every(a=>a.status!=="uploading")&&((n=l.onComplete)==null||n.call(l,i.value))},y=e=>{var a;const n=i.value.find(t=>t.id===e);if(!n||n.status!=="pending"&&n.status!=="uploading")return!1;if(n.status==="uploading"){const t=f.value.get(e);t&&(t.abort(),f.value.delete(e))}return g(e,{status:"cancelled"}),(a=l.onCancel)==null||a.call(l,e),z(),!0},D=e=>{e?e.forEach(n=>y(n)):i.value.forEach(n=>y(n.id))},G=async e=>{if(!e.file)throw new Error("File not found");T(e.file);const n=new AbortController;f.value.set(e.id,n);const a=Date.now();g(e.id,{status:"uploading"}),await A.upload(e.file,{...$.value,method:I.value,signal:n.signal,onUploadProgress:t=>{var F;const s=(Date.now()-a)/1e3,r=s>0?t.loaded/s:0,m=(t.total||0)-t.loaded,U=r>0?m/r:0,P={loaded:t.loaded,total:t.total,percent:t.percent||0,speed:Math.round(r),speedText:h(r),uploadTime:Math.round(s),remainingTime:Math.round(U)};g(e.id,{status:"uploading",progress:P}),(F=l.onProgress)==null||F.call(l,b.value)}}).then(t=>{var s,r;if(e.status==="cancelled")return;const c=((s=l.onDataCallback)==null?void 0:s.call(l,t,e))||{},o=Math.round((Date.now()-a)/1e3);g(e.id,{status:"success",data:t,...c,progress:{...e.progress,loaded:e.filesize||0,percent:100,speed:0,speedText:h(0),uploadTime:o,remainingTime:0}}),f.value.delete(e.id),(r=l.onSuccess)==null||r.call(l,t)}).catch(t=>{if(!(t.message==="canceled"||e.status==="cancelled"))throw g(e.id,{status:"error",error:t.message}),f.value.delete(e.id),t}).finally(()=>{z()})},C=async()=>{var n;const e=i.value.filter(a=>a.status==="pending");if(e.length!==0){v.value=!0;try{for(let a=0;a<e.length;a++){const t=e[a],c=i.value.findIndex(o=>o.id===t.id);d.value=c,await G(t)}}catch(a){throw(n=l.onError)==null||n.call(l,{status:(a==null?void 0:a.status)||500,message:(a==null?void 0:a.message)||"upload failed"}),a}finally{v.value=!1,d.value=-1}}},B=async(e,n="file")=>{var a;try{if(l.multiple||E(),!l.multiple&&e.length>1)throw new Error("Single file mode: only one file can be selected");if(l.maxFileCount&&i.value.length+e.length>l.maxFileCount)throw new Error(`Adding ${e.length} files would exceed the maximum limit of ${l.maxFileCount}`);for(const t of e)await q(t,n)}catch(t){throw(a=l.onError)==null||a.call(l,{status:(t==null?void 0:t.status)||400,message:(t==null?void 0:t.message)||"Failed to add files"}),t}l.autoUpload&&C()},K=e=>{const n=e.map(a=>j(a));i.value.push(...n)},E=()=>{i.value.forEach(e=>{y(e.id)}),f.value.clear(),i.value=[],d.value=-1},M=e=>{const n=i.value.find(t=>t.id===e);if(n&&n.status==="uploading"){g(e,{status:"cancelled"});const t=f.value.get(e);if(!t)return;t.abort(),f.value.delete(e)}const a=i.value.findIndex(t=>t.id===e);a!==-1&&i.value.splice(a,1)},L=e=>{e?e.forEach(n=>M(n)):i.value.forEach(n=>M(n.id))},{files:N,open:O,reset:S}=Q.useFileDialog({accept:l.accept,multiple:l.multiple||!1}),j=e=>({id:x(),...e,filesizeText:e.filesize?w(e.filesize):void 0,status:e.url?"success":"pending",progress:{loaded:0,total:e.filesize||0,percent:e.url?100:0,speed:0,speedText:h(0),remainingTime:0,uploadTime:0}});u.watch(N,async e=>{if(e&&e.length>0){const n=Array.from(e);S(),await B(n,"file").catch(a=>{console.warn("Failed to add selected files:",a)})}});const H=u.computed(()=>i.value.filter(e=>e.status==="success").map(e=>({url:e.url,filename:e.filename,filesize:e.filesize,filetype:e.filetype})));return{isUploading:v,uploadFiles:i,dataFiles:H,progress:b,open:O,trigger:C,resetFiles:S,clearFiles:E,removeFiles:L,addFiles:B,addDataFiles:K,cancelFiles:D}}exports.useUpload=W;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./main.cjs"),r=require("./hooks/auth.cjs"),t=require("./hooks/config.cjs"),e=require("./hooks/data.cjs"),o=require("./hooks/manage.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./main.cjs"),r=require("./hooks/auth.cjs"),t=require("./hooks/config.cjs"),e=require("./hooks/data.cjs"),o=require("./hooks/manage.cjs"),a=require("./hooks/menu.cjs"),i=require("./hooks/theme.cjs"),n=require("./hooks/overlay.cjs"),c=require("./hooks/i18n.cjs"),l=require("./hooks/select.cjs"),p=require("./hooks/form.cjs"),d=require("./hooks/export.cjs"),q=require("./hooks/import.cjs"),v=require("./hooks/exportCsv.cjs"),m=require("./hooks/importCsv.cjs"),g=require("./hooks/upload.cjs"),C=require("./hooks/upload/local.cjs"),D=require("./hooks/upload/s3.cjs"),x=require("./router/route.cjs"),y=require("./stores/auth.cjs"),M=require("./stores/route.cjs"),h=require("./stores/tab.cjs"),P=require("./stores/manage.cjs"),S=require("./stores/i18n.cjs"),I=require("./components/common/logo.cjs"),L=require("./components/loader/iframe.cjs"),T=require("./components/overlay/overlay.cjs"),U=require("./components/auth/can.cjs"),u=require("./utils/tree.cjs"),A=require("./provider/app.cjs"),f=require("./provider/tab.cjs"),b=require("./preset/authProvider.cjs"),R=require("./preset/dataProvider.cjs"),O=require("./preset/i18nProvider.cjs");exports.createDux=s.createDux;exports.useCan=r.useCan;exports.useCheck=r.useCheck;exports.useError=r.useError;exports.useForgotPassword=r.useForgotPassword;exports.useGetAuth=r.useGetAuth;exports.useIsLogin=r.useIsLogin;exports.useLogin=r.useLogin;exports.useLogout=r.useLogout;exports.useRegister=r.useRegister;exports.useUpdatePassword=r.useUpdatePassword;exports.useConfig=t.useConfig;exports.useClient=e.useClient;exports.useCreate=e.useCreate;exports.useCreateMany=e.useCreateMany;exports.useCustom=e.useCustom;exports.useCustomMutation=e.useCustomMutation;exports.useDelete=e.useDelete;exports.useDeleteMany=e.useDeleteMany;exports.useInfiniteList=e.useInfiniteList;exports.useInvalidate=e.useInvalidate;exports.useList=e.useList;exports.useMany=e.useMany;exports.useOne=e.useOne;exports.useUpdate=e.useUpdate;exports.useUpdateMany=e.useUpdateMany;exports.useManage=o.useManage;exports.useMenu=a.useMenu;exports.useTheme=i.useTheme;exports.useOverlay=n.useOverlay;exports.useI18n=c.useI18n;exports.useSelect=l.useSelect;exports.useForm=p.useForm;exports.useExport=d.useExport;exports.useImport=q.useImport;exports.useExportCsv=v.useExportCsv;exports.useImportCsv=m.useImportCsv;exports.useUpload=g.useUpload;exports.createLocalUploadDriver=C.createLocalUploadDriver;exports.createS3UploadDriver=D.createS3UploadDriver;exports.initRouter=x.initRouter;exports.useAuthStore=y.useAuthStore;exports.useRouteStore=M.useRouteStore;exports.useTabStore=h.useTabStore;exports.useManageStore=P.useManageStore;exports.useI18nStore=S.useI18nStore;exports.DuxLogo=I.DuxLogo;exports.DuxLoaderIframe=L;exports.DuxOverlay=T.DuxOverlay;exports.DuxCan=U.DuxCan;exports.arrayToTree=u.arrayToTree;exports.searchTree=u.searchTree;exports.treeToArr=u.treeToArr;exports.DuxAppProvider=A.DuxAppProvider;exports.DuxTabRouterView=f.DuxTabRouterView;exports.simpleAuthProvider=b.simpleAuthProvider;exports.simpleDataProvider=R.simpleDataProvider;exports.i18nProvider=O.i18nProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("axios"),s=require("lodash-es");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("axios"),s=require("lodash-es");function h(c){const r=a=>a?`${c.apiUrl}/${s.trimStart(a||"","/")}`:c.apiUrl;return{apiUrl:r,getList:(a,d,l)=>{const e={};return a.pagination&&typeof a.pagination=="object"&&(e.page=a.pagination.page,e.pageSize=a.pagination.pageSize),n.get(r(a.path)||"",{params:{...e,...a.filters,...a.sorters},headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(t=>c.successCallback?c.successCallback(t):k(t)).catch(t=>{throw c.errorCallback?c.errorCallback(t):b(t)})},create:(a,d,l)=>n.post(r(a.path)||"",a.data,{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),update:(a,d,l)=>n.put(r(a.id?`${a.path}/${a.id}`:a.path)||"",a.data,{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),deleteOne:(a,d,l)=>n.delete(r(a.id?`${a.path}/${a.id}`:a.path)||"",{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),getOne:(a,d,l)=>n.get(r(a.id?`${a.path}/${a.id}`:a.path)||"",{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),getMany:(a,d,l)=>n.get(r(a.path)||"",{params:{ids:a.ids},headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),createMany:(a,d,l)=>n.post(r(a.path)||"",a.data,{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),updateMany:(a,d,l)=>n.put(r(a.path)||"",{ids:a.ids,data:a.data},{headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),deleteMany:(a,d,l)=>n.delete(r(a.path)||"",{params:{ids:a.ids},headers:{Authorization:l==null?void 0:l.token},...a.meta}).then(e=>c.successCallback?c.successCallback(e):k(e)).catch(e=>{throw c.errorCallback?c.errorCallback(e):b(e)}),custom:(a,d,l)=>{let e={...a.query};return a.sorters&&typeof a.sorters=="object"&&(e={...e,...a.sorters}),a.filters&&typeof a.filters=="object"&&(e={...e,...a.filters}),n.request({url:r(a.path||""),method:a.method||"GET",data:a.payload,params:e,signal:a.signal,headers:{Authorization:l==null?void 0:l.token,...a.headers},onUploadProgress:t=>{var m;const C=Math.round(t.loaded*100/(t.total||1));(m=a.onUploadProgress)==null||m.call(a,{loaded:t.loaded,total:t.total,percent:C})},onDownloadProgress:t=>{var m;const C=Math.round(t.loaded*100/(t.total||1));(m=a.onDownloadProgress)==null||m.call(a,{loaded:t.loaded,total:t.total,percent:C})},...a.meta}).then(t=>c.successCallback?c.successCallback(t):k(t)).catch(t=>{throw c.errorCallback?c.errorCallback(t):b(t)})}}}function k(c){var r,a,d;return{message:(r=c.data)==null?void 0:r.message,data:(a=c.data)==null?void 0:a.data,meta:(d=c.data)==null?void 0:d.meta,raw:c.data}}function b(c){var r,a,d,l,e,t,C,m,u,g;return{message:((a=(r=c.response)==null?void 0:r.data)==null?void 0:a.message)||(c==null?void 0:c.message),data:(l=(d=c.response)==null?void 0:d.data)==null?void 0:l.data,meta:(t=(e=c.response)==null?void 0:e.data)==null?void 0:t.meta,status:((m=(C=c.response)==null?void 0:C.data)==null?void 0:m.code)||((u=c.response)==null?void 0:u.status)||500,raw:(g=c.response)==null?void 0:g.data}}exports.simpleDataProvider=h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("vue"),U=require("@overlastic/vue"),V=require("vue-router"),B=require("../hooks/auth.cjs"),G=require("../hooks/config.cjs");require("@tanstack/vue-query");const H=require("../hooks/manage.cjs");require("lodash-es");require("pinia");const J=require("../stores/auth.cjs"),K=require("../stores/route.cjs"),Q=require("../stores/manage.cjs"),W=require("../stores/i18n.cjs");require("@vueuse/core");require("clsx");require("json-2-csv");const p=l=>Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"})),X=h.defineComponent({name:"DuxAppProvider",props:{},setup(l,{slots:f}){const m=h.inject("dux.manage"),s=G.useConfig(),d=V.useRouter();return d.beforeEach(async(n,Y,a)=>{var $,S,R,A,M,y,_,k,z,w,D,I,O,j;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("vue"),U=require("@overlastic/vue"),V=require("vue-router"),B=require("../hooks/auth.cjs"),G=require("../hooks/config.cjs");require("@tanstack/vue-query");const H=require("../hooks/manage.cjs");require("lodash-es");require("pinia");const J=require("../stores/auth.cjs"),K=require("../stores/route.cjs"),Q=require("../stores/manage.cjs"),W=require("../stores/i18n.cjs");require("@vueuse/core");require("clsx");require("json-2-csv");require("axios");const p=l=>Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"})),X=h.defineComponent({name:"DuxAppProvider",props:{},setup(l,{slots:f}){const m=h.inject("dux.manage"),s=G.useConfig(),d=V.useRouter();return d.beforeEach(async(n,Y,a)=>{var $,S,R,A,M,y,_,k,z,w,D,I,O,j;const r=n.meta.manageName,L=n.meta.authorization===!1;if(!r){const e=s.defaultManage||((S=($=s.manages)==null?void 0:$[0])==null?void 0:S.name)||"";return a({path:`/${e}`,replace:!0})}m&&(m.value=r);const g=Q.useManageStore(r);g.isInit()||g.setConfig((R=s.manages)==null?void 0:R.find(e=>e.name===r),s);const i=K.useRouteStore(r),o=H.useManage(r),q=J.useAuthStore(r),v=W.useI18nStore(r);if((A=o.config)!=null&&A.i18nProvider&&!v.isInit()){const e=v.getLocale();e&&((M=o.config)==null||M.i18nProvider.changeLocale(e))}if(!q.isLogin())return L?a():a({path:o.getRoutePath("login"),replace:!0});const P=e=>e==null?void 0:e.map(u=>({...u,path:o.getRoutePath(u.path||"")}));if(!i.getRouteInit()){const e=((y=o.config)==null?void 0:y.components)||{},u=[];if(u.push({name:`${r}.notFound`,label:"404",path:":pathMatch(.*)*",component:e.notFound||(()=>Promise.resolve().then(()=>p(require("../components/status/notFound.cjs")))),hidden:!0,meta:{can:!1}}),u.push({name:`${r}.notAuthorized`,label:"403",path:"notAuthorized",component:e.notAuthorized||(()=>Promise.resolve().then(()=>p(require("../components/status/notAuthorized.cjs")))),hidden:!0,meta:{can:!1}}),u.push({name:`${r}.error`,label:"500",path:"error",component:e.error||(()=>Promise.resolve().then(()=>p(require("../components/status/error.cjs")))),hidden:!0,meta:{can:!1}}),i.setRoutes(P(((_=o.config)==null?void 0:_.menus)||[])),(k=o.config)!=null&&k.apiRoutePath)try{await((D=(w=(z=o.config)==null?void 0:z.dataProvider)==null?void 0:w.default)==null?void 0:D.custom({path:o.config.apiRoutePath,meta:{timeout:5e3}},o,q.getUser()).then(t=>{i.appendRoutes(P(t.data||[]))}))}catch(t){console.error(t)}return i.appendRoutes(u),i.getRoutes().forEach(t=>{var C,N;if(!t.path)return;const c={name:t.name,path:t.path,meta:t.meta};switch(t.loader){case"iframe":c.component=((N=(C=o.config)==null?void 0:C.components)==null?void 0:N.iframe)||(()=>Promise.resolve().then(()=>p(require("../components/loader/iframe.cjs"))));break;case"link":c.beforeEnter=()=>{var F;const E=((F=t.meta)==null?void 0:F.url)||t.path;return E&&window.open(E,"_blank"),!1},c.component=()=>Promise.resolve({template:"<div></div>"});break;default:t.component&&(c.component=t.component);break}d.addRoute(`${r}.auth`,c)}),a({path:((I=n.redirectedFrom)==null?void 0:I.path)||n.path,replace:!0})}const b=["","/",`/${r}`,`/${r}/`];if(b.includes(n.path)){const e=i.getIndexRoute();return!(e!=null&&e.path)||b.includes(e==null?void 0:e.path)?(console.warn("[Dux] index route not found, skip redirect"),a()):a({path:(e==null?void 0:e.path)||"/",replace:!0})}const T=B.useCan(r);return(((O=n.meta)==null?void 0:O.can)===void 0||((j=n.meta)==null?void 0:j.can)===!0)&&!T(n.name)?a({name:`${r}.notAuthorized`}):a()}),()=>h.createVNode(U.OverlaysProvider,null,{default:()=>{var n;return[(n=f.default)==null?void 0:n.call(f)]}})}});exports.DuxAppProvider=X;
|
|
@@ -8,7 +8,8 @@ import "@vueuse/core";
|
|
|
8
8
|
import "@overlastic/vue";
|
|
9
9
|
import "clsx";
|
|
10
10
|
import "json-2-csv";
|
|
11
|
-
|
|
11
|
+
import "axios";
|
|
12
|
+
const g = /* @__PURE__ */ a({
|
|
12
13
|
name: "DuxCan",
|
|
13
14
|
props: {
|
|
14
15
|
name: {
|
|
@@ -24,11 +25,11 @@ const D = /* @__PURE__ */ a({
|
|
|
24
25
|
}) {
|
|
25
26
|
const n = i();
|
|
26
27
|
return () => {
|
|
27
|
-
var
|
|
28
|
-
return n(m.name, m.params) ? (
|
|
28
|
+
var p, e;
|
|
29
|
+
return n(m.name, m.params) ? (p = r.default) == null ? void 0 : p.call(r) : ((e = r.fallback) == null ? void 0 : e.call(r)) || null;
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
export {
|
|
33
|
-
|
|
34
|
+
g as DuxCan
|
|
34
35
|
};
|
|
@@ -8,7 +8,8 @@ import "@vueuse/core";
|
|
|
8
8
|
import "@overlastic/vue";
|
|
9
9
|
import "clsx";
|
|
10
10
|
import "json-2-csv";
|
|
11
|
-
|
|
11
|
+
import "axios";
|
|
12
|
+
const h = {
|
|
12
13
|
mounted(t, i) {
|
|
13
14
|
var r;
|
|
14
15
|
const { value: o } = i;
|
|
@@ -18,5 +19,5 @@ const C = {
|
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
export {
|
|
21
|
-
|
|
22
|
+
h as permissionDirective
|
|
22
23
|
};
|
|
@@ -8,12 +8,13 @@ import "lodash-es";
|
|
|
8
8
|
import "@tanstack/vue-query";
|
|
9
9
|
import "@vueuse/core";
|
|
10
10
|
import "json-2-csv";
|
|
11
|
-
|
|
11
|
+
import "axios";
|
|
12
|
+
function O() {
|
|
12
13
|
const r = t(m);
|
|
13
14
|
return {
|
|
14
15
|
show: (o) => r(o)
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
+
O as useOverlay
|
|
19
20
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useClient as o } from "../data.js";
|
|
2
|
+
const m = () => {
|
|
3
|
+
const n = o();
|
|
4
|
+
return {
|
|
5
|
+
upload(l, e) {
|
|
6
|
+
const c = e.query || {};
|
|
7
|
+
let a = null;
|
|
8
|
+
if (e.method === "PUT")
|
|
9
|
+
Object.entries(e.params || {}).forEach(([r, t]) => {
|
|
10
|
+
c[r] = t;
|
|
11
|
+
}), a = l;
|
|
12
|
+
else {
|
|
13
|
+
const r = new FormData();
|
|
14
|
+
r.append("file", l), Object.entries(e.params || {}).forEach(([t, d]) => {
|
|
15
|
+
r.append(t, d);
|
|
16
|
+
}), a = r;
|
|
17
|
+
}
|
|
18
|
+
return n.request({
|
|
19
|
+
...e,
|
|
20
|
+
query: c,
|
|
21
|
+
method: e.method || "POST",
|
|
22
|
+
payload: a,
|
|
23
|
+
signal: e.signal,
|
|
24
|
+
onUploadProgress: e.onUploadProgress
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
m as createLocalUploadDriver
|
|
31
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useClient as y } from "../data.js";
|
|
2
|
+
import P from "axios";
|
|
3
|
+
function q(s) {
|
|
4
|
+
const h = y();
|
|
5
|
+
return {
|
|
6
|
+
async upload(a, t) {
|
|
7
|
+
var m, i, c, U;
|
|
8
|
+
const o = await h.request({
|
|
9
|
+
method: "GET",
|
|
10
|
+
path: s.signPath,
|
|
11
|
+
query: {
|
|
12
|
+
name: a.name,
|
|
13
|
+
size: a.size,
|
|
14
|
+
mime: a.type,
|
|
15
|
+
...t.params
|
|
16
|
+
},
|
|
17
|
+
signal: t.signal,
|
|
18
|
+
onUploadProgress: t.onUploadProgress
|
|
19
|
+
}), r = ((m = s.signCallback) == null ? void 0 : m.call(s, o)) || {
|
|
20
|
+
uploadUrl: (i = o.data) == null ? void 0 : i.uploadUrl,
|
|
21
|
+
url: (c = o.data) == null ? void 0 : c.url,
|
|
22
|
+
params: (U = o.data) == null ? void 0 : U.params
|
|
23
|
+
};
|
|
24
|
+
if (!r.uploadUrl)
|
|
25
|
+
throw new Error("Upload URL is required");
|
|
26
|
+
if (!r.url)
|
|
27
|
+
throw new Error("File URL is required");
|
|
28
|
+
const p = t.method || "POST";
|
|
29
|
+
let l = null;
|
|
30
|
+
const u = t.headers || {};
|
|
31
|
+
if (p === "PUT")
|
|
32
|
+
l = a, u["Content-Type"] = a.type || "application/octet-stream";
|
|
33
|
+
else {
|
|
34
|
+
const e = new FormData();
|
|
35
|
+
e.append("Content-Type", a.type || "application/octet-stream"), e.append("file", a), r.params && Object.entries(r.params).forEach(([n, w]) => {
|
|
36
|
+
e.append(n, String(w));
|
|
37
|
+
}), l = e;
|
|
38
|
+
}
|
|
39
|
+
const d = await P.request({
|
|
40
|
+
method: p,
|
|
41
|
+
url: r.uploadUrl,
|
|
42
|
+
data: l,
|
|
43
|
+
signal: t.signal,
|
|
44
|
+
headers: u,
|
|
45
|
+
onUploadProgress: (e) => {
|
|
46
|
+
if (t.onUploadProgress && e.total) {
|
|
47
|
+
const n = Math.round(e.loaded * 100 / e.total);
|
|
48
|
+
t.onUploadProgress({
|
|
49
|
+
loaded: e.loaded,
|
|
50
|
+
total: e.total,
|
|
51
|
+
percent: n
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (d.status < 200 || d.status >= 300)
|
|
57
|
+
throw new Error(`S3 upload failed: ${d.statusText}`);
|
|
58
|
+
return {
|
|
59
|
+
data: {
|
|
60
|
+
url: r.url,
|
|
61
|
+
filename: a.name,
|
|
62
|
+
size: a.size,
|
|
63
|
+
mime: a.type
|
|
64
|
+
},
|
|
65
|
+
message: "upload successful"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
q as createS3UploadDriver
|
|
72
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { useFileDialog as R } from "@vueuse/core";
|
|
2
|
+
import { uniqueId as V } from "lodash-es";
|
|
3
|
+
import { ref as g, computed as v, watch as W } from "vue";
|
|
4
|
+
import { createLocalUploadDriver as X } from "./upload/local.js";
|
|
5
|
+
function ne(l) {
|
|
6
|
+
const w = g(!1), i = g([]), u = g(-1), d = g(/* @__PURE__ */ new Map()), $ = l.driver || X(), I = v(() => {
|
|
7
|
+
const { onProgress: e, onDataCallback: n, onCancel: a, onComplete: t, maxFileSize: c, maxFileCount: s, accept: o, multiple: r, autoUpload: f, options: P, onSuccess: A, onError: x, method: Y, driver: Z, ...Q } = l;
|
|
8
|
+
return Q;
|
|
9
|
+
}), k = v(() => l.method || "POST"), b = v(() => {
|
|
10
|
+
const e = i.value.length, n = i.value.reduce((s, o) => s + (o.filesize || 0), 0);
|
|
11
|
+
let a = 0, t = 0;
|
|
12
|
+
return i.value.forEach((s, o) => {
|
|
13
|
+
var r;
|
|
14
|
+
o < u.value ? a += s.filesize || 0 : o === u.value && (a += ((r = s.progress) == null ? void 0 : r.loaded) || 0);
|
|
15
|
+
}), n > 0 && (t = Math.round(a / n * 100)), {
|
|
16
|
+
index: u.value >= 0 ? u.value + 1 : 0,
|
|
17
|
+
totalFiles: e,
|
|
18
|
+
currentFile: i.value[u.value],
|
|
19
|
+
totalPercent: t,
|
|
20
|
+
totalLoaded: a,
|
|
21
|
+
totalSize: n
|
|
22
|
+
};
|
|
23
|
+
}), y = (e) => {
|
|
24
|
+
if (e === 0)
|
|
25
|
+
return "0 Bytes";
|
|
26
|
+
const n = 1024, a = ["Bytes", "KB", "MB", "GB"], t = Math.floor(Math.log(e) / Math.log(n));
|
|
27
|
+
return `${Number.parseFloat((e / n ** t).toFixed(2))} ${a[t]}`;
|
|
28
|
+
}, h = (e) => {
|
|
29
|
+
if (e === 0)
|
|
30
|
+
return "0 B/s";
|
|
31
|
+
const n = 1024, a = ["B/s", "KB/s", "MB/s", "GB/s"], t = Math.floor(Math.log(e) / Math.log(n));
|
|
32
|
+
return `${Number.parseFloat((e / n ** t).toFixed(2))} ${a[t]}`;
|
|
33
|
+
}, T = () => V("upload-"), D = async (e, n, a) => {
|
|
34
|
+
switch (n) {
|
|
35
|
+
case "file": {
|
|
36
|
+
if (!(e instanceof File))
|
|
37
|
+
throw new TypeError('Payload must be a File when type is "file"');
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
case "blob": {
|
|
41
|
+
if (!(e instanceof Blob))
|
|
42
|
+
throw new TypeError('Payload must be a Blob when type is "blob"');
|
|
43
|
+
return new File([e], "blob-file", { type: e.type });
|
|
44
|
+
}
|
|
45
|
+
case "base64": {
|
|
46
|
+
if (typeof e != "string")
|
|
47
|
+
throw new TypeError('Payload must be a string when type is "base64"');
|
|
48
|
+
const t = e.includes(",") ? e.split(",")[1] : e, c = e.includes(",") ? e.split(",")[0].split(":")[1].split(";")[0] : "application/octet-stream", s = atob(t), o = new Uint8Array(s.length);
|
|
49
|
+
for (let f = 0; f < s.length; f++)
|
|
50
|
+
o[f] = s.charCodeAt(f);
|
|
51
|
+
const r = new Blob([o], { type: c });
|
|
52
|
+
return new File([r], "base64-file", { type: c });
|
|
53
|
+
}
|
|
54
|
+
case "arrayBuffer": {
|
|
55
|
+
if (!(e instanceof ArrayBuffer))
|
|
56
|
+
throw new TypeError('Payload must be ArrayBuffer when type is "arrayBuffer"');
|
|
57
|
+
const t = new Blob([e]);
|
|
58
|
+
return new File([t], "array-buffer-file", { type: "application/octet-stream" });
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`Unsupported upload type: ${n}`);
|
|
62
|
+
}
|
|
63
|
+
}, z = (e) => {
|
|
64
|
+
if (l.maxFileSize && e.size > l.maxFileSize)
|
|
65
|
+
throw new Error(`File size cannot exceed ${y(l.maxFileSize)}`);
|
|
66
|
+
if (l.maxFileCount && i.value.length >= l.maxFileCount)
|
|
67
|
+
throw new Error(`File count cannot exceed ${l.maxFileCount}`);
|
|
68
|
+
}, G = async (e, n, a) => {
|
|
69
|
+
const t = await D(e, n);
|
|
70
|
+
z(t);
|
|
71
|
+
const c = {
|
|
72
|
+
id: T(),
|
|
73
|
+
file: t,
|
|
74
|
+
filename: t.name,
|
|
75
|
+
filesize: t.size,
|
|
76
|
+
filetype: t.type,
|
|
77
|
+
filesizeText: y(t.size),
|
|
78
|
+
status: "pending",
|
|
79
|
+
progress: {
|
|
80
|
+
loaded: 0,
|
|
81
|
+
total: t.size,
|
|
82
|
+
percent: 0,
|
|
83
|
+
speed: 0,
|
|
84
|
+
speedText: h(0),
|
|
85
|
+
remainingTime: 0,
|
|
86
|
+
uploadTime: 0
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return i.value.push(c), c;
|
|
90
|
+
}, m = (e, n) => {
|
|
91
|
+
const a = i.value.findIndex((t) => t.id === e);
|
|
92
|
+
a !== -1 && (i.value[a] = { ...i.value[a], ...n });
|
|
93
|
+
}, C = () => {
|
|
94
|
+
var n;
|
|
95
|
+
i.value.every((a) => a.status !== "uploading") && ((n = l.onComplete) == null || n.call(l, i.value));
|
|
96
|
+
}, F = (e) => {
|
|
97
|
+
var a;
|
|
98
|
+
const n = i.value.find((t) => t.id === e);
|
|
99
|
+
if (!n || n.status !== "pending" && n.status !== "uploading")
|
|
100
|
+
return !1;
|
|
101
|
+
if (n.status === "uploading") {
|
|
102
|
+
const t = d.value.get(e);
|
|
103
|
+
t && (t.abort(), d.value.delete(e));
|
|
104
|
+
}
|
|
105
|
+
return m(e, {
|
|
106
|
+
status: "cancelled"
|
|
107
|
+
}), (a = l.onCancel) == null || a.call(l, e), C(), !0;
|
|
108
|
+
}, K = (e) => {
|
|
109
|
+
e ? e.forEach((n) => F(n)) : i.value.forEach((n) => F(n.id));
|
|
110
|
+
}, L = async (e) => {
|
|
111
|
+
if (!e.file)
|
|
112
|
+
throw new Error("File not found");
|
|
113
|
+
z(e.file);
|
|
114
|
+
const n = new AbortController();
|
|
115
|
+
d.value.set(e.id, n);
|
|
116
|
+
const a = Date.now();
|
|
117
|
+
m(e.id, { status: "uploading" }), await $.upload(e.file, {
|
|
118
|
+
...I.value,
|
|
119
|
+
method: k.value,
|
|
120
|
+
signal: n.signal,
|
|
121
|
+
onUploadProgress: (t) => {
|
|
122
|
+
var x;
|
|
123
|
+
const o = (Date.now() - a) / 1e3, r = o > 0 ? t.loaded / o : 0, f = (t.total || 0) - t.loaded, P = r > 0 ? f / r : 0, A = {
|
|
124
|
+
loaded: t.loaded,
|
|
125
|
+
total: t.total,
|
|
126
|
+
percent: t.percent || 0,
|
|
127
|
+
speed: Math.round(r),
|
|
128
|
+
speedText: h(r),
|
|
129
|
+
uploadTime: Math.round(o),
|
|
130
|
+
remainingTime: Math.round(P)
|
|
131
|
+
};
|
|
132
|
+
m(e.id, {
|
|
133
|
+
status: "uploading",
|
|
134
|
+
progress: A
|
|
135
|
+
}), (x = l.onProgress) == null || x.call(l, b.value);
|
|
136
|
+
}
|
|
137
|
+
}).then((t) => {
|
|
138
|
+
var o, r;
|
|
139
|
+
if (e.status === "cancelled")
|
|
140
|
+
return;
|
|
141
|
+
const c = ((o = l.onDataCallback) == null ? void 0 : o.call(l, t, e)) || {}, s = Math.round((Date.now() - a) / 1e3);
|
|
142
|
+
m(e.id, {
|
|
143
|
+
status: "success",
|
|
144
|
+
data: t,
|
|
145
|
+
...c,
|
|
146
|
+
progress: {
|
|
147
|
+
...e.progress,
|
|
148
|
+
loaded: e.filesize || 0,
|
|
149
|
+
percent: 100,
|
|
150
|
+
speed: 0,
|
|
151
|
+
speedText: h(0),
|
|
152
|
+
uploadTime: s,
|
|
153
|
+
remainingTime: 0
|
|
154
|
+
}
|
|
155
|
+
}), d.value.delete(e.id), (r = l.onSuccess) == null || r.call(l, t);
|
|
156
|
+
}).catch((t) => {
|
|
157
|
+
if (!(t.message === "canceled" || e.status === "cancelled"))
|
|
158
|
+
throw m(e.id, {
|
|
159
|
+
status: "error",
|
|
160
|
+
error: t.message
|
|
161
|
+
}), d.value.delete(e.id), t;
|
|
162
|
+
}).finally(() => {
|
|
163
|
+
C();
|
|
164
|
+
});
|
|
165
|
+
}, B = async () => {
|
|
166
|
+
var n;
|
|
167
|
+
const e = i.value.filter((a) => a.status === "pending");
|
|
168
|
+
if (e.length !== 0) {
|
|
169
|
+
w.value = !0;
|
|
170
|
+
try {
|
|
171
|
+
for (let a = 0; a < e.length; a++) {
|
|
172
|
+
const t = e[a], c = i.value.findIndex((s) => s.id === t.id);
|
|
173
|
+
u.value = c, await L(t);
|
|
174
|
+
}
|
|
175
|
+
} catch (a) {
|
|
176
|
+
throw (n = l.onError) == null || n.call(l, {
|
|
177
|
+
status: (a == null ? void 0 : a.status) || 500,
|
|
178
|
+
message: (a == null ? void 0 : a.message) || "upload failed"
|
|
179
|
+
}), a;
|
|
180
|
+
} finally {
|
|
181
|
+
w.value = !1, u.value = -1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}, E = async (e, n = "file") => {
|
|
185
|
+
var a;
|
|
186
|
+
try {
|
|
187
|
+
if (l.multiple || M(), !l.multiple && e.length > 1)
|
|
188
|
+
throw new Error("Single file mode: only one file can be selected");
|
|
189
|
+
if (l.maxFileCount && i.value.length + e.length > l.maxFileCount)
|
|
190
|
+
throw new Error(`Adding ${e.length} files would exceed the maximum limit of ${l.maxFileCount}`);
|
|
191
|
+
for (const t of e)
|
|
192
|
+
await G(t, n);
|
|
193
|
+
} catch (t) {
|
|
194
|
+
throw (a = l.onError) == null || a.call(l, {
|
|
195
|
+
status: (t == null ? void 0 : t.status) || 400,
|
|
196
|
+
message: (t == null ? void 0 : t.message) || "Failed to add files"
|
|
197
|
+
}), t;
|
|
198
|
+
}
|
|
199
|
+
l.autoUpload && B();
|
|
200
|
+
}, N = (e) => {
|
|
201
|
+
const n = e.map((a) => H(a));
|
|
202
|
+
i.value.push(...n);
|
|
203
|
+
}, M = () => {
|
|
204
|
+
i.value.forEach((e) => {
|
|
205
|
+
F(e.id);
|
|
206
|
+
}), d.value.clear(), i.value = [], u.value = -1;
|
|
207
|
+
}, S = (e) => {
|
|
208
|
+
const n = i.value.find((t) => t.id === e);
|
|
209
|
+
if (n && n.status === "uploading") {
|
|
210
|
+
m(e, {
|
|
211
|
+
status: "cancelled"
|
|
212
|
+
});
|
|
213
|
+
const t = d.value.get(e);
|
|
214
|
+
if (!t)
|
|
215
|
+
return;
|
|
216
|
+
t.abort(), d.value.delete(e);
|
|
217
|
+
}
|
|
218
|
+
const a = i.value.findIndex((t) => t.id === e);
|
|
219
|
+
a !== -1 && i.value.splice(a, 1);
|
|
220
|
+
}, q = (e) => {
|
|
221
|
+
e ? e.forEach((n) => S(n)) : i.value.forEach((n) => S(n.id));
|
|
222
|
+
}, { files: O, open: j, reset: U } = R({
|
|
223
|
+
accept: l.accept,
|
|
224
|
+
multiple: l.multiple || !1
|
|
225
|
+
}), H = (e) => ({
|
|
226
|
+
id: T(),
|
|
227
|
+
...e,
|
|
228
|
+
filesizeText: e.filesize ? y(e.filesize) : void 0,
|
|
229
|
+
status: e.url ? "success" : "pending",
|
|
230
|
+
progress: {
|
|
231
|
+
loaded: 0,
|
|
232
|
+
total: e.filesize || 0,
|
|
233
|
+
percent: e.url ? 100 : 0,
|
|
234
|
+
speed: 0,
|
|
235
|
+
speedText: h(0),
|
|
236
|
+
remainingTime: 0,
|
|
237
|
+
uploadTime: 0
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
W(O, async (e) => {
|
|
241
|
+
if (e && e.length > 0) {
|
|
242
|
+
const n = Array.from(e);
|
|
243
|
+
U(), await E(n, "file").catch((a) => {
|
|
244
|
+
console.warn("Failed to add selected files:", a);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const J = v(() => i.value.filter((e) => e.status === "success").map((e) => ({
|
|
249
|
+
url: e.url,
|
|
250
|
+
filename: e.filename,
|
|
251
|
+
filesize: e.filesize,
|
|
252
|
+
filetype: e.filetype
|
|
253
|
+
})));
|
|
254
|
+
return {
|
|
255
|
+
isUploading: w,
|
|
256
|
+
uploadFiles: i,
|
|
257
|
+
dataFiles: J,
|
|
258
|
+
progress: b,
|
|
259
|
+
open: j,
|
|
260
|
+
trigger: B,
|
|
261
|
+
resetFiles: U,
|
|
262
|
+
clearFiles: M,
|
|
263
|
+
removeFiles: q,
|
|
264
|
+
addFiles: E,
|
|
265
|
+
addDataFiles: N,
|
|
266
|
+
cancelFiles: K
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
export {
|
|
270
|
+
ne as useUpload
|
|
271
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
|
-
import { useCan as u, useCheck as s, useError as p, useForgotPassword as m, useGetAuth as x, useIsLogin as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useClient as
|
|
5
|
-
import { useManage as
|
|
2
|
+
import { useCan as u, useCheck as s, useError as p, useForgotPassword as m, useGetAuth as x, useIsLogin as a, useLogin as f, useLogout as i, useRegister as n, useUpdatePassword as d } from "./hooks/auth.js";
|
|
3
|
+
import { useConfig as D } from "./hooks/config.js";
|
|
4
|
+
import { useClient as C, useCreate as g, useCreateMany as I, useCustom as L, useCustomMutation as M, useDelete as c, useDeleteMany as y, useInfiniteList as S, useInvalidate as T, useList as h, useMany as P, useOne as U, useUpdate as A, useUpdateMany as R } from "./hooks/data.js";
|
|
5
|
+
import { useManage as E } from "./hooks/manage.js";
|
|
6
6
|
import { useMenu as b } from "./hooks/menu.js";
|
|
7
7
|
import { useTheme as k } from "./hooks/theme.js";
|
|
8
8
|
import { useOverlay as V } from "./hooks/overlay.js";
|
|
@@ -13,48 +13,53 @@ import { useExport as N } from "./hooks/export.js";
|
|
|
13
13
|
import { useImport as W } from "./hooks/import.js";
|
|
14
14
|
import { useExportCsv as Y } from "./hooks/exportCsv.js";
|
|
15
15
|
import { useImportCsv as _ } from "./hooks/importCsv.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
16
|
+
import { useUpload as ee } from "./hooks/upload.js";
|
|
17
|
+
import { createLocalUploadDriver as oe } from "./hooks/upload/local.js";
|
|
18
|
+
import { createS3UploadDriver as ue } from "./hooks/upload/s3.js";
|
|
19
|
+
import { initRouter as pe } from "./router/route.js";
|
|
20
|
+
import { useAuthStore as xe } from "./stores/auth.js";
|
|
21
|
+
import { useRouteStore as fe } from "./stores/route.js";
|
|
22
|
+
import { useTabStore as ne } from "./stores/tab.js";
|
|
23
|
+
import { useManageStore as le } from "./stores/manage.js";
|
|
24
|
+
import { useI18nStore as ve } from "./stores/i18n.js";
|
|
25
|
+
import { DuxLogo as ge } from "./components/common/logo.js";
|
|
26
|
+
import { default as Le } from "./components/loader/iframe.js";
|
|
27
|
+
import { DuxOverlay as ce } from "./components/overlay/overlay.js";
|
|
28
|
+
import { DuxCan as Se } from "./components/auth/can.js";
|
|
29
|
+
import { arrayToTree as he, searchTree as Pe, treeToArr as Ue } from "./utils/tree.js";
|
|
30
|
+
import { DuxAppProvider as Re } from "./provider/app.js";
|
|
31
|
+
import { DuxTabRouterView as Ee } from "./provider/tab.js";
|
|
32
|
+
import { simpleAuthProvider as be } from "./preset/authProvider.js";
|
|
33
|
+
import { simpleDataProvider as ke } from "./preset/dataProvider.js";
|
|
34
|
+
import { i18nProvider as Ve } from "./preset/i18nProvider.js";
|
|
32
35
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
Re as DuxAppProvider,
|
|
37
|
+
Se as DuxCan,
|
|
38
|
+
Le as DuxLoaderIframe,
|
|
39
|
+
ge as DuxLogo,
|
|
40
|
+
ce as DuxOverlay,
|
|
41
|
+
Ee as DuxTabRouterView,
|
|
42
|
+
he as arrayToTree,
|
|
40
43
|
o as createDux,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
oe as createLocalUploadDriver,
|
|
45
|
+
ue as createS3UploadDriver,
|
|
46
|
+
Ve as i18nProvider,
|
|
47
|
+
pe as initRouter,
|
|
48
|
+
Pe as searchTree,
|
|
49
|
+
be as simpleAuthProvider,
|
|
50
|
+
ke as simpleDataProvider,
|
|
51
|
+
Ue as treeToArr,
|
|
52
|
+
xe as useAuthStore,
|
|
48
53
|
u as useCan,
|
|
49
54
|
s as useCheck,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
C as useClient,
|
|
56
|
+
D as useConfig,
|
|
57
|
+
g as useCreate,
|
|
53
58
|
I as useCreateMany,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
L as useCustom,
|
|
60
|
+
M as useCustomMutation,
|
|
61
|
+
c as useDelete,
|
|
62
|
+
y as useDeleteMany,
|
|
58
63
|
p as useError,
|
|
59
64
|
N as useExport,
|
|
60
65
|
Y as useExportCsv,
|
|
@@ -62,27 +67,28 @@ export {
|
|
|
62
67
|
J as useForm,
|
|
63
68
|
x as useGetAuth,
|
|
64
69
|
q as useI18n,
|
|
65
|
-
|
|
70
|
+
ve as useI18nStore,
|
|
66
71
|
W as useImport,
|
|
67
72
|
_ as useImportCsv,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
S as useInfiniteList,
|
|
74
|
+
T as useInvalidate,
|
|
75
|
+
a as useIsLogin,
|
|
76
|
+
h as useList,
|
|
77
|
+
f as useLogin,
|
|
78
|
+
i as useLogout,
|
|
79
|
+
E as useManage,
|
|
80
|
+
le as useManageStore,
|
|
81
|
+
P as useMany,
|
|
77
82
|
b as useMenu,
|
|
78
|
-
|
|
83
|
+
U as useOne,
|
|
79
84
|
V as useOverlay,
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
n as useRegister,
|
|
86
|
+
fe as useRouteStore,
|
|
82
87
|
B as useSelect,
|
|
83
|
-
|
|
88
|
+
ne as useTabStore,
|
|
84
89
|
k as useTheme,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
d as useUpdatePassword
|
|
90
|
+
A as useUpdate,
|
|
91
|
+
R as useUpdateMany,
|
|
92
|
+
d as useUpdatePassword,
|
|
93
|
+
ee as useUpload
|
|
88
94
|
};
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { trimStart as
|
|
3
|
-
function
|
|
4
|
-
const r = (a) => a ? `${c.apiUrl}/${
|
|
1
|
+
import k from "axios";
|
|
2
|
+
import { trimStart as u } from "lodash-es";
|
|
3
|
+
function w(c) {
|
|
4
|
+
const r = (a) => a ? `${c.apiUrl}/${u(a || "", "/")}` : c.apiUrl;
|
|
5
5
|
return {
|
|
6
6
|
apiUrl: r,
|
|
7
|
-
getList: (a,
|
|
7
|
+
getList: (a, d, l) => {
|
|
8
8
|
const e = {};
|
|
9
|
-
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize),
|
|
9
|
+
return a.pagination && typeof a.pagination == "object" && (e.page = a.pagination.page, e.pageSize = a.pagination.pageSize), k.get(r(a.path) || "", {
|
|
10
10
|
params: {
|
|
11
11
|
...e,
|
|
12
12
|
...a.filters,
|
|
13
13
|
...a.sorters
|
|
14
14
|
},
|
|
15
15
|
headers: {
|
|
16
|
-
Authorization:
|
|
16
|
+
Authorization: l == null ? void 0 : l.token
|
|
17
17
|
},
|
|
18
18
|
...a.meta
|
|
19
|
-
}).then((
|
|
20
|
-
throw c.errorCallback ? c.errorCallback(
|
|
19
|
+
}).then((t) => c.successCallback ? c.successCallback(t) : n(t)).catch((t) => {
|
|
20
|
+
throw c.errorCallback ? c.errorCallback(t) : b(t);
|
|
21
21
|
});
|
|
22
22
|
},
|
|
23
|
-
create: (a,
|
|
23
|
+
create: (a, d, l) => k.post(r(a.path) || "", a.data, {
|
|
24
24
|
headers: {
|
|
25
|
-
Authorization:
|
|
25
|
+
Authorization: l == null ? void 0 : l.token
|
|
26
26
|
},
|
|
27
27
|
...a.meta
|
|
28
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
28
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
29
29
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
30
30
|
}),
|
|
31
|
-
update: (a,
|
|
31
|
+
update: (a, d, l) => k.put(r(a.id ? `${a.path}/${a.id}` : a.path) || "", a.data, {
|
|
32
32
|
headers: {
|
|
33
|
-
Authorization:
|
|
33
|
+
Authorization: l == null ? void 0 : l.token
|
|
34
34
|
},
|
|
35
35
|
...a.meta
|
|
36
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
36
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
37
37
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
38
38
|
}),
|
|
39
|
-
deleteOne: (a,
|
|
39
|
+
deleteOne: (a, d, l) => k.delete(r(a.id ? `${a.path}/${a.id}` : a.path) || "", {
|
|
40
40
|
headers: {
|
|
41
|
-
Authorization:
|
|
41
|
+
Authorization: l == null ? void 0 : l.token
|
|
42
42
|
},
|
|
43
43
|
...a.meta
|
|
44
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
44
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
45
45
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
46
46
|
}),
|
|
47
|
-
getOne: (a,
|
|
47
|
+
getOne: (a, d, l) => k.get(r(a.id ? `${a.path}/${a.id}` : a.path) || "", {
|
|
48
48
|
headers: {
|
|
49
|
-
Authorization:
|
|
49
|
+
Authorization: l == null ? void 0 : l.token
|
|
50
50
|
},
|
|
51
51
|
...a.meta
|
|
52
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
52
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
53
53
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
54
54
|
}),
|
|
55
|
-
getMany: (a,
|
|
55
|
+
getMany: (a, d, l) => k.get(r(a.path) || "", {
|
|
56
56
|
params: {
|
|
57
57
|
ids: a.ids
|
|
58
58
|
},
|
|
59
59
|
headers: {
|
|
60
|
-
Authorization:
|
|
60
|
+
Authorization: l == null ? void 0 : l.token
|
|
61
61
|
},
|
|
62
62
|
...a.meta
|
|
63
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
63
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
64
64
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
65
65
|
}),
|
|
66
|
-
createMany: (a,
|
|
66
|
+
createMany: (a, d, l) => k.post(r(a.path) || "", a.data, {
|
|
67
67
|
headers: {
|
|
68
|
-
Authorization:
|
|
68
|
+
Authorization: l == null ? void 0 : l.token
|
|
69
69
|
},
|
|
70
70
|
...a.meta
|
|
71
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
71
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
72
72
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
73
73
|
}),
|
|
74
|
-
updateMany: (a,
|
|
74
|
+
updateMany: (a, d, l) => k.put(r(a.path) || "", {
|
|
75
75
|
ids: a.ids,
|
|
76
76
|
data: a.data
|
|
77
77
|
}, {
|
|
78
78
|
headers: {
|
|
79
|
-
Authorization:
|
|
79
|
+
Authorization: l == null ? void 0 : l.token
|
|
80
80
|
},
|
|
81
81
|
...a.meta
|
|
82
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
82
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
83
83
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
84
84
|
}),
|
|
85
|
-
deleteMany: (a,
|
|
85
|
+
deleteMany: (a, d, l) => k.delete(r(a.path) || "", {
|
|
86
86
|
params: {
|
|
87
87
|
ids: a.ids
|
|
88
88
|
},
|
|
89
89
|
headers: {
|
|
90
|
-
Authorization:
|
|
90
|
+
Authorization: l == null ? void 0 : l.token
|
|
91
91
|
},
|
|
92
92
|
...a.meta
|
|
93
|
-
}).then((e) => c.successCallback ? c.successCallback(e) :
|
|
93
|
+
}).then((e) => c.successCallback ? c.successCallback(e) : n(e)).catch((e) => {
|
|
94
94
|
throw c.errorCallback ? c.errorCallback(e) : b(e);
|
|
95
95
|
}),
|
|
96
|
-
custom: (a,
|
|
96
|
+
custom: (a, d, l) => {
|
|
97
97
|
let e = {
|
|
98
98
|
...a.query
|
|
99
99
|
};
|
|
@@ -103,41 +103,60 @@ function g(c) {
|
|
|
103
103
|
}), a.filters && typeof a.filters == "object" && (e = {
|
|
104
104
|
...e,
|
|
105
105
|
...a.filters
|
|
106
|
-
}),
|
|
106
|
+
}), k.request({
|
|
107
107
|
url: r(a.path || ""),
|
|
108
108
|
method: a.method || "GET",
|
|
109
109
|
data: a.payload,
|
|
110
110
|
params: e,
|
|
111
|
+
signal: a.signal,
|
|
111
112
|
headers: {
|
|
112
|
-
Authorization:
|
|
113
|
+
Authorization: l == null ? void 0 : l.token,
|
|
113
114
|
...a.headers
|
|
114
115
|
},
|
|
116
|
+
onUploadProgress: (t) => {
|
|
117
|
+
var m;
|
|
118
|
+
const C = Math.round(t.loaded * 100 / (t.total || 1));
|
|
119
|
+
(m = a.onUploadProgress) == null || m.call(a, {
|
|
120
|
+
loaded: t.loaded,
|
|
121
|
+
total: t.total,
|
|
122
|
+
percent: C
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
onDownloadProgress: (t) => {
|
|
126
|
+
var m;
|
|
127
|
+
const C = Math.round(t.loaded * 100 / (t.total || 1));
|
|
128
|
+
(m = a.onDownloadProgress) == null || m.call(a, {
|
|
129
|
+
loaded: t.loaded,
|
|
130
|
+
total: t.total,
|
|
131
|
+
percent: C
|
|
132
|
+
});
|
|
133
|
+
},
|
|
115
134
|
...a.meta
|
|
116
|
-
}).then((
|
|
117
|
-
throw c.errorCallback ? c.errorCallback(
|
|
135
|
+
}).then((t) => c.successCallback ? c.successCallback(t) : n(t)).catch((t) => {
|
|
136
|
+
throw c.errorCallback ? c.errorCallback(t) : b(t);
|
|
118
137
|
});
|
|
119
138
|
}
|
|
120
139
|
};
|
|
121
140
|
}
|
|
122
|
-
function
|
|
123
|
-
var r, a,
|
|
141
|
+
function n(c) {
|
|
142
|
+
var r, a, d;
|
|
124
143
|
return {
|
|
125
144
|
message: (r = c.data) == null ? void 0 : r.message,
|
|
126
145
|
data: (a = c.data) == null ? void 0 : a.data,
|
|
127
|
-
meta: (
|
|
146
|
+
meta: (d = c.data) == null ? void 0 : d.meta,
|
|
128
147
|
raw: c.data
|
|
129
148
|
};
|
|
130
149
|
}
|
|
131
150
|
function b(c) {
|
|
132
|
-
var r, a, l, t;
|
|
151
|
+
var r, a, d, l, e, t, C, m, g, h;
|
|
133
152
|
return {
|
|
134
|
-
message: ((r = c.response.data) == null ? void 0 :
|
|
135
|
-
data: (
|
|
136
|
-
meta: (
|
|
137
|
-
status: ((
|
|
138
|
-
raw: c.response.data
|
|
153
|
+
message: ((a = (r = c.response) == null ? void 0 : r.data) == null ? void 0 : a.message) || (c == null ? void 0 : c.message),
|
|
154
|
+
data: (l = (d = c.response) == null ? void 0 : d.data) == null ? void 0 : l.data,
|
|
155
|
+
meta: (t = (e = c.response) == null ? void 0 : e.data) == null ? void 0 : t.meta,
|
|
156
|
+
status: ((m = (C = c.response) == null ? void 0 : C.data) == null ? void 0 : m.code) || ((g = c.response) == null ? void 0 : g.status) || 500,
|
|
157
|
+
raw: (h = c.response) == null ? void 0 : h.data
|
|
139
158
|
};
|
|
140
159
|
}
|
|
141
160
|
export {
|
|
142
|
-
|
|
161
|
+
w as simpleDataProvider
|
|
143
162
|
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -14,7 +14,8 @@ import { useI18nStore as W } from "../stores/i18n.js";
|
|
|
14
14
|
import "@vueuse/core";
|
|
15
15
|
import "clsx";
|
|
16
16
|
import "json-2-csv";
|
|
17
|
-
|
|
17
|
+
import "axios";
|
|
18
|
+
const le = /* @__PURE__ */ O({
|
|
18
19
|
name: "DuxAppProvider",
|
|
19
20
|
props: {},
|
|
20
21
|
setup(X, {
|
|
@@ -143,5 +144,5 @@ const de = /* @__PURE__ */ O({
|
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
146
|
export {
|
|
146
|
-
|
|
147
|
+
le as DuxAppProvider
|
|
147
148
|
};
|
|
@@ -1579,7 +1579,7 @@ interface IClientParams extends IDataProviderCustomOptions {
|
|
|
1579
1579
|
* Custom request client
|
|
1580
1580
|
*/
|
|
1581
1581
|
export declare function useClient(): {
|
|
1582
|
-
request: (params: IClientParams) =>
|
|
1582
|
+
request: (params: IClientParams) => Promise<IDataProviderResponse>;
|
|
1583
1583
|
};
|
|
1584
1584
|
export declare function useInvalidate(): {
|
|
1585
1585
|
invalidate: (path: string, providerName?: string) => void;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { UseColorModeOptions } from '@vueuse/core';
|
|
2
2
|
import type { ITheme } from '../types';
|
|
3
|
-
export interface RippleOptions {
|
|
4
|
-
duration?: number;
|
|
5
|
-
easing?: string;
|
|
6
|
-
}
|
|
7
3
|
export declare function useTheme(options?: UseColorModeOptions): {
|
|
8
4
|
toggle: (n?: number) => "light" | "dark" | "auto";
|
|
9
5
|
mode: import("vue").ShallowRef<"light" | "dark" | "auto">;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDataProviderResponse } from '../../types';
|
|
2
|
+
import type { IUploadDriver } from './types';
|
|
3
|
+
export interface IS3SignData {
|
|
4
|
+
uploadUrl: string;
|
|
5
|
+
url: string;
|
|
6
|
+
params?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createS3UploadDriver(config: {
|
|
9
|
+
signPath: string;
|
|
10
|
+
signCallback?: (response: IDataProviderResponse) => IS3SignData;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}): IUploadDriver;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IDataProviderCustomOptions, IDataProviderResponse } from '../../types';
|
|
2
|
+
export interface IUploadDriver {
|
|
3
|
+
upload(file: File, options: IUploadDriverOptions): Promise<IDataProviderResponse>;
|
|
4
|
+
}
|
|
5
|
+
export interface IUploadDriverOptions extends Omit<IDataProviderCustomOptions, 'onUploadProgress' | 'onDownloadProgress'> {
|
|
6
|
+
method?: 'POST' | 'PUT';
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
onUploadProgress?: (progressData: {
|
|
9
|
+
loaded: number;
|
|
10
|
+
total?: number;
|
|
11
|
+
percent?: number;
|
|
12
|
+
}) => void;
|
|
13
|
+
params?: Record<string, string>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { UseMutationOptions } from '@tanstack/vue-query';
|
|
2
|
+
import type { IDataProviderCustomOptions, IDataProviderError, IDataProviderResponse } from '../types';
|
|
3
|
+
import type { IUploadDriver } from './upload/types';
|
|
4
|
+
export interface IUseUploadProps extends Omit<IDataProviderCustomOptions, 'onUploadProgress' | 'onDownloadProgress'> {
|
|
5
|
+
method?: 'POST' | 'PUT';
|
|
6
|
+
maxFileSize?: number;
|
|
7
|
+
maxFileCount?: number;
|
|
8
|
+
accept?: string;
|
|
9
|
+
multiple?: boolean;
|
|
10
|
+
autoUpload?: boolean;
|
|
11
|
+
driver?: IUploadDriver;
|
|
12
|
+
options?: UseMutationOptions<IDataProviderResponse, IDataProviderError, IDataProviderCustomOptions>;
|
|
13
|
+
onSuccess?: (data: IDataProviderResponse) => void;
|
|
14
|
+
onError?: (error: IDataProviderError) => void;
|
|
15
|
+
onDataCallback?: (data: IDataProviderResponse, file: IUseUploadFile) => Partial<IUseUploadFileData>;
|
|
16
|
+
onProgress?: (progress: IOverallProgress) => void;
|
|
17
|
+
onCancel?: (id: string) => void;
|
|
18
|
+
onComplete?: (data: IUseUploadFile[]) => void;
|
|
19
|
+
}
|
|
20
|
+
export type IUseUploadType = 'file' | 'blob' | 'base64' | 'arrayBuffer';
|
|
21
|
+
export type IUseUploadPayload = File | Blob | string | ArrayBuffer;
|
|
22
|
+
export interface IUseUploadFileData {
|
|
23
|
+
url?: string;
|
|
24
|
+
filename?: string;
|
|
25
|
+
filesize?: number;
|
|
26
|
+
filetype?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IUseUploadFile extends IUseUploadFileData {
|
|
29
|
+
id: string;
|
|
30
|
+
progress?: IUploadProgress;
|
|
31
|
+
file?: File;
|
|
32
|
+
filesizeText?: string;
|
|
33
|
+
status?: 'pending' | 'uploading' | 'success' | 'error' | 'cancelled';
|
|
34
|
+
error?: string;
|
|
35
|
+
data?: IDataProviderResponse;
|
|
36
|
+
}
|
|
37
|
+
export interface IUploadProgress {
|
|
38
|
+
loaded: number;
|
|
39
|
+
total?: number;
|
|
40
|
+
percent?: number;
|
|
41
|
+
speed?: number;
|
|
42
|
+
speedText?: string;
|
|
43
|
+
uploadTime?: number;
|
|
44
|
+
remainingTime?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface IOverallProgress {
|
|
47
|
+
index: number;
|
|
48
|
+
totalFiles: number;
|
|
49
|
+
currentFile?: IUseUploadFile;
|
|
50
|
+
totalPercent: number;
|
|
51
|
+
totalLoaded: number;
|
|
52
|
+
totalSize: number;
|
|
53
|
+
}
|
|
54
|
+
export declare function useUpload(props: IUseUploadProps): {
|
|
55
|
+
isUploading: import("vue").Ref<boolean, boolean>;
|
|
56
|
+
uploadFiles: import("vue").Ref<{
|
|
57
|
+
id: string;
|
|
58
|
+
progress?: {
|
|
59
|
+
loaded: number;
|
|
60
|
+
total?: number | undefined;
|
|
61
|
+
percent?: number | undefined;
|
|
62
|
+
speed?: number | undefined;
|
|
63
|
+
speedText?: string | undefined;
|
|
64
|
+
uploadTime?: number | undefined;
|
|
65
|
+
remainingTime?: number | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
file?: {
|
|
68
|
+
readonly lastModified: number;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly webkitRelativePath: string;
|
|
71
|
+
readonly size: number;
|
|
72
|
+
readonly type: string;
|
|
73
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
74
|
+
bytes: () => Promise<Uint8Array>;
|
|
75
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
76
|
+
stream: () => ReadableStream<Uint8Array>;
|
|
77
|
+
text: () => Promise<string>;
|
|
78
|
+
} | undefined;
|
|
79
|
+
filesizeText?: string | undefined;
|
|
80
|
+
status?: "pending" | "uploading" | "success" | "error" | "cancelled" | undefined;
|
|
81
|
+
error?: string | undefined;
|
|
82
|
+
data?: {
|
|
83
|
+
[x: string]: any;
|
|
84
|
+
message?: string | undefined;
|
|
85
|
+
data?: any;
|
|
86
|
+
meta?: Record<string, any> | undefined;
|
|
87
|
+
raw?: any;
|
|
88
|
+
} | undefined;
|
|
89
|
+
url?: string | undefined;
|
|
90
|
+
filename?: string | undefined;
|
|
91
|
+
filesize?: number | undefined;
|
|
92
|
+
filetype?: string | undefined;
|
|
93
|
+
}[], IUseUploadFile[] | {
|
|
94
|
+
id: string;
|
|
95
|
+
progress?: {
|
|
96
|
+
loaded: number;
|
|
97
|
+
total?: number | undefined;
|
|
98
|
+
percent?: number | undefined;
|
|
99
|
+
speed?: number | undefined;
|
|
100
|
+
speedText?: string | undefined;
|
|
101
|
+
uploadTime?: number | undefined;
|
|
102
|
+
remainingTime?: number | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
file?: {
|
|
105
|
+
readonly lastModified: number;
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly webkitRelativePath: string;
|
|
108
|
+
readonly size: number;
|
|
109
|
+
readonly type: string;
|
|
110
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
111
|
+
bytes: () => Promise<Uint8Array>;
|
|
112
|
+
slice: (start?: number, end?: number, contentType?: string) => Blob;
|
|
113
|
+
stream: () => ReadableStream<Uint8Array>;
|
|
114
|
+
text: () => Promise<string>;
|
|
115
|
+
} | undefined;
|
|
116
|
+
filesizeText?: string | undefined;
|
|
117
|
+
status?: "pending" | "uploading" | "success" | "error" | "cancelled" | undefined;
|
|
118
|
+
error?: string | undefined;
|
|
119
|
+
data?: {
|
|
120
|
+
[x: string]: any;
|
|
121
|
+
message?: string | undefined;
|
|
122
|
+
data?: any;
|
|
123
|
+
meta?: Record<string, any> | undefined;
|
|
124
|
+
raw?: any;
|
|
125
|
+
} | undefined;
|
|
126
|
+
url?: string | undefined;
|
|
127
|
+
filename?: string | undefined;
|
|
128
|
+
filesize?: number | undefined;
|
|
129
|
+
filetype?: string | undefined;
|
|
130
|
+
}[]>;
|
|
131
|
+
dataFiles: import("vue").ComputedRef<IUseUploadFileData[]>;
|
|
132
|
+
progress: import("vue").ComputedRef<IOverallProgress>;
|
|
133
|
+
open: (localOptions?: Partial<import("@vueuse/core").UseFileDialogOptions>) => void;
|
|
134
|
+
trigger: () => Promise<void>;
|
|
135
|
+
resetFiles: () => void;
|
|
136
|
+
clearFiles: () => void;
|
|
137
|
+
removeFiles: (ids?: string[]) => void;
|
|
138
|
+
addFiles: (files: IUseUploadPayload[], type?: IUseUploadType) => Promise<void>;
|
|
139
|
+
addDataFiles: (dataFiles: IUseUploadFileData[]) => void;
|
|
140
|
+
cancelFiles: (ids?: string[]) => void;
|
|
141
|
+
};
|
|
@@ -82,6 +82,11 @@ export interface IDataProviderDeleteOptions {
|
|
|
82
82
|
meta?: Record<string, any>;
|
|
83
83
|
id: string | number;
|
|
84
84
|
}
|
|
85
|
+
export interface IDataProviderProgress {
|
|
86
|
+
loaded: number;
|
|
87
|
+
total?: number;
|
|
88
|
+
percent?: number;
|
|
89
|
+
}
|
|
85
90
|
export interface IDataProviderCustomOptions {
|
|
86
91
|
path?: string;
|
|
87
92
|
method?: string;
|
|
@@ -91,4 +96,7 @@ export interface IDataProviderCustomOptions {
|
|
|
91
96
|
headers?: Record<string, string>;
|
|
92
97
|
meta?: Record<string, any>;
|
|
93
98
|
payload?: any;
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
onUploadProgress?: (progress: IDataProviderProgress) => void;
|
|
101
|
+
onDownloadProgress?: (progress: IDataProviderProgress) => void;
|
|
94
102
|
}
|