Files
vue-pure-admin/static/js/useDataThemeChange-DDlvWXw6.js

2 lines
3.5 KiB
JavaScript

import{et as g,p as L,ew as P,el as F,Q as A,a as S,aw as E,ex as q,av as z,ee as w,ey as G,ez as W,eA as x,eB as D}from"./index-ByWe-9J4.js";import{u as Q}from"./app-Czbp3HoW.js";import{u as b}from"./epTheme-qLcRdykJ.js";function R(){const{$storage:a,$config:e}=g(),p=()=>{var n,k,c,h,y,d,f,v,C,T,t,o,s,u,r,i,M;P().multiTagsCache&&(!a.tags||a.tags.length===0)&&(a.tags=F),a.locale||(a.locale={locale:(n=e==null?void 0:e.Locale)!=null?n:"zh"},A().locale.value=(k=e==null?void 0:e.Locale)!=null?k:"zh"),a.layout||(a.layout={layout:(c=e==null?void 0:e.Layout)!=null?c:"vertical",theme:(h=e==null?void 0:e.Theme)!=null?h:"light",darkMode:(y=e==null?void 0:e.DarkMode)!=null?y:!1,sidebarStatus:(d=e==null?void 0:e.SidebarStatus)!=null?d:!0,epThemeColor:(f=e==null?void 0:e.EpThemeColor)!=null?f:"#409EFF",themeColor:(v=e==null?void 0:e.Theme)!=null?v:"light",themeMode:(C=e==null?void 0:e.ThemeMode)!=null?C:"light"}),a.configure||(a.configure={grey:(T=e==null?void 0:e.Grey)!=null?T:!1,weak:(t=e==null?void 0:e.Weak)!=null?t:!1,hideTabs:(o=e==null?void 0:e.HideTabs)!=null?o:!1,hideFooter:(s=e.HideFooter)!=null?s:!0,showLogo:(u=e==null?void 0:e.ShowLogo)!=null?u:!0,showModel:(r=e==null?void 0:e.ShowModel)!=null?r:"smart",multiTagsCache:(i=e==null?void 0:e.MultiTagsCache)!=null?i:!1,stretch:(M=e==null?void 0:e.Stretch)!=null?M:!1})},l=L(()=>a==null?void 0:a.layout.layout),m=L(()=>a.layout);return{layout:l,layoutTheme:m,initStorage:p}}function K(){var C,T;const{layoutTheme:a,layout:e}=R(),p=S([{color:"#ffffff",themeColor:"light"},{color:"#1b2a47",themeColor:"default"},{color:"#722ed1",themeColor:"saucePurple"},{color:"#eb2f96",themeColor:"pink"},{color:"#f5222d",themeColor:"dusk"},{color:"#fa541c",themeColor:"volcano"},{color:"#13c2c2",themeColor:"mingQing"},{color:"#52c41a",themeColor:"auroraGreen"}]),{$storage:l}=g(),m=S((C=l==null?void 0:l.layout)==null?void 0:C.darkMode),n=S((T=l==null?void 0:l.layout)==null?void 0:T.themeMode),k=document.documentElement;function c(t,o,s){const u=s||document.body;let{className:r}=u;r=r.replace(o,"").trim(),u.className=t?`${r} ${o}`:r}function h(t=(s=>(s=E().Theme)!=null?s:"light")(),o=!0){var r,i;a.value.theme=t,document.documentElement.setAttribute("data-theme",t);const u=l.layout.themeColor;if(l.layout={layout:e.value,theme:t,darkMode:m.value,sidebarStatus:(r=l.layout)==null?void 0:r.sidebarStatus,epThemeColor:(i=l.layout)==null?void 0:i.epThemeColor,themeColor:o?t:u,themeMode:n.value},t==="default"||t==="light")d(E().EpThemeColor);else{const M=p.value.find(H=>H.themeColor===t);d(M.color)}}function y(t,o,s){document.documentElement.style.setProperty(`--el-color-primary-${t}-${o}`,m.value?x(s,o/10):D(s,o/10))}const d=t=>{b().setEpThemeColor(t),document.documentElement.style.setProperty("--el-color-primary",t);for(let o=1;o<=2;o++)y("dark",o,t);for(let o=1;o<=9;o++)y("light",o,t)};function f(t){n.value=t,b().epTheme==="light"&&m.value?h("default",!1):h(b().epTheme,!1),m.value?document.documentElement.classList.add("dark"):(l.layout.themeColor==="light"&&h("light",!1),document.documentElement.classList.remove("dark"))}function v(){q(),z().clear();const{Grey:t,Weak:o,MultiTagsCache:s,EpThemeColor:u,Layout:r}=E();Q().setLayout(r),d(u),w().multiTagsCacheChange(s),c(t,"html-grey",document.querySelector("html")),c(o,"html-weakness",document.querySelector("html")),G.push("/login"),w().handleTags("equal",[...F]),W()}return{body:k,dataTheme:m,themeMode:n,layoutTheme:a,themeColors:p,onReset:v,toggleClass:c,dataThemeChange:f,setEpThemeColor:d,setLayoutThemeColor:h}}export{R as a,K as u};