You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
8.6 KiB

import{_ as R}from"./CDB8L8go.js";import{u as L}from"./xsgK-Nup.js";import{g as C,o,c as l,F as m,r as k,n as G,a as t,t as i,m as c,I as M,w as N,l as v,T as H,_ as q,j as W,k as J,E as K,C as Q,d as X,M as Y,N as Z,q as w,v as y,b as B,S as tt,y as E,z as et,A as h}from"./6O01ZZML.js";import{a as st,u as ot}from"./BgasD__e.js";const nt={class:"toast toast-bottom toast-end z-50"},lt=C({__name:"AppToast",setup(A){const{toasts:n}=L();function p(r){switch(r){case"success":return"alert-success";case"error":return"alert-error";case"warning":return"alert-warning";default:return"alert-info"}}return(r,z)=>(o(),l("div",nt,[(o(!0),l(m,null,k(c(n),u=>(o(),l("div",{key:u.id,class:G(["alert",p(u.type)])},[t("span",null,i(u.msg),1)],2))),128))]))}}),at=Object.assign(lt,{__name:"AppToast"}),it={key:0,class:"fixed inset-0 z-[100] flex items-center justify-center bg-black/30 backdrop-blur-[1px]","aria-busy":"true",role:"alert"},rt=C({__name:"AppLoading",setup(A){const{loading:n}=st();return(p,r)=>(o(),M(H,{name:"fade"},{default:N(()=>[c(n)?(o(),l("div",it,[...r[0]||(r[0]=[t("div",{class:"flex flex-col items-center gap-3 rounded-2xl bg-white px-10 py-7 shadow-xl"},[t("span",{class:"loading loading-spinner loading-lg text-primary"}),t("span",{class:"text-sm text-slate-600"},"处理中,请稍候…")],-1)])])):v("",!0)]),_:1}))}}),dt=Object.assign(q(rt,[["__scopeId","data-v-c1ace0c2"]]),{__name:"AppLoading"}),ct={class:"flex min-h-screen"},pt={class:"fixed top-0 left-0 bottom-0 z-30 overflow-y-auto flex flex-col",style:{width:"256px",background:"#1E293B"}},ut={style:{padding:"20px 20px 16px","border-bottom":"1px solid rgba(255,255,255,0.06)"}},xt={style:{display:"flex","align-items":"center",gap:"12px"}},mt={style:{width:"40px",height:"40px",background:"linear-gradient(135deg,#4F46E5,#7C3AED)","border-radius":"12px",display:"flex","align-items":"center","justify-content":"center","box-shadow":"0 6px 20px rgba(79,70,229,0.35)","flex-shrink":"0"}},ft={style:{width:"22px",height:"22px",color:"#fff"},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},_t={style:{color:"#fff","font-weight":"700","font-size":"15px","letter-spacing":"-0.02em"}},ht={style:{padding:"12px 0",flex:"1"}},vt={class:"icon",width:"18",height:"18",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},gt=["d"],bt={style:{"margin-top":"auto",padding:"14px 18px","border-top":"1px solid rgba(255,255,255,0.06)"}},wt={style:{display:"flex","align-items":"center",gap:"10px"}},yt={style:{width:"32px",height:"32px","border-radius":"9px",background:"linear-gradient(135deg,#4F46E5,#7C3AED)",color:"#fff",display:"flex","align-items":"center","justify-content":"center","font-weight":"700","flex-shrink":"0"}},kt={style:{"min-width":"0"}},Ct={style:{color:"#E2E8F0","font-size":"13px","font-weight":"600","line-height":"1.2",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"}},At={style:{color:"#64748B","font-size":"11px","margin-top":"2px"}},zt={class:"flex-1",style:{"margin-left":"256px"}},Vt={class:"bg-white shadow-sm sticky top-0 z-20 h-16 flex items-center justify-between px-6"},jt={class:"flex items-center gap-2 text-sm"},Tt={class:"text-slate-700 font-medium"},Bt={class:"flex items-center gap-2"},Et={class:"dropdown dropdown-end"},Lt={tabindex:"0",class:"flex items-center gap-2 cursor-pointer hover:bg-slate-50 rounded-lg px-3 py-1.5"},Mt={class:"avatar placeholder"},Nt={class:"bg-indigo-600 text-white rounded-full w-8"},St={class:"text-sm"},Ut={class:"text-sm text-slate-700 leading-tight"},$t={class:"text-[10px] text-slate-400"},Ft={key:0,class:"modal modal-open"},Dt={class:"modal-box max-w-sm"},Ot={class:"space-y-3"},It={class:"modal-action"},Pt=["disabled"],Rt={class:"p-6"},Jt=C({__name:"default",setup(A){const n=W(),p=J(),r=K(),{consoleApi:z}=ot(),{success:u,error:f}=L();function V(){n.logout(),p.push("/")}const _=E(!1),g=E(!1),s=et({old:"",next:"",confirm:""});function S(){s.old="",s.next="",s.confirm="",_.value=!0}async function U(){if(!s.old||!s.next){f("原密码和新密码必填");return}if(s.next.length<6){f("新密码至少 6 位");return}if(s.next!==s.confirm){f("两次输入的新密码不一致");return}g.value=!0;try{await z("accounts/changepwd",{old_password:s.old,new_password:s.next}),_.value=!1,u("密码已修改,请重新登录"),setTimeout(V,800)}catch(d){f(d?.message??"修改失败")}finally{g.value=!1}}const $=h(()=>({1:"超级管理员",2:"管理员",3:"代理",4:"运营"})[n.identity]??""),F=h(()=>({1:"超管",2:"管理员",3:"代理",4:"运营"})[n.identity]??""),j=h(()=>(n.account||"A").charAt(0).toUpperCase()),T=Y;function D(d){return d.items.some(e=>n.hasAccess(e.id))}const O=h(()=>{if(r.meta?.title)return r.meta.title;for(const d of T){const e=d.items.find(b=>r.path.startsWith(b.to));if(e)return e.label}return"Console"});return Q(()=>{n.token||p.push("/")}),(d,e)=>{const b=R,I=at,P=dt;return o(),l("div",ct,[t("aside",pt,[t("div",ut,[t("div",xt,[t("div",mt,[(o(),l("svg",ft,[...e[4]||(e[4]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"},null,-1)])]))]),t("div",null,[t("div",_t,i(c(n).siteTitle||"Admin"),1),e[5]||(e[5]=t("div",{style:{color:"#64748B","font-size":"11px","font-weight":"500"}},"Admin Console · v1.0.1",-1))])])]),t("nav",ht,[(o(!0),l(m,null,k(c(T),a=>(o(),l(m,null,[D(a)?(o(),l("div",{key:a.label,class:"group-title"},i(a.label),1)):v("",!0),(o(!0),l(m,null,k(a.items,x=>(o(),l(m,null,[c(n).hasAccess(x.id)?(o(),M(b,{key:x.id,to:x.to,class:"sidebar-link","active-class":"active"},{default:N(()=>[(o(),l("svg",vt,[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:x.icon},null,8,gt)])),X(" "+i(x.label),1)]),_:2},1032,["to"])):v("",!0)],64))),256))],64))),256))]),t("div",bt,[t("div",wt,[t("div",yt,i(j.value),1),t("div",kt,[t("div",Ct,i(c(n).account||"-"),1),t("div",At,i($.value),1)])])])]),t("main",zt,[t("header",Vt,[t("div",jt,[e[6]||(e[6]=t("span",{class:"text-slate-400"},"首页",-1)),e[7]||(e[7]=t("span",{class:"text-slate-300"},"/",-1)),t("span",Tt,i(O.value),1)]),t("div",Bt,[e[8]||(e[8]=Z('<div class="dropdown dropdown-end"><div tabindex="0" class="btn btn-ghost btn-sm btn-circle relative"><svg class="h-5 w-5 text-slate-500" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"></path></svg></div><div tabindex="0" class="dropdown-content z-[2] shadow-xl bg-white rounded-xl w-80 border" style="max-height:400px;"><div class="flex items-center justify-between px-4 py-3 border-b"><span class="text-sm font-semibold text-slate-700">系统通知</span></div><div class="px-3 py-6 text-center text-slate-400 text-xs">暂无新通知</div></div></div>',1)),t("div",Et,[t("div",Lt,[t("div",Mt,[t("div",Nt,[t("span",St,i(j.value),1)])]),t("div",null,[t("div",Ut,i(c(n).account),1),t("div",$t,i(F.value),1)])]),t("ul",{tabindex:"0",class:"dropdown-content z-[1] menu p-2 shadow-lg bg-white rounded-lg w-44 border"},[t("li",null,[t("a",{class:"text-sm cursor-pointer",onClick:S},"修改密码")]),t("li",null,[t("a",{class:"text-sm text-red-500 cursor-pointer",onClick:V},"退出登录")])])])])]),_.value?(o(),l("div",Ft,[t("div",Dt,[e[12]||(e[12]=t("h3",{class:"font-bold text-base mb-3"},"修改密码",-1)),t("div",Ot,[t("div",null,[e[9]||(e[9]=t("label",{class:"text-xs text-slate-500"},"原密码",-1)),w(t("input",{"onUpdate:modelValue":e[0]||(e[0]=a=>s.old=a),type:"password",class:"input input-bordered input-sm w-full",autocomplete:"current-password"},null,512),[[y,s.old]])]),t("div",null,[e[10]||(e[10]=t("label",{class:"text-xs text-slate-500"},"新密码(至少 6 位)",-1)),w(t("input",{"onUpdate:modelValue":e[1]||(e[1]=a=>s.next=a),type:"password",class:"input input-bordered input-sm w-full",autocomplete:"new-password"},null,512),[[y,s.next]])]),t("div",null,[e[11]||(e[11]=t("label",{class:"text-xs text-slate-500"},"确认新密码",-1)),w(t("input",{"onUpdate:modelValue":e[2]||(e[2]=a=>s.confirm=a),type:"password",class:"input input-bordered input-sm w-full",autocomplete:"new-password"},null,512),[[y,s.confirm]])])]),e[13]||(e[13]=t("p",{class:"text-xs text-slate-400 mt-3"},"改完需要重新登录。",-1)),t("div",It,[t("button",{class:"btn btn-ghost btn-sm",onClick:e[3]||(e[3]=a=>_.value=!1)},"取消"),t("button",{class:"btn btn-primary btn-sm text-white",disabled:g.value,onClick:U},"确认修改",8,Pt)])])])):v("",!0),B(I),B(P),t("div",Rt,[tt(d.$slots,"default")])])])}}});export{Jt as default};