From 04b0559fb8cf6240808af6ea35852b7add133ae7 Mon Sep 17 00:00:00 2001 From: jacy-dukang Date: Mon, 6 Jul 2026 19:35:15 +0800 Subject: [PATCH] =?UTF-8?q?webadmin=E7=95=8C=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin-web/src/admin.css | 17 +++++++ apps/admin-web/src/layouts/AdminLayout.tsx | 59 +++++++++++++++------- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/apps/admin-web/src/admin.css b/apps/admin-web/src/admin.css index eeba271..42e62cd 100644 --- a/apps/admin-web/src/admin.css +++ b/apps/admin-web/src/admin.css @@ -1,3 +1,20 @@ +html, +body, +#root { + height: 100%; + margin: 0; +} + +/* 左侧导航可滚动但不显示滚动条 */ +.admin-sider-menu-scroll { + scrollbar-width: none; + -ms-overflow-style: none; +} + +.admin-sider-menu-scroll::-webkit-scrollbar { + display: none; +} + .admin-table-nowrap .ant-table-cell { white-space: nowrap; } diff --git a/apps/admin-web/src/layouts/AdminLayout.tsx b/apps/admin-web/src/layouts/AdminLayout.tsx index 6f6a7da..846f117 100644 --- a/apps/admin-web/src/layouts/AdminLayout.tsx +++ b/apps/admin-web/src/layouts/AdminLayout.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { Outlet, useLocation, useNavigate } from 'react-router-dom'; import { Layout, Menu, Typography, Button, Space } from 'antd'; import type { MenuProps } from 'antd'; @@ -92,12 +92,17 @@ const MENU_ITEMS: MenuProps['items'] = [ export default function AdminLayout() { const navigate = useNavigate(); const location = useLocation(); + const contentRef = useRef(null); const [profile, setProfile] = useState(null); useEffect(() => { request('/admin/auth/me').then(setProfile).catch(() => {}); }, []); + useEffect(() => { + contentRef.current?.scrollTo({ top: 0, left: 0 }); + }, [location.pathname]); + function logout() { clearAuth(); navigate('/login'); @@ -106,23 +111,36 @@ export default function AdminLayout() { const selectedKey = location.pathname; return ( - - -
杜康 HQ
- { - if (key.startsWith('/')) navigate(key); - }} - /> + + +
+
+ 杜康 HQ +
+
+ { + if (key.startsWith('/')) navigate(key); + }} + /> +
+
- +
- - - +
+ + + +
);