From 0b2e6efe2858e8dc9fdce7411a7c957b4bb9e689 Mon Sep 17 00:00:00 2001 From: Supra4E8C Date: Sat, 27 Dec 2025 14:42:10 +0800 Subject: [PATCH] fix(logs): keep log panel scroll within viewport --- src/components/layout/MainLayout.tsx | 6 ++++-- src/pages/LogsPage.module.scss | 8 ++------ src/styles/layout.scss | 5 +++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index b132e6d..41c6052 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -7,7 +7,7 @@ import { useRef, useState, } from 'react'; -import { NavLink, Outlet } from 'react-router-dom'; +import { NavLink, Outlet, useLocation } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Button } from '@/components/ui/Button'; import { Modal } from '@/components/ui/Modal'; @@ -173,6 +173,7 @@ const compareVersions = (latest?: string | null, current?: string | null) => { export function MainLayout() { const { t, i18n } = useTranslation(); const { showNotification } = useNotificationStore(); + const location = useLocation(); const apiBase = useAuthStore((state) => state.apiBase); const serverVersion = useAuthStore((state) => state.serverVersion); @@ -207,6 +208,7 @@ export function MainLayout() { const requestLogEnabled = config?.requestLog ?? false; const requestLogDirty = requestLogDraft !== requestLogEnabled; const canEditRequestLog = connectionStatus === 'connected' && Boolean(config); + const isLogsPage = location.pathname.startsWith('/logs'); // 将顶栏高度写入 CSS 变量,确保侧栏/内容区计算一致,防止滚动时抖动 useLayoutEffect(() => { @@ -504,7 +506,7 @@ export function MainLayout() {
-
+
diff --git a/src/pages/LogsPage.module.scss b/src/pages/LogsPage.module.scss index f95683c..0c1d176 100644 --- a/src/pages/LogsPage.module.scss +++ b/src/pages/LogsPage.module.scss @@ -161,8 +161,8 @@ background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: $radius-md; - flex: 0 0 auto; - height: 480px; + flex: 1 1 auto; + min-height: 0; overflow: auto; position: relative; -webkit-overflow-scrolling: touch; @@ -401,10 +401,6 @@ padding: $spacing-md; } - .logPanel { - height: 360px; - } - .errorPanel { height: 360px; } diff --git a/src/styles/layout.scss b/src/styles/layout.scss index 9e733de..bcd1529 100644 --- a/src/styles/layout.scss +++ b/src/styles/layout.scss @@ -338,6 +338,11 @@ gap: $spacing-lg; overflow-x: hidden; + &.main-content-logs { + flex: 1 1 auto; + min-height: 0; + } + @media (max-width: $breakpoint-mobile) { padding: $spacing-md; }