@duxweb/dvha-core 1.0.39 → 1.0.41
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/loader/remote/loader.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +2 -2
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/stores/route.cjs +1 -1
- package/dist/esm/components/loader/remote/loader.js +81 -76
- package/dist/esm/hooks/auth.js +65 -62
- package/dist/esm/hooks/theme.js +39 -37
- package/dist/esm/preset/authProvider.js +15 -15
- package/dist/esm/stores/route.js +18 -15
- package/dist/types/stores/route.d.ts +2 -1
- package/dist/types/types/theme.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("vue"),$=require("@tanstack/vue-query"),C=require("@vueuse/core"),W=require("axios"),_=require("crypto-js"),E=require("dayjs"),T=require("lodash-es"),k=require("mathjs"),q=require("mime"),L=require("mitt"),D=require("pinia"),J=require("vue3-sfc-loader"),N=require("vue-router"),V=require("../../../hooks/auth.cjs"),B=require("../../../hooks/data.cjs");require("json-2-csv");require("@vee-validate/rules");require("vee-validate");const F=require("../../../hooks/i18n.cjs"),Q=require("../../../hooks/json.cjs");require("../../../hooks/json/index.cjs");const U=require("../../../hooks/manage.cjs");require("../../../utils/bus.cjs");require("@overlastic/vue");require("clsx");require("colorizr");const z=require("../../../index.cjs");function u(n){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const h=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(a,o,h.get?h:{enumerable:!0,get:()=>n[o]})}}return a.default=n,Object.freeze(a)}const A=u(v),H=u($),I=u(C),G=u(T),K=u(k),X=u(D),Y=u(N),y=new Map;function Z(n){return _.MD5(n).toString().substring(0,10)}function ee(n){const a=B.useClient(),{mutate:o}=V.useError(),{mergeLocale:h}=F.useI18n(),{config:d}=U.useManage(),j={moduleCache:{vue:A,"@duxweb/dvha-core":z,"@vueuse/core":I,"@tanstack/vue-query":H,axios:W,"crypto-js":_,mime:q,math:K,mitt:L,"lodash-es":G,pinia:X,dayjs:E,"vue-router":Y,...d?.remote?.packages,"static!":function(e,t,r){const s=q.getType(r);if(s?.startsWith("image"))return`data:${s};charset=utf-8;base64,${btoa(e)}`;if(r===".json")return JSON.parse(e);throw new Error(`${r} unable to parse`)}},async handleModule(e,t){if(e!==".vue"){if(e===".json"){const r=await t(),{render:s}=Q.useJsonSchema({data:r?.nodes||{},context:r?.data||{}});return()=>v.createVNode(s,null,null)}if(e!==".mjs")return t()}},customBlockHandler(e){if(e.type==="i18n"){const t=JSON.parse(e.content);for(const r in t)h(r,t[r])}},getFile:async e=>{e=g(e,".vue"),e=g(e,".json");const t=await a.request({path:typeof d?.remote?.apiRoutePath=="function"?d?.remote?.apiRoutePath(e):d?.remote?.apiRoutePath||"static",payload:{path:e},method:d?.remote?.apiMethod||"POST"}).then(s=>s?.data).catch(s=>{o(s)});if(!t)return;let r=t?.type||".vue";return(t?.type?.endsWith("js")||t?.type?.endsWith("ts")||t?.type?.endsWith("jsx")||t?.type?.endsWith("tsx"))&&(r=".mjs"),{content:t?.content,type:r}},getResource({refPath:e,relPath:t},r){const{moduleCache:s,pathResolve:b,getFile:S}=r,[w,...p]=t.match(/([^!]+!)|[^!]+$/g).reverse(),P=(c,m,l,f)=>p.reduce((O,M)=>s[M](O,m,l,f),c),i=b({refPath:e,relPath:w},r),x=p.join("")+i,R=c=>c.startsWith("@")?!0:!c.includes("/")&&!c.startsWith(".");return{id:x,path:i,async getContent(){if(R(i))throw new Error(`Package ${i} not imported`);const c=await S(i),{content:m,type:l}=c||{};return{getContentData:async f=>P(m,i,l,r),type:l}}}},addStyle(e){const t=Z(e);if(y.has(t))return;y.set(t,!0);const r=document.createElement("style");r.textContent=e,r.setAttribute("data-hash",t),document.head.appendChild(r)}};return()=>J.loadModule(`${n}`,{...j})}function g(n,a){const o=new RegExp(`${a}$`);return n.replace(o,"")}exports.sfcLoader=ee;
|
package/dist/cjs/hooks/auth.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 S=require("vue"),g=require("vue-router"),c=require("../stores/auth.cjs");require("pinia");require("lodash-es");const h=require("../stores/route.cjs"),i=require("./manage.cjs");function l(t){const e=i.useManage(),u=c.useAuthStore(),s=h.useRouteStore(),n=g.useRouter(),r=S.ref(!1);return{mutate:async d=>{r.value=!0;const a=await e.config.authProvider?.login(d,e);if(r.value=!1,a?.success){if(!a?.data)throw new Error("Login response data is undefined");s.resetRouteInit(),t?.onSuccess?.(a),u.login(a.data),n.push(e.getRoutePath(a.redirectTo||"/"));return}t?.onError?.(a)},isLoading:r}}function m(t){const e=i.useManage(),u=c.useAuthStore(),s=g.useRouter();return{mutate:async r=>{const o=await e.config.authProvider?.logout(r,e);if(o?.success){t?.onSuccess?.(o),u.logout(),await s.replace(e.getRoutePath(o.redirectTo||"/login")),setTimeout(()=>{window.location.reload()},100);return}t?.onError?.(o)}}}function w(t){const e=i.useManage(),u=c.useAuthStore(),{mutate:s}=f();return{mutate:async r=>{const o=await e.config.authProvider?.check?.(r,e,u.getUser());if(o?.success){if(t?.onSuccess?.(o),!o?.data)throw new Error("Check response data is undefined");u.update(o.data);return}t?.onError?.(o),o?.logout&&s({status:401,message:o.message||"Unauthorized"})}}}function P(t){const e=i.useManage(),u=c.useAuthStore(),s=g.useRouter();return{mutate:async r=>{const o=await e.config.authProvider?.register?.(r,e);if(o?.success){if(t?.onSuccess?.(o),!o?.data)throw new Error("Register response data is undefined");u.login(o.data),s.push(e.getRoutePath(o.redirectTo||"/"));return}t?.onError?.(o)}}}function R(t){const e=i.useManage(),u=g.useRouter();return{mutate:async n=>{const r=await e.config.authProvider?.forgotPassword?.(n,e);if(r?.success){t?.onSuccess?.(r),r.redirectTo&&u.push(e.getRoutePath(r.redirectTo||"/"));return}t?.onError?.(r)}}}function v(t){const e=i.useManage(),u=g.useRouter();return{mutate:async n=>{const r=await e.config.authProvider?.updatePassword?.(n,e);if(r?.success){t?.onSuccess?.(r),r.redirectTo&&u.push(e.getRoutePath(r.redirectTo||"/"));return}t?.onError?.(r)}}}function f(t){const{config:e,getRoutePath:u}=i.useManage(),s=g.useRouter(),n=c.useAuthStore(e.name),r=h.useRouteStore(e.name);return{mutate:async d=>{const a=await e.authProvider?.onError(d);t?.(a),a?.logout&&(await n.logout(),await r.resetRouteInit(),await s.replace(u(a.redirectTo||"/login")),setTimeout(()=>{},100))}}}function E(t){return c.useAuthStore(t).getUser()}function T(t){return c.useAuthStore(t).isLogin()}function A(t){const e=i.useManage(t),s=c.useAuthStore(t).getUser();return(r,o)=>e.config.authProvider?.can?e.config.authProvider.can(r,o,e,s):!0}exports.useCan=A;exports.useCheck=w;exports.useError=f;exports.useForgotPassword=R;exports.useGetAuth=E;exports.useIsLogin=T;exports.useLogin=l;exports.useLogout=m;exports.useRegister=P;exports.useUpdatePassword=v;
|
package/dist/cjs/hooks/theme.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("@vueuse/core"),F=require("colorizr"),H=require("pinia"),s=require("vue"),J=require("../config/color.cjs");require("lodash-es");const K=require("../stores/theme.cjs"),Q=require("./manage.cjs");function W(){const u=K.useThemeStore(),{mode:E}=H.storeToRefs(u),$=q.useColorMode({storageRef:E}),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("@vueuse/core"),F=require("colorizr"),H=require("pinia"),s=require("vue"),J=require("../config/color.cjs");require("lodash-es");const K=require("../stores/theme.cjs"),Q=require("./manage.cjs");function W(){const u=K.useThemeStore(),{mode:E}=H.storeToRefs(u),$=q.useColorMode({storageRef:E}),d=Q.useManage(),{state:S,next:L,go:v}=q.useCycleList(["dark","light","auto"],{initialValue:$.store.value});s.watchEffect(()=>{$.value=S.value});const V=t=>{switch(t){case"auto":v(2);break;case"light":v(1);break;case"dark":v(0);break}},f=s.computed(()=>{const{system:t,store:e}=$;return e.value==="auto"?t.value==="dark":e.value==="dark"}),y=s.computed(()=>f.value?{logo:d.config?.theme?.darkLogo,appLogo:d.config?.theme?.appDarkLogo,banner:d.config?.theme?.darkBanner}:{logo:d.config?.theme?.logo,appLogo:d.config?.theme?.appLogo,banner:d.config?.theme?.banner}),r={...{colors:J.themeColor,colorTypes:["primary","info","success","warning","error","gray"],colorShades:["50","100","200","300","400","500","600","700","800","900","950"],colorScenes:{light:{default:{default:"600",hover:"600",pressed:"700",focus:"500",disabled:"300"}},dark:{default:{default:"500",hover:"400",pressed:"300",focus:"500",disabled:"600"}}},colorSemantic:{light:{text:{dimmed:"300",muted:"400",toned:"600",base:"800",highlighted:"900",inverted:"white"},bg:{base:"white",muted:"50",elevated:"100",accented:"200",inverted:"900"},border:{base:"100",muted:"200",accented:"300",inverted:"900"}},dark:{text:{dimmed:"600",muted:"500",toned:"300",base:"400",highlighted:"100",inverted:"black"},bg:{base:"950",muted:"900",elevated:"800",accented:"700",inverted:"100"},border:{base:"900",muted:"800",accented:"700",inverted:"100"}}},colorBase:{white:"#ffffff",black:"#000000"}},...d.config?.theme?.config},{colorShades:C,colorTypes:k}=r,g=s.computed(()=>u.theme),h=s.computed(()=>Object.keys(r.colors)),x=["default","hover","pressed","focus","disabled"];function B(){return f.value?r.colorScenes.dark:r.colorScenes.light}function w(t,e){const o=B(),l=o.default;if(o.overrides?.[t]){const i=o.overrides[t]?.[e];if(i)return i}return l[e]||"500"}function T(t,e){const o=g.value[t];return r.colors[o]?.[e]||""}function n(t,e,o){const c=(f.value?r.colorSemantic.dark:r.colorSemantic.light)[t][e];return c==="white"||c==="black"?`var(--ui-color-${c})`:`var(--base-color-${o}-${c})`}const p=t=>{const e=F.hex2rgb(t);return`${e.r} ${e.g} ${e.b}`};function M(){const t=[];Object.entries(r.colors).forEach(([c,i])=>{typeof i=="object"&&Object.entries(i).forEach(([a,m])=>{try{t.push(`--base-color-${c}-${a}: ${p(m)};`)}catch{t.push(`--base-color-${c}-${a}: ${m};`)}})});const e=[];k.forEach(c=>{const i=g.value[c];C.forEach(a=>{e.push(`--ui-color-${c}-${a}: var(--base-color-${i}-${a});`)}),x.forEach(a=>{const m=w(c,a);a==="default"?e.push(`--ui-color-${c}: var(--base-color-${i}-${m});`):e.push(`--ui-color-${c}-${a}: var(--base-color-${i}-${m});`)})});const o=g.value.gray,l=[`--ui-color-white: ${p(r.colorBase?.white||"#ffffff")};`,`--ui-color-black: ${p(r.colorBase?.black||"#000000")};`,`--ui-text-dimmed: ${n("text","dimmed",o)};`,`--ui-text-muted: ${n("text","muted",o)};`,`--ui-text-toned: ${n("text","toned",o)};`,`--ui-text: ${n("text","base",o)};`,`--ui-text-highlighted: ${n("text","highlighted",o)};`,`--ui-text-inverted: ${n("text","inverted",o)};`,`--ui-bg: ${n("bg","base",o)};`,`--ui-bg-muted: ${n("bg","muted",o)};`,`--ui-bg-elevated: ${n("bg","elevated",o)};`,`--ui-bg-accented: ${n("bg","accented",o)};`,`--ui-bg-inverted: ${n("bg","inverted",o)};`,`--ui-border: ${n("border","base",o)};`,`--ui-border-muted: ${n("border","muted",o)};`,`--ui-border-accented: ${n("border","accented",o)};`,`--ui-border-inverted: ${n("border","inverted",o)};`];return`:root {
|
|
2
2
|
${t.join(`
|
|
3
3
|
`)}
|
|
4
4
|
${e.join(`
|
|
5
5
|
`)}
|
|
6
6
|
${l.join(`
|
|
7
7
|
`)}
|
|
8
|
-
}`}let
|
|
8
|
+
}`}let b=null;function j(){const t=M();b||(b=document.createElement("style"),b.id="dvha-variables",document.head.appendChild(b)),b.textContent=t}function O(){u.cssInit||(u.setCssInit(),j())}s.watch([g,f],()=>{u.cssInit&&j()},{deep:!0,immediate:!1});function I(t,e){h.value.includes(e)?u.setThemeColor(t,e):console.warn(`Color "${e}" is not available`)}function z(t){u.setThemeColors(t)}function R(){u.resetTheme()}function D(t,e,o=!1){return o?`--ui-color-${t}-${e}`:T(t,e)}function U(t,e,o=!1){if(e||(e="default"),o)return e==="default"?`--ui-color-${t})`:`--ui-color-${t}-${e})`;const l=w(t,e);return T(t,l)}function G(t,e,o=!1){if(o){let a;switch(t){case"text":a=e==="base"?"--ui-text":`--ui-text-${e}`;break;case"bg":a=e==="base"?"--ui-bg":`--ui-bg-${e}`;break;case"border":a=e==="base"?"--ui-border":`--ui-border-${e}`;break;default:a=`--ui-${t}-${e}`}return`${a}`}const l=g.value.gray,i=(f.value?r.colorSemantic.dark:r.colorSemantic.light)[t][e];return i==="white"?r.colorBase?.white||"#ffffff":i==="black"?r.colorBase?.black||"#000000":r.colors[l]?.[i]||""}const P=s.computed(()=>h.value?.filter(t=>["slate","gray","zinc","neutral","stone"].includes(t))),A=s.computed(()=>h.value?.filter(t=>!["slate","gray","zinc","neutral","stone"].includes(t)));return{toggle:L,mode:S,setMode:V,isDark:f,resources:y,config:s.readonly(r),colorMapping:s.readonly(g),colors:h,neutralColors:P,primaryColors:A,colorShades:C,colorTypes:k,colorScenes:x,cssInit:O,cssReset:R,setColor:I,setColors:z,getSceneColor:U,getShadeColor:D,getSemanticColor:G}}exports.useTheme=W;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("axios");function n(s){return{login:async(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("axios");function n(s){return{login:async(t,r)=>await i.post(r.getApiUrl(s?.apiPath?.login||"/login",s?.dataProviderName),t).then(e=>({success:!0,message:e?.data?.message,redirectTo:s?.routePath?.index||"/",data:e?.data?.data})).catch(e=>({success:!1,message:e?.response?.data?.message||e?.message})),check:async(t,r,e)=>await i.get(r?.getApiUrl(s?.apiPath?.check||"/check",s?.dataProviderName)||"",{headers:{Authorization:e?.token||""}}).then(a=>({success:!0,logout:!1,message:a?.data?.message,data:a?.data?.data})).catch(a=>({success:!1,logout:a.status===401,message:a?.response?.data?.message||a?.message})),onError:async t=>t?.status===401?{logout:!0,redirectTo:s?.routePath?.login||"/login",error:t}:{logout:!1,error:t},logout:async()=>({success:!0,redirectTo:s?.routePath?.login||"/login"}),register:async(t,r)=>await i.post(r?.getApiUrl(s?.apiPath?.register||"/register",s?.dataProviderName)||"",t).then(e=>({success:!0,message:e?.data?.message,redirectTo:s?.routePath?.index||"/",data:e?.data?.data})).catch(e=>({success:!1,message:e?.response?.data?.message||e?.message})),forgotPassword:async(t,r)=>await i.post(r?.getApiUrl(s?.apiPath?.forgotPassword||"/forgot-password",s?.dataProviderName)||"",t).then(e=>({success:!0,message:e?.data?.message,redirectTo:s?.routePath?.login||"/login"})).catch(e=>({success:!1,message:e?.response?.data?.message||e?.message})),updatePassword:async(t,r)=>await i.post(r?.getApiUrl(s?.apiPath?.updatePassword||"/update-password",s?.dataProviderName)||"",t).then(e=>({success:!0,message:e?.data?.message,redirectTo:s?.routePath?.login||"/login"})).catch(e=>({success:!1,message:e?.response?.data?.message||e?.message})),can:(t,r,e,a)=>!a?.permission||Array.isArray(a?.permission)&&a?.permission?.length===0||typeof a?.permission=="object"&&Object.keys(a?.permission).length===0?!0:!(Array.isArray(a?.permission)&&!a?.permission?.includes(t)||typeof a?.permission=="object"&&a?.permission[t]===!1)}}exports.simpleAuthProvider=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("pinia"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("pinia"),a=require("vue");function I(r){const t=a.inject("dux.manage");if(r||(r=t?.value||""),!r)throw new Error("manage not found");return b(r)()}function b(r){return g.defineStore(`routes-${r}`,()=>{const t=a.ref([]),l=e=>t.value?.find(n=>n.path===e),f=e=>t.value?.find(n=>n.name===e),d=e=>{t.value?.push(e)},v=e=>{t.value=[...t.value,...e]},R=e=>{t.value=e},p=()=>t.value,h=()=>{t.value=[]},S=()=>{const e=t.value?.filter(o=>!o.parent&&!o.name?.includes("404")&&!o.name?.includes("403"))?.sort((o,u)=>(o.sort||0)-(u.sort||0)),n=o=>{if(o.path)return o;const u=t.value?.filter(s=>s.parent===o.name)?.sort((s,c)=>(s.sort||0)-(c.sort||0));for(const s of u||[]){const c=n(s);if(c)return c}};for(const o of e||[]){const u=n(o);if(u)return u}},i=a.ref(!1);return{routes:t,searchRoute:l,searchRouteName:f,appendRoute:d,appendRoutes:v,setRoutes:R,getRoutes:p,clearRoutes:h,getIndexRoute:S,getRouteInit:()=>{const e=i.value;return i.value=!0,e},resetRouteInit:()=>{i.value=!1}}})}exports.useRouteStore=I;
|
|
@@ -1,149 +1,154 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as E from "vue";
|
|
2
2
|
import { createVNode as M } from "vue";
|
|
3
3
|
import * as b from "@tanstack/vue-query";
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
4
|
+
import * as k from "@vueuse/core";
|
|
5
|
+
import J from "axios";
|
|
6
|
+
import g from "crypto-js";
|
|
7
|
+
import T from "dayjs";
|
|
8
|
+
import * as L from "lodash-es";
|
|
9
|
+
import * as N from "mathjs";
|
|
10
10
|
import h from "mime";
|
|
11
|
-
import
|
|
12
|
-
import * as
|
|
13
|
-
import { loadModule as
|
|
14
|
-
import * as
|
|
15
|
-
import {
|
|
16
|
-
import { useClient as
|
|
11
|
+
import O from "mitt";
|
|
12
|
+
import * as _ from "pinia";
|
|
13
|
+
import { loadModule as q } from "vue3-sfc-loader";
|
|
14
|
+
import * as B from "vue-router";
|
|
15
|
+
import { useError as D } from "../../../hooks/auth.js";
|
|
16
|
+
import { useClient as F } from "../../../hooks/data.js";
|
|
17
17
|
import "json-2-csv";
|
|
18
18
|
import "@vee-validate/rules";
|
|
19
19
|
import "vee-validate";
|
|
20
|
-
import { useI18n as
|
|
21
|
-
import { useJsonSchema as
|
|
20
|
+
import { useI18n as V } from "../../../hooks/i18n.js";
|
|
21
|
+
import { useJsonSchema as A } from "../../../hooks/json.js";
|
|
22
22
|
import "../../../hooks/json/index.js";
|
|
23
|
+
import { useManage as H } from "../../../hooks/manage.js";
|
|
23
24
|
import "../../../utils/bus.js";
|
|
24
25
|
import "@overlastic/vue";
|
|
25
26
|
import "clsx";
|
|
26
27
|
import "colorizr";
|
|
27
|
-
import * as
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return
|
|
28
|
+
import * as I from "../../../index.js";
|
|
29
|
+
const l = /* @__PURE__ */ new Map();
|
|
30
|
+
function Q(s) {
|
|
31
|
+
return g.MD5(s).toString().substring(0, 10);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
const c =
|
|
34
|
-
|
|
35
|
-
} =
|
|
33
|
+
function ft(s) {
|
|
34
|
+
const c = F(), {
|
|
35
|
+
mutate: u
|
|
36
|
+
} = D(), {
|
|
37
|
+
mergeLocale: v
|
|
38
|
+
} = V(), {
|
|
36
39
|
config: i
|
|
37
|
-
} =
|
|
40
|
+
} = H(), j = {
|
|
38
41
|
moduleCache: {
|
|
39
|
-
vue:
|
|
40
|
-
"@duxweb/dvha-core":
|
|
41
|
-
"@vueuse/core":
|
|
42
|
+
vue: E,
|
|
43
|
+
"@duxweb/dvha-core": I,
|
|
44
|
+
"@vueuse/core": k,
|
|
42
45
|
"@tanstack/vue-query": b,
|
|
43
|
-
axios:
|
|
44
|
-
"crypto-js":
|
|
46
|
+
axios: J,
|
|
47
|
+
"crypto-js": g,
|
|
45
48
|
mime: h,
|
|
46
|
-
math:
|
|
47
|
-
mitt:
|
|
48
|
-
"lodash-es":
|
|
49
|
-
pinia:
|
|
50
|
-
dayjs:
|
|
51
|
-
"vue-router":
|
|
49
|
+
math: N,
|
|
50
|
+
mitt: O,
|
|
51
|
+
"lodash-es": L,
|
|
52
|
+
pinia: _,
|
|
53
|
+
dayjs: T,
|
|
54
|
+
"vue-router": B,
|
|
52
55
|
...i?.remote?.packages,
|
|
53
|
-
"static!": function(t,
|
|
54
|
-
const o = h.getType(
|
|
56
|
+
"static!": function(t, e, r) {
|
|
57
|
+
const o = h.getType(r);
|
|
55
58
|
if (o?.startsWith("image"))
|
|
56
59
|
return `data:${o};charset=utf-8;base64,${btoa(t)}`;
|
|
57
|
-
if (
|
|
60
|
+
if (r === ".json")
|
|
58
61
|
return JSON.parse(t);
|
|
59
|
-
throw new Error(`${
|
|
62
|
+
throw new Error(`${r} unable to parse`);
|
|
60
63
|
}
|
|
61
64
|
},
|
|
62
|
-
async handleModule(t,
|
|
65
|
+
async handleModule(t, e) {
|
|
63
66
|
if (t !== ".vue") {
|
|
64
67
|
if (t === ".json") {
|
|
65
|
-
const
|
|
68
|
+
const r = await e(), {
|
|
66
69
|
render: o
|
|
67
|
-
} =
|
|
68
|
-
data:
|
|
69
|
-
context:
|
|
70
|
+
} = A({
|
|
71
|
+
data: r?.nodes || {},
|
|
72
|
+
context: r?.data || {}
|
|
70
73
|
});
|
|
71
74
|
return () => M(o, null, null);
|
|
72
75
|
}
|
|
73
76
|
if (t !== ".mjs")
|
|
74
|
-
return
|
|
77
|
+
return e();
|
|
75
78
|
}
|
|
76
79
|
},
|
|
77
80
|
customBlockHandler(t) {
|
|
78
81
|
if (t.type === "i18n") {
|
|
79
|
-
const
|
|
80
|
-
for (const
|
|
81
|
-
|
|
82
|
+
const e = JSON.parse(t.content);
|
|
83
|
+
for (const r in e)
|
|
84
|
+
v(r, e[r]);
|
|
82
85
|
}
|
|
83
86
|
},
|
|
84
87
|
getFile: async (t) => {
|
|
85
|
-
t =
|
|
86
|
-
const
|
|
88
|
+
t = y(t, ".vue"), t = y(t, ".json");
|
|
89
|
+
const e = await c.request({
|
|
87
90
|
path: typeof i?.remote?.apiRoutePath == "function" ? i?.remote?.apiRoutePath(t) : i?.remote?.apiRoutePath || "static",
|
|
88
91
|
payload: {
|
|
89
92
|
path: t
|
|
90
93
|
},
|
|
91
94
|
method: i?.remote?.apiMethod || "POST"
|
|
92
95
|
}).then((o) => o?.data).catch((o) => {
|
|
93
|
-
|
|
96
|
+
u(o);
|
|
94
97
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
if (!e)
|
|
99
|
+
return;
|
|
100
|
+
let r = e?.type || ".vue";
|
|
101
|
+
return (e?.type?.endsWith("js") || e?.type?.endsWith("ts") || e?.type?.endsWith("jsx") || e?.type?.endsWith("tsx")) && (r = ".mjs"), {
|
|
102
|
+
content: e?.content,
|
|
103
|
+
type: r
|
|
99
104
|
};
|
|
100
105
|
},
|
|
101
106
|
getResource({
|
|
102
107
|
refPath: t,
|
|
103
|
-
relPath:
|
|
104
|
-
},
|
|
108
|
+
relPath: e
|
|
109
|
+
}, r) {
|
|
105
110
|
const {
|
|
106
111
|
moduleCache: o,
|
|
107
|
-
pathResolve:
|
|
112
|
+
pathResolve: x,
|
|
108
113
|
getFile: w
|
|
109
|
-
} =
|
|
114
|
+
} = r, [R, ...d] = e.match(/([^!]+!)|[^!]+$/g).reverse(), P = (n, p, m, f) => d.reduce((C, W) => o[W](C, p, m, f), n), a = x({
|
|
110
115
|
refPath: t,
|
|
111
|
-
relPath:
|
|
112
|
-
},
|
|
116
|
+
relPath: R
|
|
117
|
+
}, r), S = d.join("") + a, $ = (n) => n.startsWith("@") ? !0 : !n.includes("/") && !n.startsWith(".");
|
|
113
118
|
return {
|
|
114
|
-
id:
|
|
119
|
+
id: S,
|
|
115
120
|
path: a,
|
|
116
121
|
async getContent() {
|
|
117
|
-
if (
|
|
122
|
+
if ($(a))
|
|
118
123
|
throw new Error(`Package ${a} not imported`);
|
|
119
|
-
const {
|
|
120
|
-
content:
|
|
124
|
+
const n = await w(a), {
|
|
125
|
+
content: p,
|
|
121
126
|
type: m
|
|
122
|
-
} =
|
|
127
|
+
} = n || {};
|
|
123
128
|
return {
|
|
124
|
-
getContentData: async (
|
|
129
|
+
getContentData: async (f) => P(p, a, m, r),
|
|
125
130
|
type: m
|
|
126
131
|
};
|
|
127
132
|
}
|
|
128
133
|
};
|
|
129
134
|
},
|
|
130
135
|
addStyle(t) {
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
136
|
+
const e = Q(t);
|
|
137
|
+
if (l.has(e))
|
|
133
138
|
return;
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
139
|
+
l.set(e, !0);
|
|
140
|
+
const r = document.createElement("style");
|
|
141
|
+
r.textContent = t, r.setAttribute("data-hash", e), document.head.appendChild(r);
|
|
137
142
|
}
|
|
138
143
|
};
|
|
139
|
-
return () =>
|
|
140
|
-
...
|
|
144
|
+
return () => q(`${s}`, {
|
|
145
|
+
...j
|
|
141
146
|
});
|
|
142
147
|
}
|
|
143
|
-
function
|
|
148
|
+
function y(s, c) {
|
|
144
149
|
const u = new RegExp(`${c}$`);
|
|
145
150
|
return s.replace(u, "");
|
|
146
151
|
}
|
|
147
152
|
export {
|
|
148
|
-
|
|
153
|
+
ft as sfcLoader
|
|
149
154
|
};
|
package/dist/esm/hooks/auth.js
CHANGED
|
@@ -1,127 +1,130 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as h } from "vue";
|
|
2
2
|
import { useRouter as g } from "vue-router";
|
|
3
3
|
import { useAuthStore as c } from "../stores/auth.js";
|
|
4
|
+
import "pinia";
|
|
5
|
+
import "lodash-es";
|
|
6
|
+
import { useRouteStore as f } from "../stores/route.js";
|
|
4
7
|
import { useManage as i } from "./manage.js";
|
|
5
|
-
function
|
|
6
|
-
const t = i(), n = c(), u =
|
|
8
|
+
function T(e) {
|
|
9
|
+
const t = i(), n = c(), u = f(), s = g(), o = h(!1);
|
|
7
10
|
return {
|
|
8
|
-
mutate: async (
|
|
9
|
-
|
|
10
|
-
const a = await t.config.authProvider?.login(
|
|
11
|
-
if (
|
|
11
|
+
mutate: async (d) => {
|
|
12
|
+
o.value = !0;
|
|
13
|
+
const a = await t.config.authProvider?.login(d, t);
|
|
14
|
+
if (o.value = !1, a?.success) {
|
|
12
15
|
if (!a?.data)
|
|
13
16
|
throw new Error("Login response data is undefined");
|
|
14
|
-
e?.onSuccess?.(a), n.login(a.data),
|
|
17
|
+
u.resetRouteInit(), e?.onSuccess?.(a), n.login(a.data), s.push(t.getRoutePath(a.redirectTo || "/"));
|
|
15
18
|
return;
|
|
16
19
|
}
|
|
17
20
|
e?.onError?.(a);
|
|
18
21
|
},
|
|
19
|
-
isLoading:
|
|
22
|
+
isLoading: o
|
|
20
23
|
};
|
|
21
24
|
}
|
|
22
|
-
function
|
|
25
|
+
function p(e) {
|
|
23
26
|
const t = i(), n = c(), u = g();
|
|
24
27
|
return {
|
|
25
|
-
mutate: async (
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
e?.onSuccess?.(
|
|
28
|
+
mutate: async (o) => {
|
|
29
|
+
const r = await t.config.authProvider?.logout(o, t);
|
|
30
|
+
if (r?.success) {
|
|
31
|
+
e?.onSuccess?.(r), n.logout(), await u.replace(t.getRoutePath(r.redirectTo || "/login")), setTimeout(() => {
|
|
29
32
|
window.location.reload();
|
|
30
33
|
}, 100);
|
|
31
34
|
return;
|
|
32
35
|
}
|
|
33
|
-
e?.onError?.(
|
|
36
|
+
e?.onError?.(r);
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
|
-
function
|
|
38
|
-
const t = i(), n = c(), u =
|
|
40
|
+
function y(e) {
|
|
41
|
+
const t = i(), n = c(), { mutate: u } = m();
|
|
39
42
|
return {
|
|
40
|
-
mutate: async (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
if (e?.onSuccess?.(
|
|
43
|
+
mutate: async (o) => {
|
|
44
|
+
const r = await t.config.authProvider?.check?.(o, t, n.getUser());
|
|
45
|
+
if (r?.success) {
|
|
46
|
+
if (e?.onSuccess?.(r), !r?.data)
|
|
44
47
|
throw new Error("Check response data is undefined");
|
|
45
|
-
n.update(
|
|
48
|
+
n.update(r.data);
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
|
-
e?.onError?.(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
e?.onError?.(r), r?.logout && u({
|
|
52
|
+
status: 401,
|
|
53
|
+
message: r.message || "Unauthorized"
|
|
54
|
+
});
|
|
51
55
|
}
|
|
52
56
|
};
|
|
53
57
|
}
|
|
54
|
-
function
|
|
58
|
+
function L(e) {
|
|
55
59
|
const t = i(), n = c(), u = g();
|
|
56
60
|
return {
|
|
57
|
-
mutate: async (
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
if (e?.onSuccess?.(
|
|
61
|
+
mutate: async (o) => {
|
|
62
|
+
const r = await t.config.authProvider?.register?.(o, t);
|
|
63
|
+
if (r?.success) {
|
|
64
|
+
if (e?.onSuccess?.(r), !r?.data)
|
|
61
65
|
throw new Error("Register response data is undefined");
|
|
62
|
-
n.login(
|
|
66
|
+
n.login(r.data), u.push(t.getRoutePath(r.redirectTo || "/"));
|
|
63
67
|
return;
|
|
64
68
|
}
|
|
65
|
-
e?.onError?.(
|
|
69
|
+
e?.onError?.(r);
|
|
66
70
|
}
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
|
-
function
|
|
73
|
+
function U(e) {
|
|
70
74
|
const t = i(), n = g();
|
|
71
75
|
return {
|
|
72
76
|
mutate: async (s) => {
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
e?.onSuccess?.(
|
|
77
|
+
const o = await t.config.authProvider?.forgotPassword?.(s, t);
|
|
78
|
+
if (o?.success) {
|
|
79
|
+
e?.onSuccess?.(o), o.redirectTo && n.push(t.getRoutePath(o.redirectTo || "/"));
|
|
76
80
|
return;
|
|
77
81
|
}
|
|
78
|
-
e?.onError?.(
|
|
82
|
+
e?.onError?.(o);
|
|
79
83
|
}
|
|
80
84
|
};
|
|
81
85
|
}
|
|
82
|
-
function
|
|
86
|
+
function k(e) {
|
|
83
87
|
const t = i(), n = g();
|
|
84
88
|
return {
|
|
85
89
|
mutate: async (s) => {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
e?.onSuccess?.(
|
|
90
|
+
const o = await t.config.authProvider?.updatePassword?.(s, t);
|
|
91
|
+
if (o?.success) {
|
|
92
|
+
e?.onSuccess?.(o), o.redirectTo && n.push(t.getRoutePath(o.redirectTo || "/"));
|
|
89
93
|
return;
|
|
90
94
|
}
|
|
91
|
-
e?.onError?.(
|
|
95
|
+
e?.onError?.(o);
|
|
92
96
|
}
|
|
93
97
|
};
|
|
94
98
|
}
|
|
95
|
-
function
|
|
96
|
-
const { config: t, getRoutePath: n } = i(), u = g(), s = c();
|
|
99
|
+
function m(e) {
|
|
100
|
+
const { config: t, getRoutePath: n } = i(), u = g(), s = c(t.name), o = f(t.name);
|
|
97
101
|
return {
|
|
98
|
-
mutate: async (
|
|
99
|
-
const a = await t.authProvider?.onError(
|
|
100
|
-
e?.(a), a?.logout && (s.logout(), await u.replace(n(a.redirectTo || "/login")), setTimeout(() => {
|
|
101
|
-
window.location.reload();
|
|
102
|
+
mutate: async (d) => {
|
|
103
|
+
const a = await t.authProvider?.onError(d);
|
|
104
|
+
e?.(a), a?.logout && (await s.logout(), await o.resetRouteInit(), await u.replace(n(a.redirectTo || "/login")), setTimeout(() => {
|
|
102
105
|
}, 100));
|
|
103
106
|
}
|
|
104
107
|
};
|
|
105
108
|
}
|
|
106
|
-
function
|
|
109
|
+
function C(e) {
|
|
107
110
|
return c(e).getUser();
|
|
108
111
|
}
|
|
109
|
-
function
|
|
112
|
+
function I(e) {
|
|
110
113
|
return c(e).isLogin();
|
|
111
114
|
}
|
|
112
|
-
function
|
|
115
|
+
function A(e) {
|
|
113
116
|
const t = i(e), u = c(e).getUser();
|
|
114
|
-
return (
|
|
117
|
+
return (o, r) => t.config.authProvider?.can ? t.config.authProvider.can(o, r, t, u) : !0;
|
|
115
118
|
}
|
|
116
119
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
A as useCan,
|
|
121
|
+
y as useCheck,
|
|
122
|
+
m as useError,
|
|
123
|
+
U as useForgotPassword,
|
|
124
|
+
C as useGetAuth,
|
|
125
|
+
I as useIsLogin,
|
|
126
|
+
T as useLogin,
|
|
127
|
+
p as useLogout,
|
|
128
|
+
L as useRegister,
|
|
129
|
+
k as useUpdatePassword
|
|
127
130
|
};
|
package/dist/esm/hooks/theme.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { useColorMode as H, useCycleList as J } from "@vueuse/core";
|
|
2
2
|
import { hex2rgb as K } from "colorizr";
|
|
3
3
|
import { storeToRefs as P } from "pinia";
|
|
4
|
-
import { watchEffect as Q, computed as
|
|
4
|
+
import { watchEffect as Q, computed as b, watch as W, readonly as L } from "vue";
|
|
5
5
|
import { themeColor as X } from "../config/color.js";
|
|
6
6
|
import "lodash-es";
|
|
7
7
|
import { useThemeStore as Y } from "../stores/theme.js";
|
|
8
8
|
import { useManage as Z } from "./manage.js";
|
|
9
9
|
function ie() {
|
|
10
|
-
const s = Y(), { mode:
|
|
11
|
-
storageRef:
|
|
12
|
-
}),
|
|
10
|
+
const s = Y(), { mode: j } = P(s), $ = H({
|
|
11
|
+
storageRef: j
|
|
12
|
+
}), u = Z(), { state: S, next: B, go: v } = J(["dark", "light", "auto"], {
|
|
13
13
|
initialValue: $.store.value
|
|
14
14
|
});
|
|
15
15
|
Q(() => {
|
|
16
16
|
$.value = S.value;
|
|
17
17
|
});
|
|
18
|
-
const
|
|
18
|
+
const V = (t) => {
|
|
19
19
|
switch (t) {
|
|
20
20
|
case "auto":
|
|
21
21
|
v(2);
|
|
@@ -27,15 +27,17 @@ function ie() {
|
|
|
27
27
|
v(0);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, d = b(() => {
|
|
31
31
|
const { system: t, store: e } = $;
|
|
32
32
|
return e.value === "auto" ? t.value === "dark" : e.value === "dark";
|
|
33
|
-
}),
|
|
34
|
-
logo:
|
|
35
|
-
|
|
33
|
+
}), M = b(() => d.value ? {
|
|
34
|
+
logo: u.config?.theme?.darkLogo,
|
|
35
|
+
appLogo: u.config?.theme?.appDarkLogo,
|
|
36
|
+
banner: u.config?.theme?.darkBanner
|
|
36
37
|
} : {
|
|
37
|
-
logo:
|
|
38
|
-
|
|
38
|
+
logo: u.config?.theme?.logo,
|
|
39
|
+
appLogo: u.config?.theme?.appLogo,
|
|
40
|
+
banner: u.config?.theme?.banner
|
|
39
41
|
}), r = { ...{
|
|
40
42
|
colors: X,
|
|
41
43
|
// 色彩类型
|
|
@@ -65,12 +67,12 @@ function ie() {
|
|
|
65
67
|
}
|
|
66
68
|
},
|
|
67
69
|
colorBase: { white: "#ffffff", black: "#000000" }
|
|
68
|
-
}, ...
|
|
69
|
-
function
|
|
70
|
-
return
|
|
70
|
+
}, ...u.config?.theme?.config }, { colorShades: C, colorTypes: x } = r, f = b(() => s.theme), h = b(() => Object.keys(r.colors)), k = ["default", "hover", "pressed", "focus", "disabled"];
|
|
71
|
+
function y() {
|
|
72
|
+
return d.value ? r.colorScenes.dark : r.colorScenes.light;
|
|
71
73
|
}
|
|
72
74
|
function w(t, e) {
|
|
73
|
-
const o =
|
|
75
|
+
const o = y(), l = o.default;
|
|
74
76
|
if (o.overrides?.[t]) {
|
|
75
77
|
const i = o.overrides[t]?.[e];
|
|
76
78
|
if (i)
|
|
@@ -79,39 +81,39 @@ function ie() {
|
|
|
79
81
|
return l[e] || "500";
|
|
80
82
|
}
|
|
81
83
|
function T(t, e) {
|
|
82
|
-
const o =
|
|
84
|
+
const o = f.value[t];
|
|
83
85
|
return r.colors[o]?.[e] || "";
|
|
84
86
|
}
|
|
85
87
|
function n(t, e, o) {
|
|
86
|
-
const c = (
|
|
88
|
+
const c = (d.value ? r.colorSemantic.dark : r.colorSemantic.light)[t][e];
|
|
87
89
|
return c === "white" || c === "black" ? `var(--ui-color-${c})` : `var(--base-color-${o}-${c})`;
|
|
88
90
|
}
|
|
89
91
|
const p = (t) => {
|
|
90
92
|
const e = K(t);
|
|
91
93
|
return `${e.r} ${e.g} ${e.b}`;
|
|
92
94
|
};
|
|
93
|
-
function
|
|
95
|
+
function I() {
|
|
94
96
|
const t = [];
|
|
95
97
|
Object.entries(r.colors).forEach(([c, i]) => {
|
|
96
|
-
typeof i == "object" && Object.entries(i).forEach(([a,
|
|
98
|
+
typeof i == "object" && Object.entries(i).forEach(([a, m]) => {
|
|
97
99
|
try {
|
|
98
|
-
t.push(`--base-color-${c}-${a}: ${p(
|
|
100
|
+
t.push(`--base-color-${c}-${a}: ${p(m)};`);
|
|
99
101
|
} catch {
|
|
100
|
-
t.push(`--base-color-${c}-${a}: ${
|
|
102
|
+
t.push(`--base-color-${c}-${a}: ${m};`);
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
const e = [];
|
|
105
107
|
x.forEach((c) => {
|
|
106
|
-
const i =
|
|
108
|
+
const i = f.value[c];
|
|
107
109
|
C.forEach((a) => {
|
|
108
110
|
e.push(`--ui-color-${c}-${a}: var(--base-color-${i}-${a});`);
|
|
109
111
|
}), k.forEach((a) => {
|
|
110
|
-
const
|
|
111
|
-
a === "default" ? e.push(`--ui-color-${c}: var(--base-color-${i}-${
|
|
112
|
+
const m = w(c, a);
|
|
113
|
+
a === "default" ? e.push(`--ui-color-${c}: var(--base-color-${i}-${m});`) : e.push(`--ui-color-${c}-${a}: var(--base-color-${i}-${m});`);
|
|
112
114
|
});
|
|
113
115
|
});
|
|
114
|
-
const o =
|
|
116
|
+
const o = f.value.gray, l = [
|
|
115
117
|
`--ui-color-white: ${p(r.colorBase?.white || "#ffffff")};`,
|
|
116
118
|
`--ui-color-black: ${p(r.colorBase?.black || "#000000")};`,
|
|
117
119
|
`--ui-text-dimmed: ${n("text", "dimmed", o)};`,
|
|
@@ -139,15 +141,15 @@ function ie() {
|
|
|
139
141
|
`)}
|
|
140
142
|
}`;
|
|
141
143
|
}
|
|
142
|
-
let
|
|
144
|
+
let g = null;
|
|
143
145
|
function E() {
|
|
144
|
-
const t =
|
|
145
|
-
|
|
146
|
+
const t = I();
|
|
147
|
+
g || (g = document.createElement("style"), g.id = "dvha-variables", document.head.appendChild(g)), g.textContent = t;
|
|
146
148
|
}
|
|
147
149
|
function O() {
|
|
148
150
|
s.cssInit || (s.setCssInit(), E());
|
|
149
151
|
}
|
|
150
|
-
W([
|
|
152
|
+
W([f, d], () => {
|
|
151
153
|
s.cssInit && E();
|
|
152
154
|
}, { deep: !0, immediate: !1 });
|
|
153
155
|
function R(t, e) {
|
|
@@ -186,18 +188,18 @@ function ie() {
|
|
|
186
188
|
}
|
|
187
189
|
return `${a}`;
|
|
188
190
|
}
|
|
189
|
-
const l =
|
|
191
|
+
const l = f.value.gray, i = (d.value ? r.colorSemantic.dark : r.colorSemantic.light)[t][e];
|
|
190
192
|
return i === "white" ? r.colorBase?.white || "#ffffff" : i === "black" ? r.colorBase?.black || "#000000" : r.colors[l]?.[i] || "";
|
|
191
193
|
}
|
|
192
|
-
const A =
|
|
194
|
+
const A = b(() => h.value?.filter((t) => ["slate", "gray", "zinc", "neutral", "stone"].includes(t))), F = b(() => h.value?.filter((t) => !["slate", "gray", "zinc", "neutral", "stone"].includes(t)));
|
|
193
195
|
return {
|
|
194
|
-
toggle:
|
|
196
|
+
toggle: B,
|
|
195
197
|
mode: S,
|
|
196
|
-
setMode:
|
|
197
|
-
isDark:
|
|
198
|
-
resources:
|
|
199
|
-
config:
|
|
200
|
-
colorMapping:
|
|
198
|
+
setMode: V,
|
|
199
|
+
isDark: d,
|
|
200
|
+
resources: M,
|
|
201
|
+
config: L(r),
|
|
202
|
+
colorMapping: L(f),
|
|
201
203
|
colors: h,
|
|
202
204
|
neutralColors: A,
|
|
203
205
|
primaryColors: F,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import i from "axios";
|
|
2
2
|
function o(a) {
|
|
3
3
|
return {
|
|
4
|
-
login: async (
|
|
4
|
+
login: async (t, r) => await i.post(r.getApiUrl(a?.apiPath?.login || "/login", a?.dataProviderName), t).then((e) => ({
|
|
5
5
|
success: !0,
|
|
6
6
|
message: e?.data?.message,
|
|
7
7
|
redirectTo: a?.routePath?.index || "/",
|
|
@@ -10,33 +10,33 @@ function o(a) {
|
|
|
10
10
|
success: !1,
|
|
11
11
|
message: e?.response?.data?.message || e?.message
|
|
12
12
|
})),
|
|
13
|
-
check: async (
|
|
13
|
+
check: async (t, r, e) => await i.get(r?.getApiUrl(a?.apiPath?.check || "/check", a?.dataProviderName) || "", {
|
|
14
14
|
headers: {
|
|
15
15
|
Authorization: e?.token || ""
|
|
16
16
|
}
|
|
17
|
-
}).then((
|
|
17
|
+
}).then((s) => ({
|
|
18
18
|
success: !0,
|
|
19
19
|
logout: !1,
|
|
20
|
-
message:
|
|
21
|
-
data:
|
|
22
|
-
})).catch((
|
|
20
|
+
message: s?.data?.message,
|
|
21
|
+
data: s?.data?.data
|
|
22
|
+
})).catch((s) => ({
|
|
23
23
|
success: !1,
|
|
24
|
-
logout:
|
|
25
|
-
message:
|
|
24
|
+
logout: s.status === 401,
|
|
25
|
+
message: s?.response?.data?.message || s?.message
|
|
26
26
|
})),
|
|
27
|
-
onError: async (
|
|
27
|
+
onError: async (t) => t?.status === 401 ? {
|
|
28
28
|
logout: !0,
|
|
29
29
|
redirectTo: a?.routePath?.login || "/login",
|
|
30
|
-
error:
|
|
30
|
+
error: t
|
|
31
31
|
} : {
|
|
32
32
|
logout: !1,
|
|
33
|
-
error:
|
|
33
|
+
error: t
|
|
34
34
|
},
|
|
35
35
|
logout: async () => ({
|
|
36
36
|
success: !0,
|
|
37
37
|
redirectTo: a?.routePath?.login || "/login"
|
|
38
38
|
}),
|
|
39
|
-
register: async (
|
|
39
|
+
register: async (t, r) => await i.post(r?.getApiUrl(a?.apiPath?.register || "/register", a?.dataProviderName) || "", t).then((e) => ({
|
|
40
40
|
success: !0,
|
|
41
41
|
message: e?.data?.message,
|
|
42
42
|
redirectTo: a?.routePath?.index || "/",
|
|
@@ -45,7 +45,7 @@ function o(a) {
|
|
|
45
45
|
success: !1,
|
|
46
46
|
message: e?.response?.data?.message || e?.message
|
|
47
47
|
})),
|
|
48
|
-
forgotPassword: async (
|
|
48
|
+
forgotPassword: async (t, r) => await i.post(r?.getApiUrl(a?.apiPath?.forgotPassword || "/forgot-password", a?.dataProviderName) || "", t).then((e) => ({
|
|
49
49
|
success: !0,
|
|
50
50
|
message: e?.data?.message,
|
|
51
51
|
redirectTo: a?.routePath?.login || "/login"
|
|
@@ -53,7 +53,7 @@ function o(a) {
|
|
|
53
53
|
success: !1,
|
|
54
54
|
message: e?.response?.data?.message || e?.message
|
|
55
55
|
})),
|
|
56
|
-
updatePassword: async (
|
|
56
|
+
updatePassword: async (t, r) => await i.post(r?.getApiUrl(a?.apiPath?.updatePassword || "/update-password", a?.dataProviderName) || "", t).then((e) => ({
|
|
57
57
|
success: !0,
|
|
58
58
|
message: e?.data?.message,
|
|
59
59
|
redirectTo: a?.routePath?.login || "/login"
|
|
@@ -61,7 +61,7 @@ function o(a) {
|
|
|
61
61
|
success: !1,
|
|
62
62
|
message: e?.response?.data?.message || e?.message
|
|
63
63
|
})),
|
|
64
|
-
can: (
|
|
64
|
+
can: (t, r, e, s) => !s?.permission || Array.isArray(s?.permission) && s?.permission?.length === 0 || typeof s?.permission == "object" && Object.keys(s?.permission).length === 0 ? !0 : !(Array.isArray(s?.permission) && !s?.permission?.includes(t) || typeof s?.permission == "object" && s?.permission[t] === !1)
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
export {
|
package/dist/esm/stores/route.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineStore as
|
|
2
|
-
import { inject as
|
|
3
|
-
function
|
|
4
|
-
const t =
|
|
1
|
+
import { defineStore as S } from "pinia";
|
|
2
|
+
import { inject as g, ref as l } from "vue";
|
|
3
|
+
function F(r) {
|
|
4
|
+
const t = g("dux.manage");
|
|
5
5
|
if (r || (r = t?.value || ""), !r)
|
|
6
6
|
throw new Error("manage not found");
|
|
7
|
-
return
|
|
7
|
+
return m(r)();
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
11
|
-
const t = l([]),
|
|
9
|
+
function m(r) {
|
|
10
|
+
return S(`routes-${r}`, () => {
|
|
11
|
+
const t = l([]), i = (e) => t.value?.find((n) => n.path === e), f = (e) => t.value?.find((n) => n.name === e), d = (e) => {
|
|
12
12
|
t.value?.push(e);
|
|
13
13
|
}, v = (e) => {
|
|
14
14
|
t.value = [...t.value, ...e];
|
|
@@ -16,7 +16,7 @@ function I(r) {
|
|
|
16
16
|
t.value = e;
|
|
17
17
|
}, p = () => t.value, h = () => {
|
|
18
18
|
t.value = [];
|
|
19
|
-
},
|
|
19
|
+
}, I = () => {
|
|
20
20
|
const e = t.value?.filter((o) => !o.parent && !o.name?.includes("404") && !o.name?.includes("403"))?.sort((o, u) => (o.sort || 0) - (u.sort || 0)), n = (o) => {
|
|
21
21
|
if (o.path)
|
|
22
22
|
return o;
|
|
@@ -32,24 +32,27 @@ function I(r) {
|
|
|
32
32
|
if (u)
|
|
33
33
|
return u;
|
|
34
34
|
}
|
|
35
|
-
},
|
|
35
|
+
}, a = l(!1);
|
|
36
36
|
return {
|
|
37
37
|
routes: t,
|
|
38
|
-
searchRoute:
|
|
38
|
+
searchRoute: i,
|
|
39
39
|
searchRouteName: f,
|
|
40
40
|
appendRoute: d,
|
|
41
41
|
appendRoutes: v,
|
|
42
42
|
setRoutes: R,
|
|
43
43
|
getRoutes: p,
|
|
44
44
|
clearRoutes: h,
|
|
45
|
-
getIndexRoute:
|
|
45
|
+
getIndexRoute: I,
|
|
46
46
|
getRouteInit: () => {
|
|
47
|
-
const e =
|
|
48
|
-
return
|
|
47
|
+
const e = a.value;
|
|
48
|
+
return a.value = !0, e;
|
|
49
|
+
},
|
|
50
|
+
resetRouteInit: () => {
|
|
51
|
+
a.value = !1;
|
|
49
52
|
}
|
|
50
53
|
};
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
export {
|
|
54
|
-
|
|
57
|
+
F as useRouteStore
|
|
55
58
|
};
|
|
@@ -11,10 +11,11 @@ export interface RouteStoreState {
|
|
|
11
11
|
clearRoutes: () => void;
|
|
12
12
|
getIndexRoute: () => IMenu | undefined;
|
|
13
13
|
getRouteInit: () => boolean;
|
|
14
|
+
resetRouteInit: () => void;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* use route store
|
|
17
18
|
* @param manageName manage name
|
|
18
19
|
* @returns route store
|
|
19
20
|
*/
|
|
20
|
-
export declare function useRouteStore(manageName?: string): import("pinia").Store<string, Pick<RouteStoreState, "routes">, Pick<RouteStoreState, never>, Pick<RouteStoreState, "searchRoute" | "searchRouteName" | "appendRoute" | "appendRoutes" | "setRoutes" | "getRoutes" | "clearRoutes" | "getIndexRoute" | "getRouteInit">>;
|
|
21
|
+
export declare function useRouteStore(manageName?: string): import("pinia").Store<string, Pick<RouteStoreState, "routes">, Pick<RouteStoreState, never>, Pick<RouteStoreState, "searchRoute" | "searchRouteName" | "appendRoute" | "appendRoutes" | "setRoutes" | "getRoutes" | "clearRoutes" | "getIndexRoute" | "getRouteInit" | "resetRouteInit">>;
|
|
@@ -3,12 +3,16 @@ import type { ThemeState } from '../stores';
|
|
|
3
3
|
export interface IConfigTheme {
|
|
4
4
|
logo?: string;
|
|
5
5
|
darkLogo?: string;
|
|
6
|
+
appLogo?: string;
|
|
7
|
+
appDarkLogo?: string;
|
|
6
8
|
banner?: string;
|
|
7
9
|
darkBanner?: string;
|
|
8
10
|
config?: ThemeConfig;
|
|
9
11
|
defaultTheme?: ThemeState;
|
|
12
|
+
[key: string]: any;
|
|
10
13
|
}
|
|
11
14
|
export interface ITheme {
|
|
12
15
|
logo?: string;
|
|
16
|
+
appLogo?: string;
|
|
13
17
|
banner?: string;
|
|
14
18
|
}
|