侧边栏增加 admin 用户管理入口

admin 用户可在侧边栏底部进入用户管理页,
支持新增/删除用户。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-06 15:05:35 +08:00
parent c1fa0461c1
commit e7cd30b30d
+18
View File
@@ -28,6 +28,8 @@ import {
Moon, Moon,
Sun, Sun,
User, User,
Users,
Shield,
LogOut, LogOut,
} from 'lucide-react' } from 'lucide-react'
import { Logo } from './Logo' import { Logo } from './Logo'
@@ -92,6 +94,7 @@ export function Layout() {
}) })
const username = authData?.username const username = authData?.username
const role = authData?.role
const navigate = useNavigate() const navigate = useNavigate()
const qc = useQueryClient() const qc = useQueryClient()
const [darkMode, setDarkMode] = useState(() => { const [darkMode, setDarkMode] = useState(() => {
@@ -209,6 +212,21 @@ export function Layout() {
</div> </div>
)} )}
{/* 用户管理 (admin only) */}
{role === 'admin' && (
<NavLink
to="/settings/users"
className={({ isActive }) =>
'flex items-center gap-2 px-3 py-1.5 text-xs text-foreground/70 hover:bg-elevated hover:text-foreground transition-colors' +
(isActive ? ' bg-accent/10 text-accent' : '')
}
>
<Users className="h-3.5 w-3.5" />
<Shield className="h-3 w-3 text-amber-400" />
<span className="flex-1"></span>
</NavLink>
)}
{/* 暗夜模式 */} {/* 暗夜模式 */}
<div className="px-1"> <div className="px-1">
<button <button