Files
monisuo/monisuo-admin/dist/assets/appearance-DpdsQ2bs.js
2026-04-21 08:12:17 +08:00

1 line
7.1 KiB
JavaScript

import{A as e,C as t,D as n,E as r,H as i,I as a,Ot as o,S as s,T as c,Tt as l,b as u,et as d,h as f,it as p,k as m,w as h,x as g}from"./iconify-DYZHDLa8.js";import{a as _,i as v,n as y,r as b,t as x}from"./SelectValue-Dhq6ao6U.js";import"./use-sidebar-DLbHg08t.js";import{v as S}from"./vue-vendor-DjtlKxRy.js";import{n as C,r as w,t as T}from"./useMutation-VMyHxPGH.js";import{G as E,f as D,l as O,q as k}from"./index-Uji7rFqr.js";import"./Teleport-BIYegdAM.js";import{n as A}from"./button-BuRmTYve.js";import{n as j,r as M,t as N}from"./RadioGroupItem-D580gfhD.js";import{a as P,c as F,i as I,l as L,n as R,r as z,s as B,t as V}from"./vee-validate-zod-CSNgsVeg.js";import{t as H}from"./Separator-DMwYbzjz.js";import"./global-layout-BGXP2p6j.js";import{t as U}from"./settings-layout-C49P92lm.js";var W=D({theme:O([`light`,`dark`],{error:`Please select a theme.`}),font:O([`inter`,`manrope`,`system`],{error:`Please select a font.`})}),G=[{key:`appearance_config`,value:JSON.stringify({theme:`dark`,font:`inter`}),description:`Appearance configuration for the application, including theme color, border radius, and content layout.`}];function K(e,t=!0){return{data:e,extra:{},code:200,message:`success`,success:t}}function q(e){return C({queryKey:[`useGetSystemConfigByKeyQuery`,e],queryFn:async()=>{let t=await new Promise((t,n)=>{setTimeout(()=>{let r=G.find(t=>t.key===e);r||n(Error(`Config not found`)),t(r)},1e3)});if(!t)throw Error(`Config not found`);return K(t)}})}function J(e){let t=w();return T({mutationKey:[`useUpdateSystemConfigByKeyMutation`,e],mutationFn:async e=>await new Promise(t=>{setTimeout(()=>{t(K(e))},100)}),onSuccess:()=>{t.invalidateQueries({queryKey:[`useGetSystemConfigByKeyQuery`,e]})}})}function Y(){let e=w();return T({mutationKey:[`useCreateTaskMutation`],mutationFn:async e=>new Promise(t=>{setTimeout(()=>{t(K(e))},100)}),onSuccess:()=>{e.invalidateQueries({queryKey:[`useGetSystemConfigByKeyQuery`]})}})}function X({key:t,defaultValue:n,description:r,schema:i}){let a={...n},{handleSubmit:o,resetForm:s}=F({validationSchema:V(i),initialValues:a}),c=S(t,a),{data:l,isPending:f}=q(t),{mutate:p,isPending:m}=Y(),{mutate:h,isPending:g}=J(t),_=u(()=>m.value||g.value);return d(l,()=>{if(!f.value&&!l.value){c.value=l.value,p({key:t,description:r,value:JSON.stringify(n)},{onSuccess:()=>{c.value=a,E(`System config created with default value.`,{description:e(`pre`,{class:`mt-2 w-[340px] rounded-md bg-slate-950 p-4`},e(`code`,{class:`text-white`},JSON.stringify({key:t,description:r,value:n},null,2)))})}});return}let i=l.value?.data?.value?JSON.parse(l.value.data.value):a;c.value=i,s({values:{...i}})},{immediate:!0,deep:!0}),{isPending:_,isGetting:f,onSubmit:o(n=>{let i={key:t,value:n,description:r};c.value=n,h({...i,value:JSON.stringify(n)},{onSuccess:()=>{E(`You submitted the following values:`,{description:e(`pre`,{class:`mt-2 w-[340px] rounded-md bg-slate-950 p-4`},e(`code`,{class:`text-white`},JSON.stringify(i,null,2)))})}})})}}var Z={key:0},Q={class:`flex justify-start`},$=`appearance_config`,ee=`Customize the appearance of the app. Automatically switch between day and night themes.`,te=n({__name:`appearance-form`,setup(e){let{isGetting:n,isPending:u,onSubmit:d}=X({key:$,description:ee,defaultValue:{theme:`light`,font:`inter`},schema:W});return(e,S)=>{let C=x,w=y,T=P,E=b,D=L,O=v,F=_;return i(),h(f,null,[S[14]||=g(`div`,null,[g(`h3`,{class:`text-lg font-medium`},` Appearance `),g(`p`,{class:`text-sm text-muted-foreground`},` Customize the appearance of the app. Automatically switch between day and night themes. `)],-1),r(l(H),{class:`my-4`}),l(n)?(i(),h(`div`,Z,[r(l(A),{variant:`secondary`,disabled:``,size:`sm`},{default:p(()=>[r(l(k)),S[1]||=c(` Please wait `,-1)]),_:1})])):t(``,!0),l(n)?t(``,!0):(i(),h(`form`,{key:1,class:`space-y-8`,onSubmit:S[0]||=(...e)=>l(d)&&l(d)(...e)},[r(l(B),{name:`font`},{default:p(({componentField:e})=>[r(l(I),null,{default:p(()=>[r(l(z),null,{default:p(()=>[...S[2]||=[c(`Font`,-1)]]),_:1}),r(F,o(m(e)),{default:p(()=>[r(T,null,{default:p(()=>[r(w,null,{default:p(()=>[r(C,{placeholder:`Select a font`})]),_:1})]),_:1}),r(O,null,{default:p(()=>[r(D,null,{default:p(()=>[r(E,{value:`inter`},{default:p(()=>[...S[3]||=[c(` Inter `,-1)]]),_:1}),r(E,{value:`manrope`},{default:p(()=>[...S[4]||=[c(` Manrope `,-1)]]),_:1}),r(E,{value:`system`},{default:p(()=>[...S[5]||=[c(` System `,-1)]]),_:1})]),_:1})]),_:1})]),_:1},16),r(l(M),null,{default:p(()=>[...S[6]||=[c(` Set the font you want to use in the dashboard. `,-1)]]),_:1}),r(l(R))]),_:2},1024)]),_:1}),r(l(B),{type:`radio`,name:`theme`},{default:p(({componentField:e})=>[r(l(I),{class:`space-y-1`},{default:p(()=>[r(l(z),null,{default:p(()=>[...S[7]||=[c(`Theme`,-1)]]),_:1}),r(l(M),null,{default:p(()=>[...S[8]||=[c(` Select the theme for the dashboard. `,-1)]]),_:1}),r(l(R)),r(l(j),a({class:`grid max-w-md grid-cols-2 gap-8 pt-2`},e),{default:p(()=>[r(l(I),null,{default:p(()=>[r(l(z),{class:`[&:has([data-state=checked])>div]:border-primary flex flex-col`},{default:p(()=>[r(l(P),null,{default:p(()=>[r(l(N),{value:`light`,class:`sr-only`})]),_:1}),S[9]||=g(`div`,{class:`items-center p-1 border-2 rounded-md border-muted hover:border-accent`},[g(`div`,{class:`space-y-2 rounded-sm bg-[#ecedef] p-2`},[g(`div`,{class:`p-2 space-y-2 bg-white rounded-md shadow-xs`},[g(`div`,{class:`h-2 w-20 rounded-lg bg-[#ecedef]`}),g(`div`,{class:`h-2 w-[100px] rounded-lg bg-[#ecedef]`})]),g(`div`,{class:`flex items-center p-2 space-x-2 bg-white rounded-md shadow-xs`},[g(`div`,{class:`h-4 w-4 rounded-full bg-[#ecedef]`}),g(`div`,{class:`h-2 w-[100px] rounded-lg bg-[#ecedef]`})]),g(`div`,{class:`flex items-center p-2 space-x-2 bg-white rounded-md shadow-xs`},[g(`div`,{class:`h-4 w-4 rounded-full bg-[#ecedef]`}),g(`div`,{class:`h-2 w-[100px] rounded-lg bg-[#ecedef]`})])])],-1),S[10]||=g(`span`,{class:`block w-full p-2 font-normal text-center`},` Light `,-1)]),_:1})]),_:1}),r(l(I),null,{default:p(()=>[r(l(z),{class:`[&:has([data-state=checked])>div]:border-primary flex flex-col`},{default:p(()=>[r(l(P),null,{default:p(()=>[r(l(N),{value:`dark`,class:`sr-only`})]),_:1}),S[11]||=g(`div`,{class:`items-center p-1 border-2 rounded-md border-muted bg-popover hover:bg-accent hover:text-accent-foreground`},[g(`div`,{class:`p-2 space-y-2 rounded-sm bg-slate-950`},[g(`div`,{class:`p-2 space-y-2 rounded-md shadow-xs bg-slate-800`},[g(`div`,{class:`w-20 h-2 rounded-lg bg-slate-400`}),g(`div`,{class:`h-2 w-[100px] rounded-lg bg-slate-400`})]),g(`div`,{class:`flex items-center p-2 space-x-2 rounded-md shadow-xs bg-slate-800`},[g(`div`,{class:`size-4 rounded-full bg-slate-400`}),g(`div`,{class:`h-2 w-[100px] rounded-lg bg-slate-400`})]),g(`div`,{class:`flex items-center p-2 space-x-2 rounded-md shadow-xs bg-slate-800`},[g(`div`,{class:`size-4 rounded-full bg-slate-400`}),g(`div`,{class:`h-2 w-[100px] rounded-lg bg-slate-400`})])])],-1),S[12]||=g(`span`,{class:`block w-full p-2 font-normal text-center`},` Dark `,-1)]),_:1})]),_:1})]),_:1},16)]),_:2},1024)]),_:1}),g(`div`,Q,[r(l(A),{type:`submit`,disabled:l(u)},{default:p(()=>[l(u)?(i(),s(l(k),{key:0,size:`sm`})):t(``,!0),S[13]||=c(` Update preferences `,-1)]),_:1},8,[`disabled`])])],32))],64)}}}),ne=n({__name:`appearance`,setup(e){return(e,t)=>(i(),s(U,null,{default:p(()=>[r(te)]),_:1}))}});export{ne as default};