diff --git a/frontend/src/components/AdminLayout.tsx b/frontend/src/components/AdminLayout.tsx index 457647a..59366ad 100644 --- a/frontend/src/components/AdminLayout.tsx +++ b/frontend/src/components/AdminLayout.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useState, useMemo } from 'react'; import { Layout, Menu, Button, theme, App } from 'antd'; import { MenuFoldOutlined, @@ -6,9 +6,12 @@ import { DashboardOutlined, SettingOutlined, LogoutOutlined, + SunOutlined, + MoonOutlined, } from '@ant-design/icons'; import { Outlet, useNavigate, useLocation } from 'react-router-dom'; import { useAuthStore } from '../stores/authStore'; +import { useThemeStore } from '../stores/themeStore'; import { adminAuthService } from '../services/adminAuthService'; const { Header, Sider, Content, Footer } = Layout; @@ -23,6 +26,16 @@ const AdminLayout = () => { const adminUser = useAuthStore((state) => state.adminUser); const logout = useAuthStore((state) => state.logout); const { message } = App.useApp(); + const { themeMode, toggleTheme } = useThemeStore(); + + // 根据当前路径计算应该展开的菜单 + const openKeys = useMemo(() => { + const path = location.pathname; + if (path.startsWith('/admin/users')) { + return ['user']; + } + return []; + }, [location.pathname]); const handleLogout = async () => { try { @@ -56,26 +69,34 @@ const AdminLayout = () => { return ( - +
{collapsed ? '运营' : '运营管理系统'}
navigate(key)} /> @@ -99,14 +120,23 @@ const AdminLayout = () => { fontSize: '16px', width: 64, height: 64, + outline: 'none', }} />
+ @@ -123,7 +153,12 @@ const AdminLayout = () => { > -