@duxweb/dvha-core 0.1.1 → 0.1.2
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/hooks/i18n.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{simple → preset}/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -0
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/stores/i18n.cjs +1 -0
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/esm/hooks/i18n.js +25 -0
- package/dist/esm/index.js +45 -39
- package/dist/esm/preset/i18nProvider.js +22 -0
- package/dist/esm/provider/app.js +57 -54
- package/dist/esm/stores/i18n.js +31 -0
- package/dist/esm/stores/manage.js +18 -18
- package/dist/types/hooks/i18n.d.ts +5 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/preset/i18nProvider.d.ts +3 -0
- package/dist/types/{simple → preset}/index.d.ts +1 -0
- package/dist/types/stores/i18n.d.ts +22 -0
- package/dist/types/stores/index.d.ts +1 -0
- package/dist/types/stores/route.d.ts +525 -0
- package/dist/types/stores/tab.d.ts +210 -0
- package/dist/types/types/config.d.ts +2 -0
- package/dist/types/types/i18n.d.ts +10 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/manage.d.ts +2 -0
- package/package.json +2 -1
- package/dist/cjs/{simple → preset}/authProvider.cjs +0 -0
- package/dist/esm/{simple → preset}/authProvider.js +0 -0
- package/dist/esm/{simple → preset}/dataProvider.js +1 -1
- /package/dist/types/{simple → preset}/authProvider.d.ts +0 -0
- /package/dist/types/{simple → preset}/dataProvider.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("pinia");require("vue");require("lodash-es");const a=require("../stores/i18n.cjs"),u=require("./manage.cjs");function s(){const i=a.useI18nStore(),o=u.useManage();return{t:(e,n,r)=>{var t,c;return(c=(t=o.config)==null?void 0:t.i18nProvider)==null?void 0:c.t(e,n,r)},changeLocale:e=>{var n,r;return i.setLocale(e),(r=(n=o.config)==null?void 0:n.i18nProvider)==null?void 0:r.changeLocale(e)},getLocale:()=>{var e,n;return(n=(e=o.config)==null?void 0:e.i18nProvider)==null?void 0:n.getLocale()}}}exports.useI18n=s;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./main.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"),d=require("./router/route.cjs"),g=require("./stores/auth.cjs"),q=require("./stores/route.cjs"),l=require("./stores/tab.cjs"),v=require("./stores/manage.cjs"),m=require("./stores/i18n.cjs"),y=require("./components/common/logo.cjs"),p=require("./components/loader/iframe.cjs"),D=require("./components/overlay/overlay.cjs"),u=require("./utils/tree.cjs"),M=require("./provider/app.cjs"),h=require("./provider/tab.cjs"),P=require("./preset/authProvider.cjs"),T=require("./preset/dataProvider.cjs"),C=require("./preset/i18nProvider.cjs");exports.createDux=s.createDux;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.initRouter=d.initRouter;exports.useAuthStore=g.useAuthStore;exports.useRouteStore=q.useRouteStore;exports.useTabStore=l.useTabStore;exports.useManageStore=v.useManageStore;exports.useI18nStore=m.useI18nStore;exports.DuxLogo=y.DuxLogo;exports.DuxLoaderIframe=p;exports.DuxOverlay=D.DuxOverlay;exports.arrayToTree=u.arrayToTree;exports.searchTree=u.searchTree;exports.treeToArr=u.treeToArr;exports.DuxAppProvider=M.DuxAppProvider;exports.DuxTabRouterView=h.DuxTabRouterView;exports.simpleAuthProvider=P.simpleAuthProvider;exports.simpleDataProvider=T.simpleDataProvider;exports.i18nProvider=C.i18nProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("axios"),g=require("lodash-es");function l(i){const t=e=>e?`${i.apiUrl}/${g.trimStart(e||"","/")}`:i.apiUrl;return{apiUrl:t,getList:(e,n,r)=>{const a={};return e.pagination&&typeof e.pagination=="object"&&(a.page=e.pagination.page,a.limit=e.pagination.limit,a.pageSize=e.pagination.pageSize),d.get(t(e.path)||"",{params:{...a,...e.filters,...e.sorters},headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(m=>m.data)},create:(e,n,r)=>d.post(t(e.path)||"",e.data,{headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),update:(e,n,r)=>d.put(t(e.id?`${e.path}/${e.id}`:e.path)||"",e.data,{headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),deleteOne:(e,n,r)=>d.delete(t(e.id?`${e.path}/${e.id}`:e.path)||"",{headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),getOne:(e,n,r)=>d.get(t(e.id?`${e.path}/${e.id}`:e.path)||"",{headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),getMany:(e,n,r)=>d.get(t(e.path)||"",{params:{ids:e.ids},headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),createMany:(e,n,r)=>d.post(t(e.path)||"",e.data,{headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),updateMany:(e,n,r)=>d.put(t(e.path)||"",{ids:e.ids,data:e.data},{headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),deleteMany:(e,n,r)=>d.delete(t(e.path)||"",{params:{ids:e.ids},headers:{Authorization:r==null?void 0:r.token},...e.meta}).then(a=>a.data),custom:(e,n,r)=>{let a={...e.query};return e.sorters&&typeof e.sorters=="object"&&(a={...a,...e.sorters}),e.filters&&typeof e.filters=="object"&&(a={...a,...e.filters}),d.request({url:t(e.path||""),method:e.method||"GET",data:e.payload,params:a,headers:{Authorization:r==null?void 0:r.token,...e.headers},...e.meta}).then(m=>m.data)}}}exports.simpleDataProvider=l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("petite-vue-i18n");function i(e){const t=n.createI18n({legacy:!1,locale:e==null?void 0:e.locale,fallbackLocale:e==null?void 0:e.fallbackLocale,messages:e==null?void 0:e.messages});return{t:(l,c,a)=>t.global.t(l,c)||a||"",changeLocale:(l,c)=>new Promise(a=>{t.global.locale.value=l,a(l)}),loadLocale:(l,c)=>new Promise(a=>{t.global.setLocaleMessage(l,c),a(l)}),getLocale:()=>t.global.locale.value}}exports.i18nProvider=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),C=require("@overlastic/vue"),E=require("vue-router"),F=require("../stores/auth.cjs"),L=require("../hooks/manage.cjs"),T=require("../hooks/config.cjs");require("@tanstack/vue-query");require("lodash-es");require("pinia");const U=require("../stores/route.cjs"),V=require("../stores/manage.cjs"),B=require("../stores/i18n.cjs");require("@vueuse/core");require("clsx");const G=h=>Object.freeze(Object.defineProperty({__proto__:null,default:h},Symbol.toStringTag,{value:"Module"})),H=f.defineComponent({name:"DuxAppProvider",props:{},setup(h,{slots:p}){const l=f.inject("dux.manage"),s=T.useConfig(),d=E.useRouter();return d.beforeEach(async(n,J,a)=>{var b,S,R,$,A,M,y,_,k,z,w;const t=n.meta.manageName,N=n.meta.authorization===!1;if(!t){const e=s.defaultManage||((S=(b=s.manages)==null?void 0:b[0])==null?void 0:S.name)||"";return a({path:`/${e}`,replace:!0})}l&&(l.value=t);const m=V.useManageStore(t);m.isInit()||m.setConfig((R=s.manages)==null?void 0:R.find(e=>e.name===t),s);const i=U.useRouteStore(t),o=L.useManage(t),g=F.useAuthStore(t),v=B.useI18nStore(t);if(($=o.config)!=null&&$.i18nProvider&&!v.isInit()){const e=v.getLocale();e&&((A=o.config)==null||A.i18nProvider.changeLocale(e))}if(!g.isLogin())return N?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=((M=o.config)==null?void 0:M.components)||{},u=[];if(e.notFound&&u.push({name:`${t}.notFound`,label:"404",path:":pathMatch(.*)*",component:e.notFound,hidden:!0}),e.notAuthorized&&u.push({name:`${t}.notAuthorized`,label:"403",path:"notAuthorized",component:e.notAuthorized,hidden:!0}),e.error&&u.push({name:`${t}.error`,label:"500",path:"error",component:e.error,hidden:!0}),i.setRoutes(P(((y=o.config)==null?void 0:y.menus)||[])),(_=o.config)!=null&&_.apiRoutePath)try{await((w=(z=(k=o.config)==null?void 0:k.dataProvider)==null?void 0:z.default)==null?void 0:w.custom({path:o.config.apiRoutePath,meta:{timeout:5e3}},o,g.getUser()).then(r=>{i.appendRoutes(P(r.data||[]))}))}catch(r){console.error(r)}return i.appendRoutes(u),i.getRoutes().forEach(r=>{var D,I;if(!r.path)return;const c={name:r.name,path:r.path,meta:r.meta};switch(r.loader){case"iframe":c.component=((I=(D=o.config)==null?void 0:D.components)==null?void 0:I.iframe)||(()=>Promise.resolve().then(()=>G(require("../components/loader/iframe.cjs"))));break;case"link":c.beforeEnter=()=>{var j;const O=((j=r.meta)==null?void 0:j.url)||r.path;return O&&window.open(O,"_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:n.fullPath,replace:!0})}const q=["","/",`/${t}`,`/${t}/`];if(q.includes(n.path)){const e=i.getIndexRoute();return!(e!=null&&e.path)||q.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})}return a()}),()=>f.createVNode(C.OverlaysProvider,null,{default:()=>{var n;return[(n=p.default)==null?void 0:n.call(p)]}})}});exports.DuxAppProvider=H;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("pinia"),o=require("vue");function u(t){const e=o.inject("dux.manage");if(t||(t=(e==null?void 0:e.value)||""),!t)throw new Error("manage not found");return c(t)()}function c(t){return i.defineStore(`i18n-${t}`,()=>{const e=o.ref(""),n=o.ref(!1);return{lang:e,isInit:()=>{const r=n.value;return n.value=!0,r},setLocale:r=>{e.value=r},getLocale:()=>e.value}},{persist:{pick:["lang"]}})}exports.useI18nStore=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("lodash-es"),p=require("pinia"),o=require("vue");function v(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)&&typeof r.getList!="function"}function h(r){const i=o.inject("dux.manage");if(r||(r=(i==null?void 0:i.value)||""),!r)throw new Error("manage not found");return y(r)()}function y(r){return p.defineStore(`manages-${r}`,()=>{const i=o.ref(),c=o.ref(!1);return{config:i,isInit:()=>{const u=c.value;return c.value=!0,u},setConfig:(u,e)=>{const t=P.cloneDeep(u),n=[];t.title&&n.push(t.title),e.title&&n.push(e.title),t.title=n.join(" - "),t.copyright=t.copyright||e.copyright,t.description=t.description||e.description,t.theme={...e==null?void 0:e.theme,...t==null?void 0:t.theme};const d={};e!=null&&e.dataProvider&&(v(e.dataProvider)?Object.keys(e.dataProvider).forEach(s=>{d[s]=e.dataProvider[s]}):d.default=e.dataProvider),t!=null&&t.dataProvider&&(v(t.dataProvider)?Object.keys(t.dataProvider).forEach(s=>{d[s]=t.dataProvider[s]}):d.default=t.dataProvider),t.authProvider=(e==null?void 0:e.authProvider)||(t==null?void 0:t.authProvider),t.dataProvider=d,t.i18nProvider=(e==null?void 0:e.i18nProvider)||(t==null?void 0:t.i18nProvider),t.layoutComponent={...e.layoutComponent,...t.layoutComponent},i.value=t},getConfig:()=>i.value}})}exports.useManageStore=h;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "pinia";
|
|
2
|
+
import "vue";
|
|
3
|
+
import "lodash-es";
|
|
4
|
+
import { useI18nStore as a } from "../stores/i18n.js";
|
|
5
|
+
import { useManage as g } from "./manage.js";
|
|
6
|
+
function h() {
|
|
7
|
+
const i = a(), n = g();
|
|
8
|
+
return {
|
|
9
|
+
t: (e, o, t) => {
|
|
10
|
+
var r, c;
|
|
11
|
+
return (c = (r = n.config) == null ? void 0 : r.i18nProvider) == null ? void 0 : c.t(e, o, t);
|
|
12
|
+
},
|
|
13
|
+
changeLocale: (e) => {
|
|
14
|
+
var o, t;
|
|
15
|
+
return i.setLocale(e), (t = (o = n.config) == null ? void 0 : o.i18nProvider) == null ? void 0 : t.changeLocale(e);
|
|
16
|
+
},
|
|
17
|
+
getLocale: () => {
|
|
18
|
+
var e, o;
|
|
19
|
+
return (o = (e = n.config) == null ? void 0 : e.i18nProvider) == null ? void 0 : o.getLocale();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
h as useI18n
|
|
25
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,67 +1,73 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
2
|
import { useCheck as u, useError as s, useForgotPassword as a, useGetAuth as p, useIsLogin as m, useLogin as x, useLogout as f, useRegister as i, useUpdatePassword as n } from "./hooks/auth.js";
|
|
3
3
|
import { useConfig as g } from "./hooks/config.js";
|
|
4
|
-
import { useClient as D, useCreate as M, useCreateMany as
|
|
4
|
+
import { useClient as D, useCreate as M, useCreateMany as v, useCustom as y, useCustomMutation as C, useDelete as L, useDeleteMany as T, useInfiniteList as h, useInvalidate as I, useList as P, useMany as A, useOne as S, useUpdate as R, useUpdateMany as c } from "./hooks/data.js";
|
|
5
5
|
import { useManage as O } from "./hooks/manage.js";
|
|
6
6
|
import { useMenu as b } from "./hooks/menu.js";
|
|
7
7
|
import { useTheme as E } from "./hooks/theme.js";
|
|
8
8
|
import { useOverlay as G } from "./hooks/overlay.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
9
|
+
import { useI18n as j } from "./hooks/i18n.js";
|
|
10
|
+
import { initRouter as z } from "./router/route.js";
|
|
11
|
+
import { useAuthStore as H } from "./stores/auth.js";
|
|
12
|
+
import { useRouteStore as K } from "./stores/route.js";
|
|
13
|
+
import { useTabStore as Q } from "./stores/tab.js";
|
|
14
|
+
import { useManageStore as X } from "./stores/manage.js";
|
|
15
|
+
import { useI18nStore as Z } from "./stores/i18n.js";
|
|
16
|
+
import { DuxLogo as $ } from "./components/common/logo.js";
|
|
17
|
+
import { default as re } from "./components/loader/iframe.js";
|
|
18
|
+
import { DuxOverlay as te } from "./components/overlay/overlay.js";
|
|
19
|
+
import { arrayToTree as se, searchTree as ae, treeToArr as pe } from "./utils/tree.js";
|
|
20
|
+
import { DuxAppProvider as xe } from "./provider/app.js";
|
|
21
|
+
import { DuxTabRouterView as ie } from "./provider/tab.js";
|
|
22
|
+
import { simpleAuthProvider as de } from "./preset/authProvider.js";
|
|
23
|
+
import { simpleDataProvider as le } from "./preset/dataProvider.js";
|
|
24
|
+
import { i18nProvider as Me } from "./preset/i18nProvider.js";
|
|
22
25
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
xe as DuxAppProvider,
|
|
27
|
+
re as DuxLoaderIframe,
|
|
28
|
+
$ as DuxLogo,
|
|
29
|
+
te as DuxOverlay,
|
|
30
|
+
ie as DuxTabRouterView,
|
|
31
|
+
se as arrayToTree,
|
|
29
32
|
o as createDux,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
Me as i18nProvider,
|
|
34
|
+
z as initRouter,
|
|
35
|
+
ae as searchTree,
|
|
36
|
+
de as simpleAuthProvider,
|
|
37
|
+
le as simpleDataProvider,
|
|
38
|
+
pe as treeToArr,
|
|
39
|
+
H as useAuthStore,
|
|
36
40
|
u as useCheck,
|
|
37
41
|
D as useClient,
|
|
38
42
|
g as useConfig,
|
|
39
43
|
M as useCreate,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
v as useCreateMany,
|
|
45
|
+
y as useCustom,
|
|
46
|
+
C as useCustomMutation,
|
|
47
|
+
L as useDelete,
|
|
48
|
+
T as useDeleteMany,
|
|
45
49
|
s as useError,
|
|
46
50
|
a as useForgotPassword,
|
|
47
51
|
p as useGetAuth,
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
j as useI18n,
|
|
53
|
+
Z as useI18nStore,
|
|
54
|
+
h as useInfiniteList,
|
|
55
|
+
I as useInvalidate,
|
|
50
56
|
m as useIsLogin,
|
|
51
57
|
P as useList,
|
|
52
58
|
x as useLogin,
|
|
53
59
|
f as useLogout,
|
|
54
60
|
O as useManage,
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
X as useManageStore,
|
|
62
|
+
A as useMany,
|
|
57
63
|
b as useMenu,
|
|
58
|
-
|
|
64
|
+
S as useOne,
|
|
59
65
|
G as useOverlay,
|
|
60
66
|
i as useRegister,
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
K as useRouteStore,
|
|
68
|
+
Q as useTabStore,
|
|
63
69
|
E as useTheme,
|
|
64
|
-
|
|
70
|
+
R as useUpdate,
|
|
65
71
|
c as useUpdateMany,
|
|
66
72
|
n as useUpdatePassword
|
|
67
73
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createI18n as n } from "petite-vue-i18n";
|
|
2
|
+
function g(e) {
|
|
3
|
+
const c = n({
|
|
4
|
+
legacy: !1,
|
|
5
|
+
locale: e == null ? void 0 : e.locale,
|
|
6
|
+
fallbackLocale: e == null ? void 0 : e.fallbackLocale,
|
|
7
|
+
messages: e == null ? void 0 : e.messages
|
|
8
|
+
});
|
|
9
|
+
return {
|
|
10
|
+
t: (l, t, a) => c.global.t(l, t) || a || "",
|
|
11
|
+
changeLocale: (l, t) => new Promise((a) => {
|
|
12
|
+
c.global.locale.value = l, a(l);
|
|
13
|
+
}),
|
|
14
|
+
loadLocale: (l, t) => new Promise((a) => {
|
|
15
|
+
c.global.setLocaleMessage(l, t), a(l);
|
|
16
|
+
}),
|
|
17
|
+
getLocale: () => c.global.locale.value
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
g as i18nProvider
|
|
22
|
+
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -1,130 +1,133 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { OverlaysProvider as
|
|
3
|
-
import { useRouter as
|
|
4
|
-
import { useAuthStore as
|
|
5
|
-
import { useManage as
|
|
6
|
-
import { useConfig as
|
|
1
|
+
import { defineComponent as L, inject as N, createVNode as _ } from "vue";
|
|
2
|
+
import { OverlaysProvider as j } from "@overlastic/vue";
|
|
3
|
+
import { useRouter as O } from "vue-router";
|
|
4
|
+
import { useAuthStore as U } from "../stores/auth.js";
|
|
5
|
+
import { useManage as V } from "../hooks/manage.js";
|
|
6
|
+
import { useConfig as q } from "../hooks/config.js";
|
|
7
7
|
import "@tanstack/vue-query";
|
|
8
8
|
import "lodash-es";
|
|
9
9
|
import "pinia";
|
|
10
|
-
import { useRouteStore as
|
|
11
|
-
import { useManageStore as
|
|
10
|
+
import { useRouteStore as B } from "../stores/route.js";
|
|
11
|
+
import { useManageStore as G } from "../stores/manage.js";
|
|
12
|
+
import { useI18nStore as H } from "../stores/i18n.js";
|
|
12
13
|
import "@vueuse/core";
|
|
13
14
|
import "clsx";
|
|
14
|
-
const
|
|
15
|
+
const pe = /* @__PURE__ */ L({
|
|
15
16
|
name: "DuxAppProvider",
|
|
16
17
|
props: {},
|
|
17
|
-
setup(
|
|
18
|
+
setup(J, {
|
|
18
19
|
slots: m
|
|
19
20
|
}) {
|
|
20
|
-
const f =
|
|
21
|
-
return s.beforeEach(async (
|
|
22
|
-
var
|
|
23
|
-
const t =
|
|
21
|
+
const f = N("dux.manage"), c = q(), s = O();
|
|
22
|
+
return s.beforeEach(async (n, K, a) => {
|
|
23
|
+
var v, R, b, A, S, M, $, k, w, z, I;
|
|
24
|
+
const t = n.meta.manageName, F = n.meta.authorization === !1;
|
|
24
25
|
if (!t) {
|
|
25
|
-
const e = c.defaultManage || ((R = (
|
|
26
|
-
return
|
|
26
|
+
const e = c.defaultManage || ((R = (v = c.manages) == null ? void 0 : v[0]) == null ? void 0 : R.name) || "";
|
|
27
|
+
return a({
|
|
27
28
|
path: `/${e}`,
|
|
28
29
|
replace: !0
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
f && (f.value = t);
|
|
32
|
-
const h =
|
|
33
|
+
const h = G(t);
|
|
33
34
|
h.isInit() || h.setConfig((b = c.manages) == null ? void 0 : b.find((e) => e.name === t), c);
|
|
34
|
-
const
|
|
35
|
+
const p = B(t), r = V(t), d = U(t), l = H(t);
|
|
36
|
+
if ((A = r.config) != null && A.i18nProvider && !l.isInit()) {
|
|
37
|
+
const e = l.getLocale();
|
|
38
|
+
e && ((S = r.config) == null || S.i18nProvider.changeLocale(e));
|
|
39
|
+
}
|
|
35
40
|
if (!d.isLogin())
|
|
36
|
-
return
|
|
41
|
+
return F ? a() : a({
|
|
37
42
|
path: r.getRoutePath("login"),
|
|
38
43
|
replace: !0
|
|
39
44
|
});
|
|
40
|
-
const
|
|
41
|
-
...
|
|
42
|
-
path: r.getRoutePath(
|
|
45
|
+
const g = (e) => e == null ? void 0 : e.map((i) => ({
|
|
46
|
+
...i,
|
|
47
|
+
path: r.getRoutePath(i.path || "")
|
|
43
48
|
}));
|
|
44
|
-
if (!
|
|
45
|
-
const e = ((
|
|
46
|
-
if (e.notFound &&
|
|
49
|
+
if (!p.getRouteInit()) {
|
|
50
|
+
const e = ((M = r.config) == null ? void 0 : M.components) || {}, i = [];
|
|
51
|
+
if (e.notFound && i.push({
|
|
47
52
|
name: `${t}.notFound`,
|
|
48
53
|
label: "404",
|
|
49
54
|
path: ":pathMatch(.*)*",
|
|
50
55
|
component: e.notFound,
|
|
51
56
|
hidden: !0
|
|
52
|
-
}), e.notAuthorized &&
|
|
57
|
+
}), e.notAuthorized && i.push({
|
|
53
58
|
name: `${t}.notAuthorized`,
|
|
54
59
|
label: "403",
|
|
55
60
|
path: "notAuthorized",
|
|
56
61
|
component: e.notAuthorized,
|
|
57
62
|
hidden: !0
|
|
58
|
-
}), e.error &&
|
|
63
|
+
}), e.error && i.push({
|
|
59
64
|
name: `${t}.error`,
|
|
60
65
|
label: "500",
|
|
61
66
|
path: "error",
|
|
62
67
|
component: e.error,
|
|
63
68
|
hidden: !0
|
|
64
|
-
}),
|
|
65
|
-
console.log("config", r.config.default);
|
|
69
|
+
}), p.setRoutes(g((($ = r.config) == null ? void 0 : $.menus) || [])), (k = r.config) != null && k.apiRoutePath)
|
|
66
70
|
try {
|
|
67
|
-
await ((
|
|
71
|
+
await ((I = (z = (w = r.config) == null ? void 0 : w.dataProvider) == null ? void 0 : z.default) == null ? void 0 : I.custom({
|
|
68
72
|
path: r.config.apiRoutePath,
|
|
69
73
|
meta: {
|
|
70
74
|
timeout: 5e3
|
|
71
75
|
}
|
|
72
76
|
}, r, d.getUser()).then((o) => {
|
|
73
|
-
|
|
77
|
+
p.appendRoutes(g(o.data || []));
|
|
74
78
|
}));
|
|
75
79
|
} catch (o) {
|
|
76
80
|
console.error(o);
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var w, z;
|
|
82
|
+
return p.appendRoutes(i), p.getRoutes().forEach((o) => {
|
|
83
|
+
var y, C;
|
|
81
84
|
if (!o.path)
|
|
82
85
|
return;
|
|
83
|
-
const
|
|
86
|
+
const u = {
|
|
84
87
|
name: o.name,
|
|
85
88
|
path: o.path,
|
|
86
89
|
meta: o.meta
|
|
87
90
|
};
|
|
88
91
|
switch (o.loader) {
|
|
89
92
|
case "iframe":
|
|
90
|
-
|
|
93
|
+
u.component = ((C = (y = r.config) == null ? void 0 : y.components) == null ? void 0 : C.iframe) || (() => import("../components/loader/iframe.js"));
|
|
91
94
|
break;
|
|
92
95
|
case "link":
|
|
93
|
-
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
},
|
|
96
|
+
u.beforeEnter = () => {
|
|
97
|
+
var E;
|
|
98
|
+
const D = ((E = o.meta) == null ? void 0 : E.url) || o.path;
|
|
99
|
+
return D && window.open(D, "_blank"), !1;
|
|
100
|
+
}, u.component = () => Promise.resolve({
|
|
98
101
|
template: "<div></div>"
|
|
99
102
|
});
|
|
100
103
|
break;
|
|
101
104
|
default:
|
|
102
|
-
o.component && (
|
|
105
|
+
o.component && (u.component = o.component);
|
|
103
106
|
break;
|
|
104
107
|
}
|
|
105
|
-
s.addRoute(`${t}.auth`,
|
|
106
|
-
}),
|
|
107
|
-
path:
|
|
108
|
+
s.addRoute(`${t}.auth`, u);
|
|
109
|
+
}), a({
|
|
110
|
+
path: n.fullPath,
|
|
108
111
|
replace: !0
|
|
109
112
|
});
|
|
110
113
|
}
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
const e =
|
|
114
|
-
return !(e != null && e.path) ||
|
|
114
|
+
const P = ["", "/", `/${t}`, `/${t}/`];
|
|
115
|
+
if (P.includes(n.path)) {
|
|
116
|
+
const e = p.getIndexRoute();
|
|
117
|
+
return !(e != null && e.path) || P.includes(e == null ? void 0 : e.path) ? (console.warn("[Dux] index route not found, skip redirect"), a()) : a({
|
|
115
118
|
path: (e == null ? void 0 : e.path) || "/",
|
|
116
119
|
replace: !0
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
|
-
return
|
|
120
|
-
}), () =>
|
|
122
|
+
return a();
|
|
123
|
+
}), () => _(j, null, {
|
|
121
124
|
default: () => {
|
|
122
|
-
var
|
|
123
|
-
return [(
|
|
125
|
+
var n;
|
|
126
|
+
return [(n = m.default) == null ? void 0 : n.call(m)];
|
|
124
127
|
}
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
});
|
|
128
131
|
export {
|
|
129
|
-
|
|
132
|
+
pe as DuxAppProvider
|
|
130
133
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineStore as i } from "pinia";
|
|
2
|
+
import { inject as c, ref as r } from "vue";
|
|
3
|
+
function p(e) {
|
|
4
|
+
const t = c("dux.manage");
|
|
5
|
+
if (e || (e = (t == null ? void 0 : t.value) || ""), !e)
|
|
6
|
+
throw new Error("manage not found");
|
|
7
|
+
return u(e)();
|
|
8
|
+
}
|
|
9
|
+
function u(e) {
|
|
10
|
+
return i(`i18n-${e}`, () => {
|
|
11
|
+
const t = r(""), n = r(!1);
|
|
12
|
+
return {
|
|
13
|
+
lang: t,
|
|
14
|
+
isInit: () => {
|
|
15
|
+
const o = n.value;
|
|
16
|
+
return n.value = !0, o;
|
|
17
|
+
},
|
|
18
|
+
setLocale: (o) => {
|
|
19
|
+
t.value = o;
|
|
20
|
+
},
|
|
21
|
+
getLocale: () => t.value
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
persist: {
|
|
25
|
+
pick: ["lang"]
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
p as useI18nStore
|
|
31
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
2
|
-
import { defineStore as
|
|
3
|
-
import { inject as h, ref as
|
|
4
|
-
function
|
|
1
|
+
import { cloneDeep as P } from "lodash-es";
|
|
2
|
+
import { defineStore as p } from "pinia";
|
|
3
|
+
import { inject as h, ref as n } from "vue";
|
|
4
|
+
function v(e) {
|
|
5
5
|
return e != null && typeof e == "object" && !Array.isArray(e) && typeof e.getList != "function";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function a(e) {
|
|
8
8
|
const i = h("dux.manage");
|
|
9
9
|
if (e || (e = (i == null ? void 0 : i.value) || ""), !e)
|
|
10
10
|
throw new Error("manage not found");
|
|
11
|
-
return
|
|
11
|
+
return y(e)();
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
15
|
-
const i =
|
|
13
|
+
function y(e) {
|
|
14
|
+
return p(`manages-${e}`, () => {
|
|
15
|
+
const i = n(), s = n(!1);
|
|
16
16
|
return {
|
|
17
17
|
config: i,
|
|
18
18
|
isInit: () => {
|
|
19
|
-
const
|
|
20
|
-
return
|
|
19
|
+
const u = s.value;
|
|
20
|
+
return s.value = !0, u;
|
|
21
21
|
},
|
|
22
|
-
setConfig: (
|
|
23
|
-
const t =
|
|
24
|
-
t.title &&
|
|
22
|
+
setConfig: (u, r) => {
|
|
23
|
+
const t = P(u), o = [];
|
|
24
|
+
t.title && o.push(t.title), r.title && o.push(r.title), t.title = o.join(" - "), t.copyright = t.copyright || r.copyright, t.description = t.description || r.description, t.theme = { ...r == null ? void 0 : r.theme, ...t == null ? void 0 : t.theme };
|
|
25
25
|
const d = {};
|
|
26
|
-
r != null && r.dataProvider && (
|
|
26
|
+
r != null && r.dataProvider && (v(r.dataProvider) ? Object.keys(r.dataProvider).forEach((c) => {
|
|
27
27
|
d[c] = r.dataProvider[c];
|
|
28
|
-
}) : d.default = r.dataProvider), t != null && t.dataProvider && (
|
|
28
|
+
}) : d.default = r.dataProvider), t != null && t.dataProvider && (v(t.dataProvider) ? Object.keys(t.dataProvider).forEach((c) => {
|
|
29
29
|
d[c] = t.dataProvider[c];
|
|
30
|
-
}) : d.default = t.dataProvider), t.authProvider = (r == null ? void 0 : r.authProvider) || (t == null ? void 0 : t.authProvider), t.dataProvider = d, t.layoutComponent = {
|
|
30
|
+
}) : d.default = t.dataProvider), t.authProvider = (r == null ? void 0 : r.authProvider) || (t == null ? void 0 : t.authProvider), t.dataProvider = d, t.i18nProvider = (r == null ? void 0 : r.i18nProvider) || (t == null ? void 0 : t.i18nProvider), t.layoutComponent = {
|
|
31
31
|
...r.layoutComponent,
|
|
32
32
|
...t.layoutComponent
|
|
33
33
|
}, i.value = t;
|
|
@@ -37,5 +37,5 @@ function a(e) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
a as useManageStore
|
|
41
41
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* use i18n store
|
|
4
|
+
* @param manageName manage name
|
|
5
|
+
* @returns i18n store
|
|
6
|
+
*/
|
|
7
|
+
export declare function useI18nStore(manageName?: string): import("pinia").Store<`i18n-${string}`, Pick<{
|
|
8
|
+
lang: Ref<string, string>;
|
|
9
|
+
isInit: () => boolean;
|
|
10
|
+
setLocale: (value: string) => void;
|
|
11
|
+
getLocale: () => string;
|
|
12
|
+
}, "lang">, Pick<{
|
|
13
|
+
lang: Ref<string, string>;
|
|
14
|
+
isInit: () => boolean;
|
|
15
|
+
setLocale: (value: string) => void;
|
|
16
|
+
getLocale: () => string;
|
|
17
|
+
}, never>, Pick<{
|
|
18
|
+
lang: Ref<string, string>;
|
|
19
|
+
isInit: () => boolean;
|
|
20
|
+
setLocale: (value: string) => void;
|
|
21
|
+
getLocale: () => string;
|
|
22
|
+
}, "isInit" | "setLocale" | "getLocale">>;
|