@duxweb/dvha-core 0.1.3 → 0.1.5
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/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/hooks/auth.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- 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/hooks/auth.js +1 -1
- package/dist/esm/preset/authProvider.js +60 -60
- package/dist/esm/provider/app.js +27 -27
- 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/package.json +1 -1
|
@@ -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;
|
package/dist/cjs/hooks/auth.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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)
|
|
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 g=require("axios");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("axios");function l(t){return{login:async(n,c)=>{var d;return await g.post(c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.login)||"/login",t==null?void 0:t.dataProviderName),n).then(e=>{var i,a,s;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.index)||"/",data:(s=e==null?void 0:e.data)==null?void 0:s.data}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},check:async(n,c)=>{var d;return await g.get((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.check)||"/check",t==null?void 0:t.dataProviderName))||"").then(e=>{var i,a;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,data:(a=e==null?void 0:e.data)==null?void 0:a.data}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},onError:async n=>{var c;return n.status===403?{logout:!0,redirectTo:((c=t==null?void 0:t.routePath)==null?void 0:c.login)||"/login",error:n}:{logout:!1,error:n}},logout:async()=>{var n;return{success:!0,redirectTo:((n=t==null?void 0:t.routePath)==null?void 0:n.login)||"/login"}},register:async(n,c)=>{var d;return await g.post((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.register)||"/register",t==null?void 0:t.dataProviderName))||"",n).then(e=>{var i,a,s;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.index)||"/",data:(s=e==null?void 0:e.data)==null?void 0:s.data}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},forgotPassword:async(n,c)=>{var d;return await g.post((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.forgotPassword)||"/forgot-password",t==null?void 0:t.dataProviderName))||"",n).then(e=>{var i,a;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.login)||"/login"}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},updatePassword:async(n,c)=>{var d;return await g.post((c==null?void 0:c.getApiUrl(((d=t==null?void 0:t.apiPath)==null?void 0:d.updatePassword)||"/update-password",t==null?void 0:t.dataProviderName))||"",n).then(e=>{var i,a;return{success:!0,message:(i=e==null?void 0:e.data)==null?void 0:i.message,redirectTo:((a=t==null?void 0:t.routePath)==null?void 0:a.login)||"/login"}}).catch(e=>{var i,a;return{success:!1,message:((a=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:a.message)||(e==null?void 0:e.message)}})},can:(n,c,d,e)=>{var i,a;return!(e!=null&&e.permission)||Array.isArray(e==null?void 0:e.permission)&&((i=e==null?void 0:e.permission)==null?void 0:i.length)===0||typeof(e==null?void 0:e.permission)=="object"&&Object.keys(e==null?void 0:e.permission).length===0?!0:!(Array.isArray(e==null?void 0:e.permission)&&!((a=e==null?void 0:e.permission)!=null&&a.includes(n))||typeof(e==null?void 0:e.permission)=="object"&&(e==null?void 0:e.permission[n])===!1)}}}exports.simpleAuthProvider=l;
|
|
@@ -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,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
|
+
};
|
package/dist/esm/hooks/auth.js
CHANGED
|
@@ -114,7 +114,7 @@ function G(e) {
|
|
|
114
114
|
const a = g(e), o = c(e).getUser();
|
|
115
115
|
return (r, i) => {
|
|
116
116
|
var t;
|
|
117
|
-
return (t = a.config.authProvider) != null && t.can ? a.config.authProvider.can(r, i, a, o)
|
|
117
|
+
return (t = a.config.authProvider) != null && t.can ? a.config.authProvider.can(r, i, a, o) : !0;
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
export {
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import g from "axios";
|
|
2
|
+
function m(t) {
|
|
3
3
|
return {
|
|
4
|
-
login: async (
|
|
5
|
-
var
|
|
6
|
-
return await
|
|
7
|
-
var
|
|
4
|
+
login: async (n, c) => {
|
|
5
|
+
var d;
|
|
6
|
+
return await g.post(c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.login) || "/login", t == null ? void 0 : t.dataProviderName), n).then((e) => {
|
|
7
|
+
var i, a, s;
|
|
8
8
|
return {
|
|
9
9
|
success: !0,
|
|
10
|
-
message: (
|
|
11
|
-
redirectTo: ((
|
|
12
|
-
data: (
|
|
10
|
+
message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
|
|
11
|
+
redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
|
|
12
|
+
data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
|
|
13
13
|
};
|
|
14
|
-
}).catch((
|
|
15
|
-
var
|
|
14
|
+
}).catch((e) => {
|
|
15
|
+
var i, a;
|
|
16
16
|
return {
|
|
17
17
|
success: !1,
|
|
18
|
-
message: ((
|
|
18
|
+
message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
},
|
|
22
|
-
check: async (
|
|
23
|
-
var
|
|
24
|
-
return await
|
|
25
|
-
var
|
|
22
|
+
check: async (n, c) => {
|
|
23
|
+
var d;
|
|
24
|
+
return await g.get((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.check) || "/check", t == null ? void 0 : t.dataProviderName)) || "").then((e) => {
|
|
25
|
+
var i, a;
|
|
26
26
|
return {
|
|
27
27
|
success: !0,
|
|
28
|
-
message: (
|
|
29
|
-
data: (
|
|
28
|
+
message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
|
|
29
|
+
data: (a = e == null ? void 0 : e.data) == null ? void 0 : a.data
|
|
30
30
|
};
|
|
31
|
-
}).catch((
|
|
32
|
-
var
|
|
31
|
+
}).catch((e) => {
|
|
32
|
+
var i, a;
|
|
33
33
|
return {
|
|
34
34
|
success: !1,
|
|
35
|
-
message: ((
|
|
35
|
+
message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
|
|
36
36
|
};
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
|
-
onError: async (
|
|
39
|
+
onError: async (n) => {
|
|
40
40
|
var c;
|
|
41
|
-
return
|
|
41
|
+
return n.status === 403 ? {
|
|
42
42
|
logout: !0,
|
|
43
|
-
redirectTo: ((c =
|
|
44
|
-
error:
|
|
43
|
+
redirectTo: ((c = t == null ? void 0 : t.routePath) == null ? void 0 : c.login) || "/login",
|
|
44
|
+
error: n
|
|
45
45
|
} : {
|
|
46
46
|
logout: !1,
|
|
47
|
-
error:
|
|
47
|
+
error: n
|
|
48
48
|
};
|
|
49
49
|
},
|
|
50
50
|
logout: async () => {
|
|
51
|
-
var
|
|
51
|
+
var n;
|
|
52
52
|
return {
|
|
53
53
|
success: !0,
|
|
54
|
-
redirectTo: ((
|
|
54
|
+
redirectTo: ((n = t == null ? void 0 : t.routePath) == null ? void 0 : n.login) || "/login"
|
|
55
55
|
};
|
|
56
56
|
},
|
|
57
|
-
register: async (
|
|
58
|
-
var
|
|
59
|
-
return await
|
|
60
|
-
var
|
|
57
|
+
register: async (n, c) => {
|
|
58
|
+
var d;
|
|
59
|
+
return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.register) || "/register", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
|
|
60
|
+
var i, a, s;
|
|
61
61
|
return {
|
|
62
62
|
success: !0,
|
|
63
|
-
message: (
|
|
64
|
-
redirectTo: ((
|
|
65
|
-
data: (
|
|
63
|
+
message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
|
|
64
|
+
redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.index) || "/",
|
|
65
|
+
data: (s = e == null ? void 0 : e.data) == null ? void 0 : s.data
|
|
66
66
|
};
|
|
67
|
-
}).catch((
|
|
68
|
-
var
|
|
67
|
+
}).catch((e) => {
|
|
68
|
+
var i, a;
|
|
69
69
|
return {
|
|
70
70
|
success: !1,
|
|
71
|
-
message: ((
|
|
71
|
+
message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
|
|
72
72
|
};
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
|
-
forgotPassword: async (
|
|
76
|
-
var
|
|
77
|
-
return await
|
|
78
|
-
var
|
|
75
|
+
forgotPassword: async (n, c) => {
|
|
76
|
+
var d;
|
|
77
|
+
return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.forgotPassword) || "/forgot-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
|
|
78
|
+
var i, a;
|
|
79
79
|
return {
|
|
80
80
|
success: !0,
|
|
81
|
-
message: (
|
|
82
|
-
redirectTo: ((
|
|
81
|
+
message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
|
|
82
|
+
redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
|
|
83
83
|
};
|
|
84
|
-
}).catch((
|
|
85
|
-
var
|
|
84
|
+
}).catch((e) => {
|
|
85
|
+
var i, a;
|
|
86
86
|
return {
|
|
87
87
|
success: !1,
|
|
88
|
-
message: ((
|
|
88
|
+
message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
|
|
89
89
|
};
|
|
90
90
|
});
|
|
91
91
|
},
|
|
92
|
-
updatePassword: async (
|
|
93
|
-
var
|
|
94
|
-
return await
|
|
95
|
-
var
|
|
92
|
+
updatePassword: async (n, c) => {
|
|
93
|
+
var d;
|
|
94
|
+
return await g.post((c == null ? void 0 : c.getApiUrl(((d = t == null ? void 0 : t.apiPath) == null ? void 0 : d.updatePassword) || "/update-password", t == null ? void 0 : t.dataProviderName)) || "", n).then((e) => {
|
|
95
|
+
var i, a;
|
|
96
96
|
return {
|
|
97
97
|
success: !0,
|
|
98
|
-
message: (
|
|
99
|
-
redirectTo: ((
|
|
98
|
+
message: (i = e == null ? void 0 : e.data) == null ? void 0 : i.message,
|
|
99
|
+
redirectTo: ((a = t == null ? void 0 : t.routePath) == null ? void 0 : a.login) || "/login"
|
|
100
100
|
};
|
|
101
|
-
}).catch((
|
|
102
|
-
var
|
|
101
|
+
}).catch((e) => {
|
|
102
|
+
var i, a;
|
|
103
103
|
return {
|
|
104
104
|
success: !1,
|
|
105
|
-
message: ((
|
|
105
|
+
message: ((a = (i = e == null ? void 0 : e.response) == null ? void 0 : i.data) == null ? void 0 : a.message) || (e == null ? void 0 : e.message)
|
|
106
106
|
};
|
|
107
107
|
});
|
|
108
108
|
},
|
|
109
|
-
can: (
|
|
110
|
-
var
|
|
111
|
-
return !(
|
|
109
|
+
can: (n, c, d, e) => {
|
|
110
|
+
var i, a;
|
|
111
|
+
return !(e != null && e.permission) || Array.isArray(e == null ? void 0 : e.permission) && ((i = e == null ? void 0 : e.permission) == null ? void 0 : i.length) === 0 || typeof (e == null ? void 0 : e.permission) == "object" && Object.keys(e == null ? void 0 : e.permission).length === 0 ? !0 : !(Array.isArray(e == null ? void 0 : e.permission) && !((a = e == null ? void 0 : e.permission) != null && a.includes(n)) || typeof (e == null ? void 0 : e.permission) == "object" && (e == null ? void 0 : e.permission[n]) === !1);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
export {
|
|
116
|
-
|
|
116
|
+
m as simpleAuthProvider
|
|
117
117
|
};
|
package/dist/esm/provider/app.js
CHANGED
|
@@ -21,8 +21,8 @@ const se = /* @__PURE__ */ j({
|
|
|
21
21
|
}) {
|
|
22
22
|
const f = O("dux.manage"), c = G(), s = q();
|
|
23
23
|
return s.beforeEach(async (a, X, n) => {
|
|
24
|
-
var v, R, b, A, S, $, M, k,
|
|
25
|
-
const t = a.meta.manageName,
|
|
24
|
+
var v, R, b, A, S, $, M, k, w, z, I, C, y;
|
|
25
|
+
const t = a.meta.manageName, _ = a.meta.authorization === !1;
|
|
26
26
|
if (!t) {
|
|
27
27
|
const e = c.defaultManage || ((R = (v = c.manages) == null ? void 0 : v[0]) == null ? void 0 : R.name) || "";
|
|
28
28
|
return n({
|
|
@@ -33,13 +33,13 @@ const se = /* @__PURE__ */ j({
|
|
|
33
33
|
f && (f.value = t);
|
|
34
34
|
const h = Q(t);
|
|
35
35
|
h.isInit() || h.setConfig((b = c.manages) == null ? void 0 : b.find((e) => e.name === t), c);
|
|
36
|
-
const
|
|
36
|
+
const p = K(t), r = H(t), d = J(t), l = T(t);
|
|
37
37
|
if ((A = r.config) != null && A.i18nProvider && !l.isInit()) {
|
|
38
38
|
const e = l.getLocale();
|
|
39
39
|
e && ((S = r.config) == null || S.i18nProvider.changeLocale(e));
|
|
40
40
|
}
|
|
41
41
|
if (!d.isLogin())
|
|
42
|
-
return
|
|
42
|
+
return _ ? n() : n({
|
|
43
43
|
path: r.getRoutePath("login"),
|
|
44
44
|
replace: !0
|
|
45
45
|
});
|
|
@@ -47,75 +47,75 @@ const se = /* @__PURE__ */ j({
|
|
|
47
47
|
...i,
|
|
48
48
|
path: r.getRoutePath(i.path || "")
|
|
49
49
|
}));
|
|
50
|
-
if (!
|
|
50
|
+
if (!p.getRouteInit()) {
|
|
51
51
|
const e = (($ = r.config) == null ? void 0 : $.components) || {}, i = [];
|
|
52
|
-
if (
|
|
52
|
+
if (i.push({
|
|
53
53
|
name: `${t}.notFound`,
|
|
54
54
|
label: "404",
|
|
55
55
|
path: ":pathMatch(.*)*",
|
|
56
|
-
component: e.notFound,
|
|
56
|
+
component: e.notFound || (() => import("../components/status/notFound.js")),
|
|
57
57
|
hidden: !0,
|
|
58
58
|
meta: {
|
|
59
59
|
can: !1
|
|
60
60
|
}
|
|
61
|
-
}),
|
|
61
|
+
}), i.push({
|
|
62
62
|
name: `${t}.notAuthorized`,
|
|
63
63
|
label: "403",
|
|
64
64
|
path: "notAuthorized",
|
|
65
|
-
component: e.notAuthorized,
|
|
65
|
+
component: e.notAuthorized || (() => import("../components/status/notAuthorized.js")),
|
|
66
66
|
hidden: !0,
|
|
67
67
|
meta: {
|
|
68
68
|
can: !1
|
|
69
69
|
}
|
|
70
|
-
}),
|
|
70
|
+
}), i.push({
|
|
71
71
|
name: `${t}.error`,
|
|
72
72
|
label: "500",
|
|
73
73
|
path: "error",
|
|
74
|
-
component: e.error,
|
|
74
|
+
component: e.error || (() => import("../components/status/error.js")),
|
|
75
75
|
hidden: !0,
|
|
76
76
|
meta: {
|
|
77
77
|
can: !1
|
|
78
78
|
}
|
|
79
|
-
}),
|
|
79
|
+
}), p.setRoutes(g(((M = r.config) == null ? void 0 : M.menus) || [])), (k = r.config) != null && k.apiRoutePath)
|
|
80
80
|
try {
|
|
81
|
-
await ((I = (
|
|
81
|
+
await ((I = (z = (w = r.config) == null ? void 0 : w.dataProvider) == null ? void 0 : z.default) == null ? void 0 : I.custom({
|
|
82
82
|
path: r.config.apiRoutePath,
|
|
83
83
|
meta: {
|
|
84
84
|
timeout: 5e3
|
|
85
85
|
}
|
|
86
86
|
}, r, d.getUser()).then((o) => {
|
|
87
|
-
|
|
87
|
+
p.appendRoutes(g(o.data || []));
|
|
88
88
|
}));
|
|
89
89
|
} catch (o) {
|
|
90
90
|
console.error(o);
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return p.appendRoutes(i), p.getRoutes().forEach((o) => {
|
|
93
93
|
var D, E;
|
|
94
94
|
if (!o.path)
|
|
95
95
|
return;
|
|
96
|
-
const
|
|
96
|
+
const u = {
|
|
97
97
|
name: o.name,
|
|
98
98
|
path: o.path,
|
|
99
99
|
meta: o.meta
|
|
100
100
|
};
|
|
101
101
|
switch (o.loader) {
|
|
102
102
|
case "iframe":
|
|
103
|
-
|
|
103
|
+
u.component = ((E = (D = r.config) == null ? void 0 : D.components) == null ? void 0 : E.iframe) || (() => import("../components/loader/iframe.js"));
|
|
104
104
|
break;
|
|
105
105
|
case "link":
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
const
|
|
109
|
-
return
|
|
110
|
-
},
|
|
106
|
+
u.beforeEnter = () => {
|
|
107
|
+
var N;
|
|
108
|
+
const L = ((N = o.meta) == null ? void 0 : N.url) || o.path;
|
|
109
|
+
return L && window.open(L, "_blank"), !1;
|
|
110
|
+
}, u.component = () => Promise.resolve({
|
|
111
111
|
template: "<div></div>"
|
|
112
112
|
});
|
|
113
113
|
break;
|
|
114
114
|
default:
|
|
115
|
-
o.component && (
|
|
115
|
+
o.component && (u.component = o.component);
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
|
-
s.addRoute(`${t}.auth`,
|
|
118
|
+
s.addRoute(`${t}.auth`, u);
|
|
119
119
|
}), n({
|
|
120
120
|
path: a.fullPath,
|
|
121
121
|
replace: !0
|
|
@@ -123,14 +123,14 @@ const se = /* @__PURE__ */ j({
|
|
|
123
123
|
}
|
|
124
124
|
const P = ["", "/", `/${t}`, `/${t}/`];
|
|
125
125
|
if (P.includes(a.path)) {
|
|
126
|
-
const e =
|
|
126
|
+
const e = p.getIndexRoute();
|
|
127
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({
|
|
128
128
|
path: (e == null ? void 0 : e.path) || "/",
|
|
129
129
|
replace: !0
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
const
|
|
133
|
-
return (((C = a.meta) == null ? void 0 : C.can) === void 0 || ((y = a.meta) == null ? void 0 : y.can) === !0) && !
|
|
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
134
|
name: `${t}.notAuthorized`
|
|
135
135
|
}) : n();
|
|
136
136
|
}), () => U(V, null, {
|
|
@@ -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;
|