@duxweb/dvha-core 0.1.10 → 0.1.12
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/exportCsv.cjs +2 -0
- package/dist/cjs/hooks/import.cjs +1 -0
- package/dist/cjs/hooks/importCsv.cjs +2 -0
- package/dist/cjs/hooks/overlay.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/esm/components/auth/can.js +6 -5
- package/dist/esm/directive/permission.js +3 -2
- package/dist/esm/hooks/exportCsv.js +55 -0
- package/dist/esm/hooks/import.js +56 -0
- package/dist/esm/hooks/importCsv.js +56 -0
- package/dist/esm/hooks/overlay.js +5 -4
- package/dist/esm/index.js +60 -54
- package/dist/esm/provider/app.js +3 -2
- package/dist/types/hooks/export.d.ts +1 -2
- package/dist/types/hooks/exportCsv.d.ts +17 -0
- package/dist/types/hooks/import.d.ts +29 -0
- package/dist/types/hooks/importCsv.d.ts +26 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("json-2-csv"),l=require("vue"),y=require("./export.cjs");function h(e){const d=l.computed(()=>{const{filename:t,headers:r,csvOptions:o,...c}=e;return c}),v=l.computed(()=>{const t=e.csvOptions||{},r=t.quote;return{prependHeader:e.headers!==!1,keys:Array.isArray(e.headers)?e.headers:void 0,delimiter:{field:t.delimiter||",",wrap:typeof r=="string"?r:'"',eol:t.eol||`
|
|
2
|
+
`},excelBOM:t.writeBOM||!1}});return y.useExport({...d.value,onSuccess:async t=>{var o,c,a,i;if(!(t!=null&&t.pages)){(o=e.onError)==null||o.call(e,{message:"No data to export",status:400});return}const r=t.pages.flatMap(n=>(n==null?void 0:n.data)||[]);if(r.length===0){(c=e.onError)==null||c.call(e,{message:"No data to export",status:400});return}try{const n=await f.json2csv(r,v.value),m=new Blob([n],{type:"text/csv;charset=utf-8;"}),u=URL.createObjectURL(m),s=document.createElement("a");s.href=u,s.download=e.filename||"export.csv",s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(u),(a=e.onSuccess)==null||a.call(e,t)}catch(n){(i=e.onError)==null||i.call(e,{message:`CSV Export Error: ${n}`,status:500})}}})}exports.useExportCsv=h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),S=require("./data.cjs"),k=e=>new Promise(a=>setTimeout(a,e));function y(e){const a=s.ref(!1),n=s.ref({totalItems:0,processedItems:0,totalBatches:0,processedBatches:0,percentage:0}),i=s.computed(()=>{const{onComplete:u,onProgress:l,onError:m,interval:c,chunkSize:o,...r}=e;return r}),{mutate:f}=S.useCustomMutation({path:e.path,method:"POST",...i.value,options:{...i.value.options}}),I=async u=>{var h,g,v;if(a.value)return;const l=e.chunkSize||100,m=e.interval||100,c=u.length,o=[];for(let t=0;t<c;t+=l)o.push(u.slice(t,t+l));const r=o.length;n.value={totalItems:c,processedItems:0,totalBatches:r,processedBatches:0,percentage:0},a.value=!0;try{for(let t=0;t<o.length;t++){const d=o[t];await f({payload:d}),n.value.processedBatches=t+1,n.value.processedItems+=d.length,n.value.percentage=Math.round(n.value.processedItems/c*100),(h=e.onProgress)==null||h.call(e,n.value),t<o.length-1&&await k(m)}a.value=!1,(g=e.onComplete)==null||g.call(e,n.value)}catch(t){a.value=!1,(v=e.onError)==null||v.call(e,t)}};return{isLoading:s.computed(()=>a.value),progress:s.computed(()=>n.value),trigger:I}}exports.useImport=y;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@vueuse/core"),f=require("json-2-csv"),c=require("vue"),F=require("./import.cjs");function O(t){const l=c.computed(()=>{const{csvOptions:e,...s}=t;return s}),u=c.computed(()=>{const e=t.csvOptions||{};return{delimiter:{field:e.delimiter||",",wrap:e.wrap||'"',eol:e.eol||`
|
|
2
|
+
`},excelBOM:e.excelBOM||!1,headerFields:e.headerFields,keys:e.keys,trimHeaderFields:e.trimHeaderFields||!1,trimFieldValues:e.trimFieldValues||!1}}),i=F.useImport({...l.value}),o=async e=>{var s,a;try{const r=await e.text(),n=await f.csv2json(r,u.value);n&&n.length>0?await i.trigger(n):(s=t.onError)==null||s.call(t,{message:"CSV 文件为空或格式不正确",status:400})}catch(r){(a=t.onError)==null||a.call(t,{message:`CSV 解析错误: ${r}`,status:500})}},{open:m,reset:d,onChange:v}=g.useFileDialog({accept:".csv",multiple:!1});return v(e=>{e&&e.length>0&&o(e[0])}),{...i,open:()=>{d(),m()},readFile:o}}exports.useImportCsv=O;
|
|
@@ -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 t=require("../components/overlay/overlay.cjs");require("pinia");require("lodash-es");require("@tanstack/vue-query");require("@vueuse/core");function i(){const e=u.useOverlayInject(t.DuxOverlay);return{show:r=>e(r)}}exports.useOverlay=i;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@overlastic/vue");require("vue");require("clsx");require("vue-router");const t=require("../components/overlay/overlay.cjs");require("pinia");require("lodash-es");require("@tanstack/vue-query");require("@vueuse/core");require("json-2-csv");function i(){const e=u.useOverlayInject(t.DuxOverlay);return{show:r=>e(r)}}exports.useOverlay=i;
|
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"),i=require("./hooks/menu.cjs"),n=require("./hooks/theme.cjs"),a=require("./hooks/overlay.cjs"),c=require("./hooks/i18n.cjs"),q=require("./hooks/select.cjs"),p=require("./hooks/form.cjs"),d=require("./hooks/export.cjs"),m=require("./hooks/import.cjs"),v=require("./hooks/exportCsv.cjs"),l=require("./hooks/importCsv.cjs"),g=require("./router/route.cjs"),C=require("./stores/auth.cjs"),x=require("./stores/route.cjs"),D=require("./stores/tab.cjs"),y=require("./stores/manage.cjs"),M=require("./stores/i18n.cjs"),h=require("./components/common/logo.cjs"),P=require("./components/loader/iframe.cjs"),I=require("./components/overlay/overlay.cjs"),T=require("./components/auth/can.cjs"),u=require("./utils/tree.cjs"),S=require("./provider/app.cjs"),L=require("./provider/tab.cjs"),A=require("./preset/authProvider.cjs"),f=require("./preset/dataProvider.cjs"),b=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=i.useMenu;exports.useTheme=n.useTheme;exports.useOverlay=a.useOverlay;exports.useI18n=c.useI18n;exports.useSelect=q.useSelect;exports.useForm=p.useForm;exports.useExport=d.useExport;exports.useImport=m.useImport;exports.useExportCsv=v.useExportCsv;exports.useImportCsv=l.useImportCsv;exports.initRouter=g.initRouter;exports.useAuthStore=C.useAuthStore;exports.useRouteStore=x.useRouteStore;exports.useTabStore=D.useTabStore;exports.useManageStore=y.useManageStore;exports.useI18nStore=M.useI18nStore;exports.DuxLogo=h.DuxLogo;exports.DuxLoaderIframe=P;exports.DuxOverlay=I.DuxOverlay;exports.DuxCan=T.DuxCan;exports.arrayToTree=u.arrayToTree;exports.searchTree=u.searchTree;exports.treeToArr=u.treeToArr;exports.DuxAppProvider=S.DuxAppProvider;exports.DuxTabRouterView=L.DuxTabRouterView;exports.simpleAuthProvider=A.simpleAuthProvider;exports.simpleDataProvider=f.simpleDataProvider;exports.i18nProvider=b.i18nProvider;
|
|
@@ -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");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 t=n.meta.manageName,L=n.meta.authorization===!1;if(!t){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=t);const g=Q.useManageStore(t);g.isInit()||g.setConfig((R=s.manages)==null?void 0:R.find(e=>e.name===t),s);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");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 t=n.meta.manageName,L=n.meta.authorization===!1;if(!t){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=t);const g=Q.useManageStore(t);g.isInit()||g.setConfig((R=s.manages)==null?void 0:R.find(e=>e.name===t),s);const i=K.useRouteStore(t),o=H.useManage(t),v=J.useAuthStore(t),q=W.useI18nStore(t);if((A=o.config)!=null&&A.i18nProvider&&!q.isInit()){const e=q.getLocale();e&&((M=o.config)==null||M.i18nProvider.changeLocale(e))}if(!v.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:`${t}.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:`${t}.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:`${t}.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,v.getUser()).then(r=>{i.appendRoutes(P(r.data||[]))}))}catch(r){console.error(r)}return i.appendRoutes(u),i.getRoutes().forEach(r=>{var C,N;if(!r.path)return;const c={name:r.name,path:r.path,meta:r.meta};switch(r.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=r.meta)==null?void 0:F.url)||r.path;return E&&window.open(E,"_blank"),!1},c.component=()=>Promise.resolve({template:"<div></div>"});break;default:r.component&&(c.component=r.component);break}d.addRoute(`${t}.auth`,c)}),a({path:((I=n.redirectedFrom)==null?void 0:I.path)||n.path,replace:!0})}const b=["","/",`/${t}`,`/${t}/`];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(t);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:`${t}.notAuthorized`}):a()}),()=>h.createVNode(U.OverlaysProvider,null,{default:()=>{var n;return[(n=f.default)==null?void 0:n.call(f)]}})}});exports.DuxAppProvider=X;
|
|
@@ -7,7 +7,8 @@ import "vue-router";
|
|
|
7
7
|
import "@vueuse/core";
|
|
8
8
|
import "@overlastic/vue";
|
|
9
9
|
import "clsx";
|
|
10
|
-
|
|
10
|
+
import "json-2-csv";
|
|
11
|
+
const D = /* @__PURE__ */ a({
|
|
11
12
|
name: "DuxCan",
|
|
12
13
|
props: {
|
|
13
14
|
name: {
|
|
@@ -18,16 +19,16 @@ const y = /* @__PURE__ */ a({
|
|
|
18
19
|
type: Object
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
|
-
setup(
|
|
22
|
+
setup(m, {
|
|
22
23
|
slots: r
|
|
23
24
|
}) {
|
|
24
25
|
const n = i();
|
|
25
26
|
return () => {
|
|
26
|
-
var
|
|
27
|
-
return n(
|
|
27
|
+
var e, p;
|
|
28
|
+
return n(m.name, m.params) ? (e = r.default) == null ? void 0 : e.call(r) : ((p = r.fallback) == null ? void 0 : p.call(r)) || null;
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
32
|
export {
|
|
32
|
-
|
|
33
|
+
D as DuxCan
|
|
33
34
|
};
|
|
@@ -7,7 +7,8 @@ import "vue-router";
|
|
|
7
7
|
import "@vueuse/core";
|
|
8
8
|
import "@overlastic/vue";
|
|
9
9
|
import "clsx";
|
|
10
|
-
|
|
10
|
+
import "json-2-csv";
|
|
11
|
+
const C = {
|
|
11
12
|
mounted(t, i) {
|
|
12
13
|
var r;
|
|
13
14
|
const { value: o } = i;
|
|
@@ -17,5 +18,5 @@ const l = {
|
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
+
C as permissionDirective
|
|
21
22
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { json2csv as v } from "json-2-csv";
|
|
2
|
+
import { computed as u } from "vue";
|
|
3
|
+
import { useExport as h } from "./export.js";
|
|
4
|
+
function b(e) {
|
|
5
|
+
const d = u(() => {
|
|
6
|
+
const { filename: t, headers: r, csvOptions: s, ...c } = e;
|
|
7
|
+
return c;
|
|
8
|
+
}), m = u(() => {
|
|
9
|
+
const t = e.csvOptions || {}, r = t.quote;
|
|
10
|
+
return {
|
|
11
|
+
prependHeader: e.headers !== !1,
|
|
12
|
+
keys: Array.isArray(e.headers) ? e.headers : void 0,
|
|
13
|
+
delimiter: {
|
|
14
|
+
field: t.delimiter || ",",
|
|
15
|
+
wrap: typeof r == "string" ? r : '"',
|
|
16
|
+
eol: t.eol || `
|
|
17
|
+
`
|
|
18
|
+
},
|
|
19
|
+
excelBOM: t.writeBOM || !1
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return h({
|
|
23
|
+
...d.value,
|
|
24
|
+
onSuccess: async (t) => {
|
|
25
|
+
var s, c, a, i;
|
|
26
|
+
if (!(t != null && t.pages)) {
|
|
27
|
+
(s = e.onError) == null || s.call(e, {
|
|
28
|
+
message: "No data to export",
|
|
29
|
+
status: 400
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const r = t.pages.flatMap((n) => (n == null ? void 0 : n.data) || []);
|
|
34
|
+
if (r.length === 0) {
|
|
35
|
+
(c = e.onError) == null || c.call(e, {
|
|
36
|
+
message: "No data to export",
|
|
37
|
+
status: 400
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const n = await v(r, m.value), f = new Blob([n], { type: "text/csv;charset=utf-8;" }), l = URL.createObjectURL(f), o = document.createElement("a");
|
|
43
|
+
o.href = l, o.download = e.filename || "export.csv", o.style.display = "none", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(l), (a = e.onSuccess) == null || a.call(e, t);
|
|
44
|
+
} catch (n) {
|
|
45
|
+
(i = e.onError) == null || i.call(e, {
|
|
46
|
+
message: `CSV Export Error: ${n}`,
|
|
47
|
+
status: 500
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
b as useExportCsv
|
|
55
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ref as f, computed as u } from "vue";
|
|
2
|
+
import { useCustomMutation as B } from "./data.js";
|
|
3
|
+
const P = (e) => new Promise((a) => setTimeout(a, e));
|
|
4
|
+
function z(e) {
|
|
5
|
+
const a = f(!1), n = f({
|
|
6
|
+
totalItems: 0,
|
|
7
|
+
processedItems: 0,
|
|
8
|
+
totalBatches: 0,
|
|
9
|
+
processedBatches: 0,
|
|
10
|
+
percentage: 0
|
|
11
|
+
}), i = u(() => {
|
|
12
|
+
const { onComplete: c, onProgress: l, onError: m, interval: s, chunkSize: o, ...r } = e;
|
|
13
|
+
return r;
|
|
14
|
+
}), { mutate: I } = B({
|
|
15
|
+
path: e.path,
|
|
16
|
+
method: "POST",
|
|
17
|
+
...i.value,
|
|
18
|
+
options: {
|
|
19
|
+
...i.value.options
|
|
20
|
+
}
|
|
21
|
+
}), k = async (c) => {
|
|
22
|
+
var h, g, v;
|
|
23
|
+
if (a.value)
|
|
24
|
+
return;
|
|
25
|
+
const l = e.chunkSize || 100, m = e.interval || 100, s = c.length, o = [];
|
|
26
|
+
for (let t = 0; t < s; t += l)
|
|
27
|
+
o.push(c.slice(t, t + l));
|
|
28
|
+
const r = o.length;
|
|
29
|
+
n.value = {
|
|
30
|
+
totalItems: s,
|
|
31
|
+
processedItems: 0,
|
|
32
|
+
totalBatches: r,
|
|
33
|
+
processedBatches: 0,
|
|
34
|
+
percentage: 0
|
|
35
|
+
}, a.value = !0;
|
|
36
|
+
try {
|
|
37
|
+
for (let t = 0; t < o.length; t++) {
|
|
38
|
+
const d = o[t];
|
|
39
|
+
await I({
|
|
40
|
+
payload: d
|
|
41
|
+
}), n.value.processedBatches = t + 1, n.value.processedItems += d.length, n.value.percentage = Math.round(n.value.processedItems / s * 100), (h = e.onProgress) == null || h.call(e, n.value), t < o.length - 1 && await P(m);
|
|
42
|
+
}
|
|
43
|
+
a.value = !1, (g = e.onComplete) == null || g.call(e, n.value);
|
|
44
|
+
} catch (t) {
|
|
45
|
+
a.value = !1, (v = e.onError) == null || v.call(e, t);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
isLoading: u(() => a.value),
|
|
50
|
+
progress: u(() => n.value),
|
|
51
|
+
trigger: k
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
z as useImport
|
|
56
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useFileDialog as g } from "@vueuse/core";
|
|
2
|
+
import { csv2json as v } from "json-2-csv";
|
|
3
|
+
import { computed as l } from "vue";
|
|
4
|
+
import { useImport as F } from "./import.js";
|
|
5
|
+
function C(t) {
|
|
6
|
+
const c = l(() => {
|
|
7
|
+
const { csvOptions: e, ...s } = t;
|
|
8
|
+
return s;
|
|
9
|
+
}), m = l(() => {
|
|
10
|
+
const e = t.csvOptions || {};
|
|
11
|
+
return {
|
|
12
|
+
delimiter: {
|
|
13
|
+
field: e.delimiter || ",",
|
|
14
|
+
wrap: e.wrap || '"',
|
|
15
|
+
eol: e.eol || `
|
|
16
|
+
`
|
|
17
|
+
},
|
|
18
|
+
excelBOM: e.excelBOM || !1,
|
|
19
|
+
headerFields: e.headerFields,
|
|
20
|
+
keys: e.keys,
|
|
21
|
+
trimHeaderFields: e.trimHeaderFields || !1,
|
|
22
|
+
trimFieldValues: e.trimFieldValues || !1
|
|
23
|
+
};
|
|
24
|
+
}), r = F({
|
|
25
|
+
...c.value
|
|
26
|
+
}), n = async (e) => {
|
|
27
|
+
var s, a;
|
|
28
|
+
try {
|
|
29
|
+
const i = await e.text(), o = await v(i, m.value);
|
|
30
|
+
o && o.length > 0 ? await r.trigger(o) : (s = t.onError) == null || s.call(t, {
|
|
31
|
+
message: "CSV 文件为空或格式不正确",
|
|
32
|
+
status: 400
|
|
33
|
+
});
|
|
34
|
+
} catch (i) {
|
|
35
|
+
(a = t.onError) == null || a.call(t, {
|
|
36
|
+
message: `CSV 解析错误: ${i}`,
|
|
37
|
+
status: 500
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, { open: u, reset: d, onChange: f } = g({
|
|
41
|
+
accept: ".csv",
|
|
42
|
+
multiple: !1
|
|
43
|
+
});
|
|
44
|
+
return f((e) => {
|
|
45
|
+
e && e.length > 0 && n(e[0]);
|
|
46
|
+
}), {
|
|
47
|
+
...r,
|
|
48
|
+
open: () => {
|
|
49
|
+
d(), u();
|
|
50
|
+
},
|
|
51
|
+
readFile: n
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
C as useImportCsv
|
|
56
|
+
};
|
|
@@ -2,17 +2,18 @@ import { useOverlayInject as t } from "@overlastic/vue";
|
|
|
2
2
|
import "vue";
|
|
3
3
|
import "clsx";
|
|
4
4
|
import "vue-router";
|
|
5
|
-
import { DuxOverlay as
|
|
5
|
+
import { DuxOverlay as m } from "../components/overlay/overlay.js";
|
|
6
6
|
import "pinia";
|
|
7
7
|
import "lodash-es";
|
|
8
8
|
import "@tanstack/vue-query";
|
|
9
9
|
import "@vueuse/core";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import "json-2-csv";
|
|
11
|
+
function y() {
|
|
12
|
+
const r = t(m);
|
|
12
13
|
return {
|
|
13
14
|
show: (o) => r(o)
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
y as useOverlay
|
|
18
19
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,80 +1,86 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
|
-
import { useCan as u, useCheck as s, useError as p, useForgotPassword as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useClient as
|
|
5
|
-
import { useManage as
|
|
6
|
-
import { useMenu as
|
|
2
|
+
import { useCan as u, useCheck as s, useError as p, useForgotPassword as m, useGetAuth as x, useIsLogin as f, useLogin as a, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
|
|
3
|
+
import { useConfig as l } from "./hooks/config.js";
|
|
4
|
+
import { useClient as g, useCreate as v, useCreateMany as I, useCustom as M, useCustomMutation as y, useDelete as L, useDeleteMany as T, useInfiniteList as h, useInvalidate as P, useList as S, useMany as A, useOne as c, useUpdate as R, useUpdateMany as w } from "./hooks/data.js";
|
|
5
|
+
import { useManage as O } from "./hooks/manage.js";
|
|
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";
|
|
9
9
|
import { useI18n as q } from "./hooks/i18n.js";
|
|
10
10
|
import { useSelect as B } from "./hooks/select.js";
|
|
11
11
|
import { useForm as J } from "./hooks/form.js";
|
|
12
12
|
import { useExport as N } from "./hooks/export.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
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 {
|
|
13
|
+
import { useImport as W } from "./hooks/import.js";
|
|
14
|
+
import { useExportCsv as Y } from "./hooks/exportCsv.js";
|
|
15
|
+
import { useImportCsv as _ } from "./hooks/importCsv.js";
|
|
16
|
+
import { initRouter as ee } from "./router/route.js";
|
|
17
|
+
import { useAuthStore as oe } from "./stores/auth.js";
|
|
18
|
+
import { useRouteStore as ue } from "./stores/route.js";
|
|
19
|
+
import { useTabStore as pe } from "./stores/tab.js";
|
|
20
|
+
import { useManageStore as xe } from "./stores/manage.js";
|
|
21
|
+
import { useI18nStore as ae } from "./stores/i18n.js";
|
|
22
|
+
import { DuxLogo as ie } from "./components/common/logo.js";
|
|
23
|
+
import { default as Ce } from "./components/loader/iframe.js";
|
|
24
|
+
import { DuxOverlay as De } from "./components/overlay/overlay.js";
|
|
25
|
+
import { DuxCan as ve } from "./components/auth/can.js";
|
|
26
|
+
import { arrayToTree as Me, searchTree as ye, treeToArr as Le } from "./utils/tree.js";
|
|
27
|
+
import { DuxAppProvider as he } from "./provider/app.js";
|
|
28
|
+
import { DuxTabRouterView as Se } from "./provider/tab.js";
|
|
29
|
+
import { simpleAuthProvider as ce } from "./preset/authProvider.js";
|
|
30
|
+
import { simpleDataProvider as we } from "./preset/dataProvider.js";
|
|
31
|
+
import { i18nProvider as Oe } from "./preset/i18nProvider.js";
|
|
29
32
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
he as DuxAppProvider,
|
|
34
|
+
ve as DuxCan,
|
|
35
|
+
Ce as DuxLoaderIframe,
|
|
36
|
+
ie as DuxLogo,
|
|
37
|
+
De as DuxOverlay,
|
|
38
|
+
Se as DuxTabRouterView,
|
|
39
|
+
Me as arrayToTree,
|
|
37
40
|
o as createDux,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
Oe as i18nProvider,
|
|
42
|
+
ee as initRouter,
|
|
43
|
+
ye as searchTree,
|
|
44
|
+
ce as simpleAuthProvider,
|
|
45
|
+
we as simpleDataProvider,
|
|
46
|
+
Le as treeToArr,
|
|
47
|
+
oe as useAuthStore,
|
|
45
48
|
u as useCan,
|
|
46
49
|
s as useCheck,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
g as useClient,
|
|
51
|
+
l as useConfig,
|
|
52
|
+
v as useCreate,
|
|
53
|
+
I as useCreateMany,
|
|
54
|
+
M as useCustom,
|
|
55
|
+
y as useCustomMutation,
|
|
56
|
+
L as useDelete,
|
|
57
|
+
T as useDeleteMany,
|
|
55
58
|
p as useError,
|
|
56
59
|
N as useExport,
|
|
57
|
-
|
|
60
|
+
Y as useExportCsv,
|
|
61
|
+
m as useForgotPassword,
|
|
58
62
|
J as useForm,
|
|
59
|
-
|
|
63
|
+
x as useGetAuth,
|
|
60
64
|
q as useI18n,
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
ae as useI18nStore,
|
|
66
|
+
W as useImport,
|
|
67
|
+
_ as useImportCsv,
|
|
68
|
+
h as useInfiniteList,
|
|
63
69
|
P as useInvalidate,
|
|
64
|
-
|
|
70
|
+
f as useIsLogin,
|
|
65
71
|
S as useList,
|
|
66
|
-
|
|
72
|
+
a as useLogin,
|
|
67
73
|
n as useLogout,
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
O as useManage,
|
|
75
|
+
xe as useManageStore,
|
|
70
76
|
A as useMany,
|
|
71
|
-
|
|
77
|
+
b as useMenu,
|
|
72
78
|
c as useOne,
|
|
73
79
|
V as useOverlay,
|
|
74
80
|
i as useRegister,
|
|
75
|
-
|
|
81
|
+
ue as useRouteStore,
|
|
76
82
|
B as useSelect,
|
|
77
|
-
|
|
83
|
+
pe as useTabStore,
|
|
78
84
|
k as useTheme,
|
|
79
85
|
R as useUpdate,
|
|
80
86
|
w as useUpdateMany,
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -13,7 +13,8 @@ import { useManageStore as T } from "../stores/manage.js";
|
|
|
13
13
|
import { useI18nStore as W } from "../stores/i18n.js";
|
|
14
14
|
import "@vueuse/core";
|
|
15
15
|
import "clsx";
|
|
16
|
-
|
|
16
|
+
import "json-2-csv";
|
|
17
|
+
const de = /* @__PURE__ */ O({
|
|
17
18
|
name: "DuxAppProvider",
|
|
18
19
|
props: {},
|
|
19
20
|
setup(X, {
|
|
@@ -142,5 +143,5 @@ const he = /* @__PURE__ */ O({
|
|
|
142
143
|
}
|
|
143
144
|
});
|
|
144
145
|
export {
|
|
145
|
-
|
|
146
|
+
de as DuxAppProvider
|
|
146
147
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InfiniteData } from '@tanstack/vue-query';
|
|
2
2
|
import type { IDataProviderResponse } from '../types';
|
|
3
3
|
import type { IInfiniteListParams } from './data';
|
|
4
|
-
interface IUseExportProps extends IInfiniteListParams {
|
|
4
|
+
export interface IUseExportProps extends IInfiniteListParams {
|
|
5
5
|
onSuccess?: (data: InfiniteData<IDataProviderResponse | undefined> | undefined) => void;
|
|
6
6
|
interval?: number;
|
|
7
7
|
maxPage?: number;
|
|
@@ -11,4 +11,3 @@ export declare function useExport(props: IUseExportProps): {
|
|
|
11
11
|
isLoading: import("vue").ComputedRef<boolean>;
|
|
12
12
|
trigger: () => Promise<void>;
|
|
13
13
|
};
|
|
14
|
-
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IUseExportProps } from './export';
|
|
2
|
+
export interface IUseExportCsvProps extends IUseExportProps {
|
|
3
|
+
filename?: string;
|
|
4
|
+
headers?: string[] | boolean;
|
|
5
|
+
csvOptions?: {
|
|
6
|
+
delimiter?: string;
|
|
7
|
+
quote?: string | boolean;
|
|
8
|
+
escape?: string;
|
|
9
|
+
eol?: string;
|
|
10
|
+
writeBOM?: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function useExportCsv(props: IUseExportCsvProps): {
|
|
14
|
+
data: import("vue").Ref<undefined, undefined> | import("vue").Ref<import("@tanstack/query-core").InfiniteData<import("..").IDataProviderResponse | undefined, unknown>, import("@tanstack/query-core").InfiniteData<import("..").IDataProviderResponse | undefined, unknown>>;
|
|
15
|
+
isLoading: import("vue").ComputedRef<boolean>;
|
|
16
|
+
trigger: () => Promise<void>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DefaultError, UseMutationOptions } from '@tanstack/vue-query';
|
|
2
|
+
import type { IDataProviderCustomOptions, IDataProviderError, IDataProviderResponse } from '../types';
|
|
3
|
+
interface IImportProgress {
|
|
4
|
+
totalItems: number;
|
|
5
|
+
processedItems: number;
|
|
6
|
+
totalBatches: number;
|
|
7
|
+
processedBatches: number;
|
|
8
|
+
percentage: number;
|
|
9
|
+
}
|
|
10
|
+
export interface IUseImportProps extends IDataProviderCustomOptions {
|
|
11
|
+
options?: UseMutationOptions<IDataProviderResponse, DefaultError, IDataProviderCustomOptions>;
|
|
12
|
+
onComplete?: (progress: IImportProgress) => void;
|
|
13
|
+
onProgress?: (progress: IImportProgress) => void;
|
|
14
|
+
onError?: (error: IDataProviderError) => void;
|
|
15
|
+
interval?: number;
|
|
16
|
+
chunkSize?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function useImport(props: IUseImportProps): {
|
|
19
|
+
isLoading: import("vue").ComputedRef<boolean>;
|
|
20
|
+
progress: import("vue").ComputedRef<{
|
|
21
|
+
totalItems: number;
|
|
22
|
+
processedItems: number;
|
|
23
|
+
totalBatches: number;
|
|
24
|
+
processedBatches: number;
|
|
25
|
+
percentage: number;
|
|
26
|
+
}>;
|
|
27
|
+
trigger: (data: Record<string, any>[]) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IUseImportProps } from './import';
|
|
2
|
+
export interface IUseImportCsvProps extends IUseImportProps {
|
|
3
|
+
csvOptions?: {
|
|
4
|
+
delimiter?: string;
|
|
5
|
+
wrap?: string;
|
|
6
|
+
eol?: string;
|
|
7
|
+
excelBOM?: boolean;
|
|
8
|
+
headerFields?: string[];
|
|
9
|
+
keys?: string[];
|
|
10
|
+
trimHeaderFields?: boolean;
|
|
11
|
+
trimFieldValues?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function useImportCsv(props: IUseImportCsvProps): {
|
|
15
|
+
open: () => void;
|
|
16
|
+
readFile: (file: File) => Promise<void>;
|
|
17
|
+
isLoading: import("vue").ComputedRef<boolean>;
|
|
18
|
+
progress: import("vue").ComputedRef<{
|
|
19
|
+
totalItems: number;
|
|
20
|
+
processedItems: number;
|
|
21
|
+
totalBatches: number;
|
|
22
|
+
processedBatches: number;
|
|
23
|
+
percentage: number;
|
|
24
|
+
}>;
|
|
25
|
+
trigger: (data: Record<string, any>[]) => Promise<void>;
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duxweb/dvha-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"author": "DuxWeb",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@vueuse/integrations": "^13.0.0",
|
|
44
44
|
"axios": "^1.9.0",
|
|
45
45
|
"clsx": "^2.1.1",
|
|
46
|
+
"json-2-csv": "^5.5.9",
|
|
46
47
|
"lodash-es": "^4.17.21",
|
|
47
48
|
"petite-vue-i18n": "^11.1.4",
|
|
48
49
|
"pinia": "^3.0.0",
|