@duxweb/dvha-core 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/auth/can.cjs +1 -0
- package/dist/cjs/components/status/error.cjs +1 -0
- package/dist/cjs/components/status/notAuthorized.cjs +1 -0
- package/dist/cjs/components/status/notFound.cjs +1 -0
- package/dist/cjs/directive/permission.cjs +1 -0
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/overlay.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/main.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/esm/components/auth/can.js +33 -0
- package/dist/esm/components/status/error.js +10 -0
- package/dist/esm/components/status/notAuthorized.js +10 -0
- package/dist/esm/components/status/notFound.js +10 -0
- package/dist/esm/directive/permission.js +21 -0
- package/dist/esm/hooks/auth.js +68 -60
- package/dist/esm/hooks/overlay.js +6 -2
- package/dist/esm/index.js +65 -62
- package/dist/esm/main.js +6 -5
- package/dist/esm/preset/authProvider.js +52 -48
- package/dist/esm/provider/app.js +57 -44
- package/dist/types/components/auth/can.d.ts +20 -0
- package/dist/types/components/auth/index.d.ts +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/status/error.d.ts +2 -0
- package/dist/types/components/status/notAuthorized.d.ts +2 -0
- package/dist/types/components/status/notFound.d.ts +2 -0
- package/dist/types/directive/index.d.ts +1 -0
- package/dist/types/directive/permission.d.ts +2 -0
- package/dist/types/hooks/auth.d.ts +7 -0
- package/dist/types/types/auth.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),t=require("../../hooks/auth.cjs");require("@tanstack/vue-query");require("lodash-es");require("pinia");require("vue-router");require("@vueuse/core");require("@overlastic/vue");require("clsx");const q=i.defineComponent({name:"DuxCan",props:{name:{type:String,required:!0},params:{type:Object}},setup(r,{slots:e}){const a=t.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=q;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),r=e.defineComponent({name:"DuxError",setup(){return()=>e.createVNode("div",null,[e.createVNode("h1",null,[e.createTextVNode("500")]),e.createVNode("p",null,[e.createTextVNode("Internal Server Error")])])}});module.exports=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),t=e.defineComponent({name:"DuxNotAuthorized",setup(){return()=>e.createVNode("div",null,[e.createVNode("h1",null,[e.createTextVNode("403")]),e.createVNode("p",null,[e.createTextVNode("You are not authorized to access this page")])])}});module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),t=e.defineComponent({name:"DuxNotFound",setup(){return()=>e.createVNode("div",null,[e.createVNode("h1",null,[e.createTextVNode("404")]),e.createVNode("p",null,[e.createTextVNode("Page not found")])])}});module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=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");const n={mounted(e,t){var i;const{value:r}=t;if(!r)return;u.useCan()(r)||(i=e.parentElement)==null||i.removeChild(e)}};exports.permissionDirective=n;
|
package/dist/cjs/hooks/auth.cjs
CHANGED
|
@@ -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("vue-router"),h=require("../stores/auth.cjs"),g=require("./manage.cjs");function P({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter(),i=f.ref(!1);return{mutate:async t=>{var d;i.value=!0;const n=await((d=o.config.authProvider)==null?void 0:d.login(t,o));if(i.value=!1,n!=null&&n.success){if(!(n!=null&&n.data))throw new Error("Login response data is undefined");e==null||e(n),s.login(n.data),r.push(o.getRoutePath(n.redirectTo||"/"));return}u==null||u(n)},isLoading:i}}function m({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.logout(a,o));if(t!=null&&t.success){e==null||e(t),s.logout(),r.push(o.getRoutePath(t.redirectTo||"/login"));return}u==null||u(t)}}}function w({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.check(a,o));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Check response data is undefined");s.update(t.data);return}u==null||u(t),t!=null&&t.logout&&r.push(o.getRoutePath(t.redirectTo||"/login"))}}}function R({onSuccess:e,onError:u}){const o=g.useManage(),s=h.useAuthStore(),r=c.useRouter();return{mutate:async a=>{var n;const t=await((n=o.config.authProvider)==null?void 0:n.register(a,o));if(t!=null&&t.success){if(e==null||e(t),!(t!=null&&t.data))throw new Error("Register response data is undefined");s.login(t.data),r.push(o.getRoutePath(t.redirectTo||""));return}u==null||u(t)}}}function p({onSuccess:e,onError:u}){const o=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.forgotPassword(i,o));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&s.push(o.getRoutePath(a.redirectTo));return}u==null||u(a)}}}function v({onSuccess:e,onError:u}){const o=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=o.config.authProvider)==null?void 0:t.updatePassword(i,o));if(a!=null&&a.success){e==null||e(a),a.redirectTo&&s.push(o.getRoutePath(a.redirectTo));return}u==null||u(a)}}}function T(e){const{config:u,getRoutePath:o}=g.useManage(),s=c.useRouter();return{mutate:async i=>{var t;const a=await((t=u.authProvider)==null?void 0:t.onError(i));e==null||e(a),a!=null&&a.logout&&s.push(o(a.redirectTo||"/login"))}}}function y(e){return h.useAuthStore(e).getUser()}function A(e){return h.useAuthStore(e).isLogin()}function L(e){const u=g.useManage(e),s=h.useAuthStore(e).getUser();return(i,a)=>{var t;return(t=u.config.authProvider)!=null&&t.can?u.config.authProvider.can(i,a,u,s):!0}}exports.useCan=L;exports.useCheck=w;exports.useError=T;exports.useForgotPassword=p;exports.useGetAuth=y;exports.useIsLogin=A;exports.useLogin=P;exports.useLogout=m;exports.useRegister=R;exports.useUpdatePassword=v;
|
|
@@ -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");function
|
|
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;
|
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"),u=require("./hooks/auth.cjs"),t=require("./hooks/config.cjs"),e=require("./hooks/data.cjs"),o=require("./hooks/manage.cjs"),a=require("./hooks/menu.cjs"),n=require("./hooks/theme.cjs"),i=require("./hooks/overlay.cjs"),c=require("./hooks/i18n.cjs"),d=require("./router/route.cjs"),q=require("./stores/auth.cjs"),g=require("./stores/route.cjs"),l=require("./stores/tab.cjs"),v=require("./stores/manage.cjs"),D=require("./stores/i18n.cjs"),m=require("./components/common/logo.cjs"),y=require("./components/loader/iframe.cjs"),C=require("./components/overlay/overlay.cjs"),p=require("./components/auth/can.cjs"),r=require("./utils/tree.cjs"),M=require("./provider/app.cjs"),h=require("./provider/tab.cjs"),P=require("./preset/authProvider.cjs"),T=require("./preset/dataProvider.cjs"),x=require("./preset/i18nProvider.cjs");exports.createDux=s.createDux;exports.useCan=u.useCan;exports.useCheck=u.useCheck;exports.useError=u.useError;exports.useForgotPassword=u.useForgotPassword;exports.useGetAuth=u.useGetAuth;exports.useIsLogin=u.useIsLogin;exports.useLogin=u.useLogin;exports.useLogout=u.useLogout;exports.useRegister=u.useRegister;exports.useUpdatePassword=u.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=n.useTheme;exports.useOverlay=i.useOverlay;exports.useI18n=c.useI18n;exports.initRouter=d.initRouter;exports.useAuthStore=q.useAuthStore;exports.useRouteStore=g.useRouteStore;exports.useTabStore=l.useTabStore;exports.useManageStore=v.useManageStore;exports.useI18nStore=D.useI18nStore;exports.DuxLogo=m.DuxLogo;exports.DuxLoaderIframe=y;exports.DuxOverlay=C.DuxOverlay;exports.DuxCan=p.DuxCan;exports.arrayToTree=r.arrayToTree;exports.searchTree=r.searchTree;exports.treeToArr=r.treeToArr;exports.DuxAppProvider=M.DuxAppProvider;exports.DuxTabRouterView=h.DuxTabRouterView;exports.simpleAuthProvider=P.simpleAuthProvider;exports.simpleDataProvider=T.simpleDataProvider;exports.i18nProvider=x.i18nProvider;
|
package/dist/cjs/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("pinia"),t=require("pinia-plugin-persistedstate"),u=require("vue"),c=require("./directive/permission.cjs"),s=require("./router/route.cjs");function a(r){const i=o.createPinia();return i.use(t),{install(e){console.log("%c dux-vue %c dux.cn %c","background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent");const n=u.ref();e.provide("dux.config",r),e.provide("dux.manage",n),e.directive("can",c.permissionDirective),e.use(s.initRouter(r)),e.use(i)}}}exports.createDux=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("axios");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("axios");function s(a){return{login:async(d,c)=>{var n;return await g.post(c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.login)||"/login",a==null?void 0:a.dataProviderName),d).then(t=>{var e,i,u;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.index)||"/",data:(u=t==null?void 0:t.data)==null?void 0:u.data}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},check:async(d,c)=>{var n;return await g.get((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.check)||"/check",a==null?void 0:a.dataProviderName))||"").then(t=>{var e,i;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,data:(i=t==null?void 0:t.data)==null?void 0:i.data}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},onError:async d=>{var c;return d.status===403?{logout:!0,redirectTo:((c=a==null?void 0:a.routePath)==null?void 0:c.login)||"/login",error:d}:{logout:!1,error:d}},logout:async()=>{var d;return{success:!0,redirectTo:((d=a==null?void 0:a.routePath)==null?void 0:d.login)||"/login"}},register:async(d,c)=>{var n;return await g.post((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.register)||"/register",a==null?void 0:a.dataProviderName))||"",d).then(t=>{var e,i,u;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.index)||"/",data:(u=t==null?void 0:t.data)==null?void 0:u.data}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},forgotPassword:async(d,c)=>{var n;return await g.post((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.forgotPassword)||"/forgot-password",a==null?void 0:a.dataProviderName))||"",d).then(t=>{var e,i;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.login)||"/login"}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},updatePassword:async(d,c)=>{var n;return await g.post((c==null?void 0:c.getApiUrl(((n=a==null?void 0:a.apiPath)==null?void 0:n.updatePassword)||"/update-password",a==null?void 0:a.dataProviderName))||"",d).then(t=>{var e,i;return{success:!0,message:(e=t==null?void 0:t.data)==null?void 0:e.message,redirectTo:((i=a==null?void 0:a.routePath)==null?void 0:i.login)||"/login"}}).catch(t=>{var e,i;return{success:!1,message:((i=(e=t==null?void 0:t.response)==null?void 0:e.data)==null?void 0:i.message)||(t==null?void 0:t.message)}})},can:(d,c,n,t)=>{var e;return!(!(t!=null&&t.permission)||Array.isArray(t==null?void 0:t.permission)&&!((e=t==null?void 0:t.permission)!=null&&e.includes(d))||typeof(t==null?void 0:t.permission)=="object"&&(t==null?void 0:t.permission[d])===!1)}}}exports.simpleAuthProvider=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("vue"),T=require("@overlastic/vue"),U=require("vue-router"),V=require("../hooks/auth.cjs"),B=require("../hooks/config.cjs");require("@tanstack/vue-query");const G=require("../hooks/manage.cjs");require("lodash-es");require("pinia");const H=require("../stores/auth.cjs"),J=require("../stores/route.cjs"),K=require("../stores/manage.cjs"),Q=require("../stores/i18n.cjs");require("@vueuse/core");require("clsx");const p=l=>Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"})),W=h.defineComponent({name:"DuxAppProvider",props:{},setup(l,{slots:f}){const m=h.inject("dux.manage"),s=B.useConfig(),d=U.useRouter();return d.beforeEach(async(o,X,a)=>{var $,S,R,A,M,y,_,k,z,w,D,I,O;const t=o.meta.manageName,L=o.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=K.useManageStore(t);g.isInit()||g.setConfig((R=s.manages)==null?void 0:R.find(e=>e.name===t),s);const c=J.useRouteStore(t),n=G.useManage(t),v=H.useAuthStore(t),q=Q.useI18nStore(t);if((A=n.config)!=null&&A.i18nProvider&&!q.isInit()){const e=q.getLocale();e&&((M=n.config)==null||M.i18nProvider.changeLocale(e))}if(!v.isLogin())return L?a():a({path:n.getRoutePath("login"),replace:!0});const P=e=>e==null?void 0:e.map(u=>({...u,path:n.getRoutePath(u.path||"")}));if(!c.getRouteInit()){const e=((y=n.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}}),c.setRoutes(P(((_=n.config)==null?void 0:_.menus)||[])),(k=n.config)!=null&&k.apiRoutePath)try{await((D=(w=(z=n.config)==null?void 0:z.dataProvider)==null?void 0:w.default)==null?void 0:D.custom({path:n.config.apiRoutePath,meta:{timeout:5e3}},n,v.getUser()).then(r=>{c.appendRoutes(P(r.data||[]))}))}catch(r){console.error(r)}return c.appendRoutes(u),c.getRoutes().forEach(r=>{var j,C;if(!r.path)return;const i={name:r.name,path:r.path,meta:r.meta};switch(r.loader){case"iframe":i.component=((C=(j=n.config)==null?void 0:j.components)==null?void 0:C.iframe)||(()=>Promise.resolve().then(()=>p(require("../components/loader/iframe.cjs"))));break;case"link":i.beforeEnter=()=>{var E;const N=((E=r.meta)==null?void 0:E.url)||r.path;return N&&window.open(N,"_blank"),!1},i.component=()=>Promise.resolve({template:"<div></div>"});break;default:r.component&&(i.component=r.component);break}d.addRoute(`${t}.auth`,i)}),a({path:o.fullPath,replace:!0})}const b=["","/",`/${t}`,`/${t}/`];if(b.includes(o.path)){const e=c.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 F=V.useCan(t);return(((I=o.meta)==null?void 0:I.can)===void 0||((O=o.meta)==null?void 0:O.can)===!0)&&!F(o.name)?a({name:`${t}.notAuthorized`}):a()}),()=>h.createVNode(T.OverlaysProvider,null,{default:()=>{var o;return[(o=f.default)==null?void 0:o.call(f)]}})}});exports.DuxAppProvider=W;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineComponent as a } from "vue";
|
|
2
|
+
import { useCan as i } from "../../hooks/auth.js";
|
|
3
|
+
import "@tanstack/vue-query";
|
|
4
|
+
import "lodash-es";
|
|
5
|
+
import "pinia";
|
|
6
|
+
import "vue-router";
|
|
7
|
+
import "@vueuse/core";
|
|
8
|
+
import "@overlastic/vue";
|
|
9
|
+
import "clsx";
|
|
10
|
+
const y = /* @__PURE__ */ a({
|
|
11
|
+
name: "DuxCan",
|
|
12
|
+
props: {
|
|
13
|
+
name: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: !0
|
|
16
|
+
},
|
|
17
|
+
params: {
|
|
18
|
+
type: Object
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setup(e, {
|
|
22
|
+
slots: r
|
|
23
|
+
}) {
|
|
24
|
+
const n = i();
|
|
25
|
+
return () => {
|
|
26
|
+
var m, p;
|
|
27
|
+
return n(e.name, e.params) ? (m = r.default) == null ? void 0 : m.call(r) : ((p = r.fallback) == null ? void 0 : p.call(r)) || null;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
y as DuxCan
|
|
33
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineComponent as n, createVNode as e, createTextVNode as r } from "vue";
|
|
2
|
+
const t = /* @__PURE__ */ n({
|
|
3
|
+
name: "DuxError",
|
|
4
|
+
setup() {
|
|
5
|
+
return () => e("div", null, [e("h1", null, [r("500")]), e("p", null, [r("Internal Server Error")])]);
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
t as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineComponent as o, createVNode as e, createTextVNode as t } from "vue";
|
|
2
|
+
const r = /* @__PURE__ */ o({
|
|
3
|
+
name: "DuxNotAuthorized",
|
|
4
|
+
setup() {
|
|
5
|
+
return () => e("div", null, [e("h1", null, [t("403")]), e("p", null, [t("You are not authorized to access this page")])]);
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
r as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineComponent as o, createVNode as e, createTextVNode as n } from "vue";
|
|
2
|
+
const u = /* @__PURE__ */ o({
|
|
3
|
+
name: "DuxNotFound",
|
|
4
|
+
setup() {
|
|
5
|
+
return () => e("div", null, [e("h1", null, [n("404")]), e("p", null, [n("Page not found")])]);
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
u as default
|
|
10
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useCan as m } from "../hooks/auth.js";
|
|
2
|
+
import "vue";
|
|
3
|
+
import "@tanstack/vue-query";
|
|
4
|
+
import "lodash-es";
|
|
5
|
+
import "pinia";
|
|
6
|
+
import "vue-router";
|
|
7
|
+
import "@vueuse/core";
|
|
8
|
+
import "@overlastic/vue";
|
|
9
|
+
import "clsx";
|
|
10
|
+
const l = {
|
|
11
|
+
mounted(t, i) {
|
|
12
|
+
var r;
|
|
13
|
+
const { value: o } = i;
|
|
14
|
+
if (!o)
|
|
15
|
+
return;
|
|
16
|
+
m()(o) || (r = t.parentElement) == null || r.removeChild(t);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
l as permissionDirective
|
|
21
|
+
};
|
package/dist/esm/hooks/auth.js
CHANGED
|
@@ -1,123 +1,131 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useRouter as
|
|
3
|
-
import { useAuthStore as
|
|
4
|
-
import { useManage as
|
|
5
|
-
function
|
|
6
|
-
const u =
|
|
1
|
+
import { ref as h } from "vue";
|
|
2
|
+
import { useRouter as f } from "vue-router";
|
|
3
|
+
import { useAuthStore as c } from "../stores/auth.js";
|
|
4
|
+
import { useManage as g } from "./manage.js";
|
|
5
|
+
function v({ onSuccess: e, onError: a }) {
|
|
6
|
+
const u = g(), o = c(), s = f(), r = h(!1);
|
|
7
7
|
return {
|
|
8
8
|
mutate: async (t) => {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
if (!(
|
|
9
|
+
var d;
|
|
10
|
+
r.value = !0;
|
|
11
|
+
const n = await ((d = u.config.authProvider) == null ? void 0 : d.login(t, u));
|
|
12
|
+
if (r.value = !1, n != null && n.success) {
|
|
13
|
+
if (!(n != null && n.data))
|
|
14
14
|
throw new Error("Login response data is undefined");
|
|
15
|
-
e == null || e(
|
|
15
|
+
e == null || e(n), o.login(n.data), s.push(u.getRoutePath(n.redirectTo || "/"));
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
a == null || a(n);
|
|
19
19
|
},
|
|
20
|
-
isLoading:
|
|
20
|
+
isLoading: r
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const u =
|
|
23
|
+
function R({ onSuccess: e, onError: a }) {
|
|
24
|
+
const u = g(), o = c(), s = f();
|
|
25
25
|
return {
|
|
26
|
-
mutate: async (
|
|
27
|
-
var
|
|
28
|
-
const t = await ((
|
|
26
|
+
mutate: async (i) => {
|
|
27
|
+
var n;
|
|
28
|
+
const t = await ((n = u.config.authProvider) == null ? void 0 : n.logout(i, u));
|
|
29
29
|
if (t != null && t.success) {
|
|
30
|
-
e == null || e(t),
|
|
30
|
+
e == null || e(t), o.logout(), s.push(u.getRoutePath(t.redirectTo || "/login"));
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
a == null || a(t);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
function T({ onSuccess: e, onError:
|
|
38
|
-
const u =
|
|
37
|
+
function T({ onSuccess: e, onError: a }) {
|
|
38
|
+
const u = g(), o = c(), s = f();
|
|
39
39
|
return {
|
|
40
|
-
mutate: async (
|
|
41
|
-
var
|
|
42
|
-
const t = await ((
|
|
40
|
+
mutate: async (i) => {
|
|
41
|
+
var n;
|
|
42
|
+
const t = await ((n = u.config.authProvider) == null ? void 0 : n.check(i, u));
|
|
43
43
|
if (t != null && t.success) {
|
|
44
44
|
if (e == null || e(t), !(t != null && t.data))
|
|
45
45
|
throw new Error("Check response data is undefined");
|
|
46
|
-
|
|
46
|
+
o.update(t.data);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
a == null || a(t), t != null && t.logout && s.push(u.getRoutePath(t.redirectTo || "/login"));
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function y({ onSuccess: e, onError:
|
|
54
|
-
const u =
|
|
53
|
+
function y({ onSuccess: e, onError: a }) {
|
|
54
|
+
const u = g(), o = c(), s = f();
|
|
55
55
|
return {
|
|
56
|
-
mutate: async (
|
|
57
|
-
var
|
|
58
|
-
const t = await ((
|
|
56
|
+
mutate: async (i) => {
|
|
57
|
+
var n;
|
|
58
|
+
const t = await ((n = u.config.authProvider) == null ? void 0 : n.register(i, u));
|
|
59
59
|
if (t != null && t.success) {
|
|
60
60
|
if (e == null || e(t), !(t != null && t.data))
|
|
61
61
|
throw new Error("Register response data is undefined");
|
|
62
|
-
|
|
62
|
+
o.login(t.data), s.push(u.getRoutePath(t.redirectTo || ""));
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
a == null || a(t);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function L({ onSuccess: e, onError:
|
|
70
|
-
const u =
|
|
69
|
+
function L({ onSuccess: e, onError: a }) {
|
|
70
|
+
const u = g(), o = f();
|
|
71
71
|
return {
|
|
72
|
-
mutate: async (
|
|
72
|
+
mutate: async (r) => {
|
|
73
73
|
var t;
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
e == null || e(
|
|
74
|
+
const i = await ((t = u.config.authProvider) == null ? void 0 : t.forgotPassword(r, u));
|
|
75
|
+
if (i != null && i.success) {
|
|
76
|
+
e == null || e(i), i.redirectTo && o.push(u.getRoutePath(i.redirectTo));
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
a == null || a(i);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const u =
|
|
83
|
+
function U({ onSuccess: e, onError: a }) {
|
|
84
|
+
const u = g(), o = f();
|
|
85
85
|
return {
|
|
86
|
-
mutate: async (
|
|
86
|
+
mutate: async (r) => {
|
|
87
87
|
var t;
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
e == null || e(
|
|
88
|
+
const i = await ((t = u.config.authProvider) == null ? void 0 : t.updatePassword(r, u));
|
|
89
|
+
if (i != null && i.success) {
|
|
90
|
+
e == null || e(i), i.redirectTo && o.push(u.getRoutePath(i.redirectTo));
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
a == null || a(i);
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const { config:
|
|
97
|
+
function A(e) {
|
|
98
|
+
const { config: a, getRoutePath: u } = g(), o = f();
|
|
99
99
|
return {
|
|
100
|
-
mutate: async (
|
|
100
|
+
mutate: async (r) => {
|
|
101
101
|
var t;
|
|
102
|
-
const
|
|
103
|
-
e == null || e(
|
|
102
|
+
const i = await ((t = a.authProvider) == null ? void 0 : t.onError(r));
|
|
103
|
+
e == null || e(i), i != null && i.logout && o.push(u(i.redirectTo || "/login"));
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
function x(e) {
|
|
108
|
-
return
|
|
108
|
+
return c(e).getUser();
|
|
109
109
|
}
|
|
110
110
|
function F(e) {
|
|
111
|
-
return
|
|
111
|
+
return c(e).isLogin();
|
|
112
|
+
}
|
|
113
|
+
function G(e) {
|
|
114
|
+
const a = g(e), o = c(e).getUser();
|
|
115
|
+
return (r, i) => {
|
|
116
|
+
var t;
|
|
117
|
+
return (t = a.config.authProvider) != null && t.can ? a.config.authProvider.can(r, i, a, o) : !0;
|
|
118
|
+
};
|
|
112
119
|
}
|
|
113
120
|
export {
|
|
121
|
+
G as useCan,
|
|
114
122
|
T as useCheck,
|
|
115
|
-
|
|
123
|
+
A as useError,
|
|
116
124
|
L as useForgotPassword,
|
|
117
125
|
x as useGetAuth,
|
|
118
126
|
F as useIsLogin,
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
v as useLogin,
|
|
128
|
+
R as useLogout,
|
|
121
129
|
y as useRegister,
|
|
122
|
-
|
|
130
|
+
U as useUpdatePassword
|
|
123
131
|
};
|
|
@@ -3,12 +3,16 @@ import "vue";
|
|
|
3
3
|
import "clsx";
|
|
4
4
|
import "vue-router";
|
|
5
5
|
import { DuxOverlay as e } from "../components/overlay/overlay.js";
|
|
6
|
-
|
|
6
|
+
import "pinia";
|
|
7
|
+
import "lodash-es";
|
|
8
|
+
import "@tanstack/vue-query";
|
|
9
|
+
import "@vueuse/core";
|
|
10
|
+
function v() {
|
|
7
11
|
const r = t(e);
|
|
8
12
|
return {
|
|
9
13
|
show: (o) => r(o)
|
|
10
14
|
};
|
|
11
15
|
}
|
|
12
16
|
export {
|
|
13
|
-
|
|
17
|
+
v as useOverlay
|
|
14
18
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,73 +1,76 @@
|
|
|
1
1
|
import { createDux as o } from "./main.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useCan as u, useCheck as s, useError as a, useForgotPassword as p, useGetAuth as x, useIsLogin as m, useLogin as f, useLogout as n, useRegister as i, useUpdatePassword as d } from "./hooks/auth.js";
|
|
3
3
|
import { useConfig as g } from "./hooks/config.js";
|
|
4
|
-
import { useClient as
|
|
5
|
-
import { useManage as
|
|
6
|
-
import { useMenu as
|
|
7
|
-
import { useTheme as
|
|
8
|
-
import { useOverlay as
|
|
9
|
-
import { useI18n as
|
|
10
|
-
import { initRouter as
|
|
11
|
-
import { useAuthStore as
|
|
12
|
-
import { useRouteStore as
|
|
13
|
-
import { useTabStore as
|
|
14
|
-
import { useManageStore as
|
|
15
|
-
import { useI18nStore as
|
|
16
|
-
import { DuxLogo as
|
|
17
|
-
import { default as
|
|
18
|
-
import { DuxOverlay as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
4
|
+
import { useClient as C, useCreate as M, useCreateMany as v, useCustom as y, useCustomMutation as L, useDelete as T, useDeleteMany as h, useInfiniteList as I, useInvalidate as P, useList as A, useMany as S, useOne as R, useUpdate as c, useUpdateMany as w } from "./hooks/data.js";
|
|
5
|
+
import { useManage as U } from "./hooks/manage.js";
|
|
6
|
+
import { useMenu as k } from "./hooks/menu.js";
|
|
7
|
+
import { useTheme as F } from "./hooks/theme.js";
|
|
8
|
+
import { useOverlay as V } from "./hooks/overlay.js";
|
|
9
|
+
import { useI18n as q } from "./hooks/i18n.js";
|
|
10
|
+
import { initRouter as B } from "./router/route.js";
|
|
11
|
+
import { useAuthStore as J } from "./stores/auth.js";
|
|
12
|
+
import { useRouteStore as N } from "./stores/route.js";
|
|
13
|
+
import { useTabStore as W } from "./stores/tab.js";
|
|
14
|
+
import { useManageStore as Y } from "./stores/manage.js";
|
|
15
|
+
import { useI18nStore as _ } from "./stores/i18n.js";
|
|
16
|
+
import { DuxLogo as ee } from "./components/common/logo.js";
|
|
17
|
+
import { default as oe } from "./components/loader/iframe.js";
|
|
18
|
+
import { DuxOverlay as ue } from "./components/overlay/overlay.js";
|
|
19
|
+
import { DuxCan as ae } from "./components/auth/can.js";
|
|
20
|
+
import { arrayToTree as xe, searchTree as me, treeToArr as fe } from "./utils/tree.js";
|
|
21
|
+
import { DuxAppProvider as ie } from "./provider/app.js";
|
|
22
|
+
import { DuxTabRouterView as De } from "./provider/tab.js";
|
|
23
|
+
import { simpleAuthProvider as le } from "./preset/authProvider.js";
|
|
24
|
+
import { simpleDataProvider as Me } from "./preset/dataProvider.js";
|
|
25
|
+
import { i18nProvider as ye } from "./preset/i18nProvider.js";
|
|
25
26
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
ie as DuxAppProvider,
|
|
28
|
+
ae as DuxCan,
|
|
29
|
+
oe as DuxLoaderIframe,
|
|
30
|
+
ee as DuxLogo,
|
|
31
|
+
ue as DuxOverlay,
|
|
32
|
+
De as DuxTabRouterView,
|
|
33
|
+
xe as arrayToTree,
|
|
32
34
|
o as createDux,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
u as
|
|
41
|
-
|
|
35
|
+
ye as i18nProvider,
|
|
36
|
+
B as initRouter,
|
|
37
|
+
me as searchTree,
|
|
38
|
+
le as simpleAuthProvider,
|
|
39
|
+
Me as simpleDataProvider,
|
|
40
|
+
fe as treeToArr,
|
|
41
|
+
J as useAuthStore,
|
|
42
|
+
u as useCan,
|
|
43
|
+
s as useCheck,
|
|
44
|
+
C as useClient,
|
|
42
45
|
g as useConfig,
|
|
43
46
|
M as useCreate,
|
|
44
47
|
v as useCreateMany,
|
|
45
48
|
y as useCustom,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
L as useCustomMutation,
|
|
50
|
+
T as useDelete,
|
|
51
|
+
h as useDeleteMany,
|
|
52
|
+
a as useError,
|
|
53
|
+
p as useForgotPassword,
|
|
54
|
+
x as useGetAuth,
|
|
55
|
+
q as useI18n,
|
|
56
|
+
_ as useI18nStore,
|
|
57
|
+
I as useInfiniteList,
|
|
58
|
+
P as useInvalidate,
|
|
56
59
|
m as useIsLogin,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
A as useList,
|
|
61
|
+
f as useLogin,
|
|
62
|
+
n as useLogout,
|
|
63
|
+
U as useManage,
|
|
64
|
+
Y as useManageStore,
|
|
65
|
+
S as useMany,
|
|
66
|
+
k as useMenu,
|
|
67
|
+
R as useOne,
|
|
68
|
+
V as useOverlay,
|
|
66
69
|
i as useRegister,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
N as useRouteStore,
|
|
71
|
+
W as useTabStore,
|
|
72
|
+
F as useTheme,
|
|
73
|
+
c as useUpdate,
|
|
74
|
+
w as useUpdateMany,
|
|
75
|
+
d as useUpdatePassword
|
|
73
76
|
};
|
package/dist/esm/main.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createPinia as n } from "pinia";
|
|
2
2
|
import t from "pinia-plugin-persistedstate";
|
|
3
3
|
import { ref as d } from "vue";
|
|
4
|
+
import { permissionDirective as c } from "./directive/permission.js";
|
|
4
5
|
import { initRouter as u } from "./router/route.js";
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
return
|
|
6
|
+
function x(e) {
|
|
7
|
+
const o = n();
|
|
8
|
+
return o.use(t), {
|
|
8
9
|
install(r) {
|
|
9
10
|
console.log(
|
|
10
11
|
"%c dux-vue %c dux.cn %c",
|
|
@@ -13,10 +14,10 @@ function p(o) {
|
|
|
13
14
|
"background:transparent"
|
|
14
15
|
);
|
|
15
16
|
const i = d();
|
|
16
|
-
r.provide("dux.config",
|
|
17
|
+
r.provide("dux.config", e), r.provide("dux.manage", i), r.directive("can", c), r.use(u(e)), r.use(o);
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export {
|
|
21
|
-
|
|
22
|
+
x as createDux
|
|
22
23
|
};
|
|
@@ -1,113 +1,117 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import u from "axios";
|
|
2
|
+
function l(a) {
|
|
3
3
|
return {
|
|
4
|
-
login: async (
|
|
5
|
-
var
|
|
6
|
-
return await
|
|
7
|
-
var e,
|
|
4
|
+
login: async (d, c) => {
|
|
5
|
+
var n;
|
|
6
|
+
return await u.post(c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.login) || "/login", a == null ? void 0 : a.dataProviderName), d).then((t) => {
|
|
7
|
+
var e, i, g;
|
|
8
8
|
return {
|
|
9
9
|
success: !0,
|
|
10
10
|
message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
|
|
11
|
-
redirectTo: ((
|
|
12
|
-
data: (
|
|
11
|
+
redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.index) || "/",
|
|
12
|
+
data: (g = t == null ? void 0 : t.data) == null ? void 0 : g.data
|
|
13
13
|
};
|
|
14
14
|
}).catch((t) => {
|
|
15
|
-
var e,
|
|
15
|
+
var e, i;
|
|
16
16
|
return {
|
|
17
17
|
success: !1,
|
|
18
|
-
message: ((
|
|
18
|
+
message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
|
-
check: async (
|
|
23
|
-
var
|
|
24
|
-
return await
|
|
25
|
-
var e,
|
|
22
|
+
check: async (d, c) => {
|
|
23
|
+
var n;
|
|
24
|
+
return await u.get((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.check) || "/check", a == null ? void 0 : a.dataProviderName)) || "").then((t) => {
|
|
25
|
+
var e, i;
|
|
26
26
|
return {
|
|
27
27
|
success: !0,
|
|
28
28
|
message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
|
|
29
|
-
data: (
|
|
29
|
+
data: (i = t == null ? void 0 : t.data) == null ? void 0 : i.data
|
|
30
30
|
};
|
|
31
31
|
}).catch((t) => {
|
|
32
|
-
var e,
|
|
32
|
+
var e, i;
|
|
33
33
|
return {
|
|
34
34
|
success: !1,
|
|
35
|
-
message: ((
|
|
35
|
+
message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
|
-
onError: async (
|
|
40
|
-
var
|
|
41
|
-
return
|
|
39
|
+
onError: async (d) => {
|
|
40
|
+
var c;
|
|
41
|
+
return d.status === 403 ? {
|
|
42
42
|
logout: !0,
|
|
43
|
-
redirectTo: ((
|
|
44
|
-
error:
|
|
43
|
+
redirectTo: ((c = a == null ? void 0 : a.routePath) == null ? void 0 : c.login) || "/login",
|
|
44
|
+
error: d
|
|
45
45
|
} : {
|
|
46
46
|
logout: !1,
|
|
47
|
-
error:
|
|
47
|
+
error: d
|
|
48
48
|
};
|
|
49
49
|
},
|
|
50
50
|
logout: async () => {
|
|
51
|
-
var
|
|
51
|
+
var d;
|
|
52
52
|
return {
|
|
53
53
|
success: !0,
|
|
54
|
-
redirectTo: ((
|
|
54
|
+
redirectTo: ((d = a == null ? void 0 : a.routePath) == null ? void 0 : d.login) || "/login"
|
|
55
55
|
};
|
|
56
56
|
},
|
|
57
|
-
register: async (
|
|
58
|
-
var
|
|
59
|
-
return await
|
|
60
|
-
var e,
|
|
57
|
+
register: async (d, c) => {
|
|
58
|
+
var n;
|
|
59
|
+
return await u.post((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.register) || "/register", a == null ? void 0 : a.dataProviderName)) || "", d).then((t) => {
|
|
60
|
+
var e, i, g;
|
|
61
61
|
return {
|
|
62
62
|
success: !0,
|
|
63
63
|
message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
|
|
64
|
-
redirectTo: ((
|
|
65
|
-
data: (
|
|
64
|
+
redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.index) || "/",
|
|
65
|
+
data: (g = t == null ? void 0 : t.data) == null ? void 0 : g.data
|
|
66
66
|
};
|
|
67
67
|
}).catch((t) => {
|
|
68
|
-
var e,
|
|
68
|
+
var e, i;
|
|
69
69
|
return {
|
|
70
70
|
success: !1,
|
|
71
|
-
message: ((
|
|
71
|
+
message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
|
-
forgotPassword: async (
|
|
76
|
-
var
|
|
77
|
-
return await
|
|
78
|
-
var e,
|
|
75
|
+
forgotPassword: async (d, c) => {
|
|
76
|
+
var n;
|
|
77
|
+
return await u.post((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.forgotPassword) || "/forgot-password", a == null ? void 0 : a.dataProviderName)) || "", d).then((t) => {
|
|
78
|
+
var e, i;
|
|
79
79
|
return {
|
|
80
80
|
success: !0,
|
|
81
81
|
message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
|
|
82
|
-
redirectTo: ((
|
|
82
|
+
redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.login) || "/login"
|
|
83
83
|
};
|
|
84
84
|
}).catch((t) => {
|
|
85
|
-
var e,
|
|
85
|
+
var e, i;
|
|
86
86
|
return {
|
|
87
87
|
success: !1,
|
|
88
|
-
message: ((
|
|
88
|
+
message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
|
|
89
89
|
};
|
|
90
90
|
});
|
|
91
91
|
},
|
|
92
|
-
updatePassword: async (
|
|
93
|
-
var
|
|
94
|
-
return await
|
|
95
|
-
var e,
|
|
92
|
+
updatePassword: async (d, c) => {
|
|
93
|
+
var n;
|
|
94
|
+
return await u.post((c == null ? void 0 : c.getApiUrl(((n = a == null ? void 0 : a.apiPath) == null ? void 0 : n.updatePassword) || "/update-password", a == null ? void 0 : a.dataProviderName)) || "", d).then((t) => {
|
|
95
|
+
var e, i;
|
|
96
96
|
return {
|
|
97
97
|
success: !0,
|
|
98
98
|
message: (e = t == null ? void 0 : t.data) == null ? void 0 : e.message,
|
|
99
|
-
redirectTo: ((
|
|
99
|
+
redirectTo: ((i = a == null ? void 0 : a.routePath) == null ? void 0 : i.login) || "/login"
|
|
100
100
|
};
|
|
101
101
|
}).catch((t) => {
|
|
102
|
-
var e,
|
|
102
|
+
var e, i;
|
|
103
103
|
return {
|
|
104
104
|
success: !1,
|
|
105
|
-
message: ((
|
|
105
|
+
message: ((i = (e = t == null ? void 0 : t.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (t == null ? void 0 : t.message)
|
|
106
106
|
};
|
|
107
107
|
});
|
|
108
|
+
},
|
|
109
|
+
can: (d, c, n, t) => {
|
|
110
|
+
var e;
|
|
111
|
+
return !(!(t != null && t.permission) || Array.isArray(t == null ? void 0 : t.permission) && !((e = t == null ? void 0 : t.permission) != null && e.includes(d)) || typeof (t == null ? void 0 : t.permission) == "object" && (t == null ? void 0 : t.permission[d]) === !1);
|
|
108
112
|
}
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
115
|
export {
|
|
112
|
-
|
|
116
|
+
l as simpleAuthProvider
|
|
113
117
|
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { OverlaysProvider as
|
|
3
|
-
import { useRouter as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useConfig as q } from "../hooks/config.js";
|
|
1
|
+
import { defineComponent as j, inject as O, createVNode as U } from "vue";
|
|
2
|
+
import { OverlaysProvider as V } from "@overlastic/vue";
|
|
3
|
+
import { useRouter as q } from "vue-router";
|
|
4
|
+
import { useCan as B } from "../hooks/auth.js";
|
|
5
|
+
import { useConfig as G } from "../hooks/config.js";
|
|
7
6
|
import "@tanstack/vue-query";
|
|
7
|
+
import { useManage as H } from "../hooks/manage.js";
|
|
8
8
|
import "lodash-es";
|
|
9
9
|
import "pinia";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { useAuthStore as J } from "../stores/auth.js";
|
|
11
|
+
import { useRouteStore as K } from "../stores/route.js";
|
|
12
|
+
import { useManageStore as Q } from "../stores/manage.js";
|
|
13
|
+
import { useI18nStore as T } from "../stores/i18n.js";
|
|
13
14
|
import "@vueuse/core";
|
|
14
15
|
import "clsx";
|
|
15
|
-
const
|
|
16
|
+
const se = /* @__PURE__ */ j({
|
|
16
17
|
name: "DuxAppProvider",
|
|
17
18
|
props: {},
|
|
18
|
-
setup(
|
|
19
|
+
setup(W, {
|
|
19
20
|
slots: m
|
|
20
21
|
}) {
|
|
21
|
-
const f =
|
|
22
|
-
return s.beforeEach(async (
|
|
23
|
-
var v, R, b, A, S, M,
|
|
24
|
-
const t =
|
|
22
|
+
const f = O("dux.manage"), c = G(), s = q();
|
|
23
|
+
return s.beforeEach(async (a, X, n) => {
|
|
24
|
+
var v, R, b, A, S, $, M, k, w, z, I, C, y;
|
|
25
|
+
const t = a.meta.manageName, _ = a.meta.authorization === !1;
|
|
25
26
|
if (!t) {
|
|
26
27
|
const e = c.defaultManage || ((R = (v = c.manages) == null ? void 0 : v[0]) == null ? void 0 : R.name) || "";
|
|
27
|
-
return
|
|
28
|
+
return n({
|
|
28
29
|
path: `/${e}`,
|
|
29
30
|
replace: !0
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
f && (f.value = t);
|
|
33
|
-
const h =
|
|
34
|
+
const h = Q(t);
|
|
34
35
|
h.isInit() || h.setConfig((b = c.manages) == null ? void 0 : b.find((e) => e.name === t), c);
|
|
35
|
-
const p =
|
|
36
|
+
const p = K(t), r = H(t), d = J(t), l = T(t);
|
|
36
37
|
if ((A = r.config) != null && A.i18nProvider && !l.isInit()) {
|
|
37
38
|
const e = l.getLocale();
|
|
38
39
|
e && ((S = r.config) == null || S.i18nProvider.changeLocale(e));
|
|
39
40
|
}
|
|
40
41
|
if (!d.isLogin())
|
|
41
|
-
return
|
|
42
|
+
return _ ? n() : n({
|
|
42
43
|
path: r.getRoutePath("login"),
|
|
43
44
|
replace: !0
|
|
44
45
|
});
|
|
@@ -47,26 +48,35 @@ const pe = /* @__PURE__ */ L({
|
|
|
47
48
|
path: r.getRoutePath(i.path || "")
|
|
48
49
|
}));
|
|
49
50
|
if (!p.getRouteInit()) {
|
|
50
|
-
const e = ((
|
|
51
|
-
if (
|
|
51
|
+
const e = (($ = r.config) == null ? void 0 : $.components) || {}, i = [];
|
|
52
|
+
if (i.push({
|
|
52
53
|
name: `${t}.notFound`,
|
|
53
54
|
label: "404",
|
|
54
55
|
path: ":pathMatch(.*)*",
|
|
55
|
-
component: e.notFound,
|
|
56
|
-
hidden: !0
|
|
57
|
-
|
|
56
|
+
component: e.notFound || (() => import("../components/status/notFound.js")),
|
|
57
|
+
hidden: !0,
|
|
58
|
+
meta: {
|
|
59
|
+
can: !1
|
|
60
|
+
}
|
|
61
|
+
}), i.push({
|
|
58
62
|
name: `${t}.notAuthorized`,
|
|
59
63
|
label: "403",
|
|
60
64
|
path: "notAuthorized",
|
|
61
|
-
component: e.notAuthorized,
|
|
62
|
-
hidden: !0
|
|
63
|
-
|
|
65
|
+
component: e.notAuthorized || (() => import("../components/status/notAuthorized.js")),
|
|
66
|
+
hidden: !0,
|
|
67
|
+
meta: {
|
|
68
|
+
can: !1
|
|
69
|
+
}
|
|
70
|
+
}), i.push({
|
|
64
71
|
name: `${t}.error`,
|
|
65
72
|
label: "500",
|
|
66
73
|
path: "error",
|
|
67
|
-
component: e.error,
|
|
68
|
-
hidden: !0
|
|
69
|
-
|
|
74
|
+
component: e.error || (() => import("../components/status/error.js")),
|
|
75
|
+
hidden: !0,
|
|
76
|
+
meta: {
|
|
77
|
+
can: !1
|
|
78
|
+
}
|
|
79
|
+
}), p.setRoutes(g(((M = r.config) == null ? void 0 : M.menus) || [])), (k = r.config) != null && k.apiRoutePath)
|
|
70
80
|
try {
|
|
71
81
|
await ((I = (z = (w = r.config) == null ? void 0 : w.dataProvider) == null ? void 0 : z.default) == null ? void 0 : I.custom({
|
|
72
82
|
path: r.config.apiRoutePath,
|
|
@@ -80,7 +90,7 @@ const pe = /* @__PURE__ */ L({
|
|
|
80
90
|
console.error(o);
|
|
81
91
|
}
|
|
82
92
|
return p.appendRoutes(i), p.getRoutes().forEach((o) => {
|
|
83
|
-
var
|
|
93
|
+
var D, E;
|
|
84
94
|
if (!o.path)
|
|
85
95
|
return;
|
|
86
96
|
const u = {
|
|
@@ -90,13 +100,13 @@ const pe = /* @__PURE__ */ L({
|
|
|
90
100
|
};
|
|
91
101
|
switch (o.loader) {
|
|
92
102
|
case "iframe":
|
|
93
|
-
u.component = ((
|
|
103
|
+
u.component = ((E = (D = r.config) == null ? void 0 : D.components) == null ? void 0 : E.iframe) || (() => import("../components/loader/iframe.js"));
|
|
94
104
|
break;
|
|
95
105
|
case "link":
|
|
96
106
|
u.beforeEnter = () => {
|
|
97
|
-
var
|
|
98
|
-
const
|
|
99
|
-
return
|
|
107
|
+
var N;
|
|
108
|
+
const L = ((N = o.meta) == null ? void 0 : N.url) || o.path;
|
|
109
|
+
return L && window.open(L, "_blank"), !1;
|
|
100
110
|
}, u.component = () => Promise.resolve({
|
|
101
111
|
template: "<div></div>"
|
|
102
112
|
});
|
|
@@ -106,28 +116,31 @@ const pe = /* @__PURE__ */ L({
|
|
|
106
116
|
break;
|
|
107
117
|
}
|
|
108
118
|
s.addRoute(`${t}.auth`, u);
|
|
109
|
-
}),
|
|
110
|
-
path:
|
|
119
|
+
}), n({
|
|
120
|
+
path: a.fullPath,
|
|
111
121
|
replace: !0
|
|
112
122
|
});
|
|
113
123
|
}
|
|
114
124
|
const P = ["", "/", `/${t}`, `/${t}/`];
|
|
115
|
-
if (P.includes(
|
|
125
|
+
if (P.includes(a.path)) {
|
|
116
126
|
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"),
|
|
127
|
+
return !(e != null && e.path) || P.includes(e == null ? void 0 : e.path) ? (console.warn("[Dux] index route not found, skip redirect"), n()) : n({
|
|
118
128
|
path: (e == null ? void 0 : e.path) || "/",
|
|
119
129
|
replace: !0
|
|
120
130
|
});
|
|
121
131
|
}
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
const F = B(t);
|
|
133
|
+
return (((C = a.meta) == null ? void 0 : C.can) === void 0 || ((y = a.meta) == null ? void 0 : y.can) === !0) && !F(a.name) ? n({
|
|
134
|
+
name: `${t}.notAuthorized`
|
|
135
|
+
}) : n();
|
|
136
|
+
}), () => U(V, null, {
|
|
124
137
|
default: () => {
|
|
125
|
-
var
|
|
126
|
-
return [(
|
|
138
|
+
var a;
|
|
139
|
+
return [(a = m.default) == null ? void 0 : a.call(m)];
|
|
127
140
|
}
|
|
128
141
|
});
|
|
129
142
|
}
|
|
130
143
|
});
|
|
131
144
|
export {
|
|
132
|
-
|
|
145
|
+
se as DuxAppProvider
|
|
133
146
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
export declare const DuxCan: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
name: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
params: {
|
|
8
|
+
type: PropType<any>;
|
|
9
|
+
};
|
|
10
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>[] | null | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
|
+
name: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
params: {
|
|
18
|
+
type: PropType<any>;
|
|
19
|
+
};
|
|
20
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './can';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './permission';
|
|
@@ -107,3 +107,10 @@ export declare function useGetAuth(manageName?: string): import("..").IUserState
|
|
|
107
107
|
* @returns Is login
|
|
108
108
|
*/
|
|
109
109
|
export declare function useIsLogin(manageName?: string): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Can
|
|
112
|
+
* check if user can access the route
|
|
113
|
+
* @param manageName Manage name
|
|
114
|
+
* @returns Can method
|
|
115
|
+
*/
|
|
116
|
+
export declare function useCan(manageName?: string): (name: string, params?: any) => boolean;
|
|
@@ -11,6 +11,7 @@ export interface IAuthProvider {
|
|
|
11
11
|
register: (params: any, manage?: IManageHook) => Promise<IAuthLoginResponse>;
|
|
12
12
|
forgotPassword: (params: any, manage?: IManageHook) => Promise<IAuthActionResponse>;
|
|
13
13
|
updatePassword: (params: any, manage?: IManageHook) => Promise<IAuthActionResponse>;
|
|
14
|
+
can?: (name: string, params?: any, manage?: IManageHook, auth?: IUserState) => boolean;
|
|
14
15
|
onError: (error?: any) => Promise<IAuthErrorResponse>;
|
|
15
16
|
}
|
|
16
17
|
export interface IAuthActionResponse {
|