fix(logs): keep log panel scroll within viewport

This commit is contained in:
Supra4E8C
2025-12-27 14:42:10 +08:00
parent 8ca6d31a26
commit 0b2e6efe28
3 changed files with 11 additions and 8 deletions

View File

@@ -7,7 +7,7 @@ import {
useRef, useRef,
useState, useState,
} from 'react'; } from 'react';
import { NavLink, Outlet } from 'react-router-dom'; import { NavLink, Outlet, useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/Button'; import { Button } from '@/components/ui/Button';
import { Modal } from '@/components/ui/Modal'; import { Modal } from '@/components/ui/Modal';
@@ -173,6 +173,7 @@ const compareVersions = (latest?: string | null, current?: string | null) => {
export function MainLayout() { export function MainLayout() {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
const { showNotification } = useNotificationStore(); const { showNotification } = useNotificationStore();
const location = useLocation();
const apiBase = useAuthStore((state) => state.apiBase); const apiBase = useAuthStore((state) => state.apiBase);
const serverVersion = useAuthStore((state) => state.serverVersion); const serverVersion = useAuthStore((state) => state.serverVersion);
@@ -207,6 +208,7 @@ export function MainLayout() {
const requestLogEnabled = config?.requestLog ?? false; const requestLogEnabled = config?.requestLog ?? false;
const requestLogDirty = requestLogDraft !== requestLogEnabled; const requestLogDirty = requestLogDraft !== requestLogEnabled;
const canEditRequestLog = connectionStatus === 'connected' && Boolean(config); const canEditRequestLog = connectionStatus === 'connected' && Boolean(config);
const isLogsPage = location.pathname.startsWith('/logs');
// 将顶栏高度写入 CSS 变量,确保侧栏/内容区计算一致,防止滚动时抖动 // 将顶栏高度写入 CSS 变量,确保侧栏/内容区计算一致,防止滚动时抖动
useLayoutEffect(() => { useLayoutEffect(() => {
@@ -504,7 +506,7 @@ export function MainLayout() {
</aside> </aside>
<div className="content"> <div className="content">
<main className="main-content"> <main className={`main-content${isLogsPage ? ' main-content-logs' : ''}`}>
<Outlet /> <Outlet />
</main> </main>

View File

@@ -161,8 +161,8 @@
background: var(--bg-secondary); background: var(--bg-secondary);
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: $radius-md; border-radius: $radius-md;
flex: 0 0 auto; flex: 1 1 auto;
height: 480px; min-height: 0;
overflow: auto; overflow: auto;
position: relative; position: relative;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
@@ -401,10 +401,6 @@
padding: $spacing-md; padding: $spacing-md;
} }
.logPanel {
height: 360px;
}
.errorPanel { .errorPanel {
height: 360px; height: 360px;
} }

View File

@@ -338,6 +338,11 @@
gap: $spacing-lg; gap: $spacing-lg;
overflow-x: hidden; overflow-x: hidden;
&.main-content-logs {
flex: 1 1 auto;
min-height: 0;
}
@media (max-width: $breakpoint-mobile) { @media (max-width: $breakpoint-mobile) {
padding: $spacing-md; padding: $spacing-md;
} }