import{a as e,n as t}from"./preload-helper-DxX6f4wy.js";import{$ as n,O as r,n as i,t as a}from"./Fade-Bj1YUcWe.js";import{n as o,t as s}from"./Box-BoFhqo9n.js";import{t as c}from"./ButtonBase-dVPwHUcG.js";import{t as l}from"./Chip-GlqHKmzW.js";import{t as u}from"./Grid-DQAAwiyo.js";import{t as d}from"./Article-DU6u_Kpl.js";import{l as f,t as p}from"./chunk-KS7C4IRE-C-Go0Sd1.js";import{a as m}from"./client-BTeclN8X.js";import{t as h}from"./Loading-BIwVunRy.js";import{d as g,l as _,u as v}from"./index-BTWPkaRa.js";import{m as y}from"./admin-D5DUHyY6.js";var b=e(t(),1),x=n();function S(){let e=f(),t=m(`/api/v1/admin/dashboard`),[n,S]=(0,b.useState)(t.data?.counts||{posts:0,tags:0,media:0,users:0}),[C,w]=(0,b.useState)(!t.hit);if((0,b.useEffect)(()=>{t.hit||w(!0),y().then(e=>{e&&S(e.counts),w(!1)})},[]),C)return(0,x.jsx)(h,{text:`加载站点数据中...`});let T=[{title:`文章总数`,value:n.posts,icon:(0,x.jsx)(d,{}),color:`primary.main`,path:`/admin/posts`},{title:`标签总数`,value:n.tags,icon:(0,x.jsx)(g,{}),color:`secondary.main`,path:`/admin/tags`},{title:`媒体总数`,value:n.media,icon:(0,x.jsx)(_,{}),color:`success.main`,path:`/admin/media`},{title:`用户总数`,value:n.users,icon:(0,x.jsx)(v,{}),color:`warning.main`,path:`/admin/users`}];return(0,x.jsx)(a,{in:!0,timeout:400,children:(0,x.jsxs)(s,{children:[(0,x.jsx)(i,{variant:`h5`,sx:{fontWeight:700,mb:3},children:`站点概览`}),(0,x.jsx)(u,{container:!0,spacing:3,children:T.map(t=>(0,x.jsx)(u,{item:!0,xs:12,sm:6,lg:3,children:(0,x.jsx)(c,{onClick:()=>e(t.path),sx:{width:`100%`,display:`block`,borderRadius:1,textAlign:`left`},children:(0,x.jsxs)(o,{elevation:0,sx:{p:{xs:2,sm:3},borderRadius:1,display:`flex`,alignItems:`center`,gap:2,boxShadow:e=>e.palette.mode===`light`?`0 4px 20px ${r(e.palette.primary.main,.08)}`:`0 4px 20px ${r(e.palette.common.black,.25)}`,transition:e=>e.transitions.create([`box-shadow`,`transform`],{duration:e.transitions.duration.short}),"&:hover":{boxShadow:e=>e.palette.mode===`light`?`0 8px 28px ${r(e.palette.primary.main,.14)}`:`0 8px 28px ${r(e.palette.common.black,.35)}`,transform:`translateY(-2px)`}},children:[(0,x.jsx)(s,{sx:{width:{xs:44,sm:52},height:{xs:44,sm:52},borderRadius:1,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`white`,backgroundColor:t.color,boxShadow:`0 4px 12px ${t.color}40`,flexShrink:0},children:t.icon}),(0,x.jsxs)(s,{sx:{minWidth:0},children:[(0,x.jsx)(i,{variant:`body2`,color:`text.secondary`,sx:{overflowWrap:`break-word`},children:t.title}),(0,x.jsx)(i,{variant:`h5`,sx:{fontWeight:700,overflowWrap:`break-word`},children:t.value})]})]})})},t.title))}),(0,x.jsxs)(o,{elevation:0,sx:{mt:4,p:{xs:2,sm:3,md:4},borderRadius:1,boxShadow:e=>e.palette.mode===`light`?`0 4px 20px ${r(e.palette.primary.main,.08)}`:`0 4px 20px ${r(e.palette.common.black,.25)}`},children:[(0,x.jsx)(i,{variant:`h6`,sx:{fontWeight:700,mb:2},children:`快捷入口`}),(0,x.jsx)(s,{sx:{display:`flex`,gap:1.5,flexWrap:`wrap`,minWidth:0},children:[{label:`前往文章管理`,to:`/admin/posts`,color:`primary`},{label:`前往标签管理`,to:`/admin/tags`,color:`secondary`},{label:`前往媒体管理`,to:`/admin/media`,color:`success`},{label:`前往用户管理`,to:`/admin/users`,color:`warning`},{label:`前往评论管理`,to:`/admin/comments`,color:`error`},{label:`前往 AI 管理`,to:`/admin/ai`,color:`info`},{label:`前往友链管理`,to:`/admin/friends`,color:`primary`},{label:`前往主题管理`,to:`/admin/themes`,color:`secondary`},{label:`前往外观设置`,to:`/admin/appearance`,color:`success`},{label:`前往高级设置`,to:`/admin/advanced`,color:`warning`}].map(e=>{let t=e.color;return(0,x.jsx)(l,{label:e.label,component:p,to:e.to,clickable:!0,sx:{borderRadius:1,px:1,py:2.5,minHeight:44,height:`auto`,fontWeight:600,backgroundColor:e=>r(e.palette[t].main,e.palette.mode===`light`?.1:.2),color:`${e.color}.main`,"& .MuiChip-label":{whiteSpace:`normal`,overflowWrap:`break-word`,maxWidth:`100%`}}},e.to)})})]})]})})}export{S as AdminDashboard};