Forráskód Böngészése

style: fix layout overflow and scrolling issues in NodeLogTerminal and NodeTelemetryModal components

jerry 1 hónapja
szülő
commit
91c5310a2e

+ 51 - 46
src/components/admin/node-configurations/NodeLogTerminal.tsx

@@ -204,9 +204,9 @@ export default function NodeLogTerminal({
   };
 
   return (
-    <div className="flex flex-col h-full bg-neutral-900 border-2 border-black text-xs font-mono select-text">
+    <div className="flex flex-col h-full min-h-0 bg-neutral-900 border-2 border-black text-xs font-mono select-text overflow-hidden">
       {/* 1. 顶部控制工具栏 */}
-      <div className="bg-neutral-800 border-b-2 border-black p-2.5 flex flex-wrap items-center justify-between gap-2 text-white">
+      <div className="bg-neutral-800 border-b-2 border-black p-2.5 flex flex-wrap items-center justify-between gap-2 text-white shrink-0 select-none">
         {/* 左侧:角色切换 & 状态指示 */}
         <div className="flex items-center gap-2 flex-wrap">
           <div className="flex items-center gap-1.5 px-2 py-1 bg-black border border-neutral-700">
@@ -376,7 +376,7 @@ export default function NodeLogTerminal({
       <div
         ref={terminalBodyRef}
         onScroll={handleScroll}
-        className="flex-1 overflow-y-auto p-3.5 space-y-1 bg-[#0d1117] text-neutral-200 font-mono text-[11px] leading-relaxed relative min-h-[360px] max-h-[560px]"
+        className="flex-1 min-h-0 overflow-y-auto p-3.5 pb-6 space-y-1 bg-[#0d1117] text-neutral-200 font-mono text-[11px] leading-relaxed relative"
       >
         {filteredLogs.length === 0 ? (
           <div className="h-full flex flex-col items-center justify-center text-neutral-500 py-16">
@@ -395,54 +395,59 @@ export default function NodeLogTerminal({
             )}
           </div>
         ) : (
-          filteredLogs.map((log, idx) => {
-            const lvl = (log.level || 'INFO').toUpperCase();
-            const isError = lvl === 'ERROR';
-            const isWarn = lvl === 'WARN' || lvl === 'WARNING';
-
-            return (
-              <div
-                key={log.id ? `${log.id}-${idx}` : idx}
-                className={`flex items-start gap-2 py-0.5 hover:bg-neutral-800/60 rounded-xs px-1.5 transition ${
-                  isError
-                    ? 'text-rose-300 bg-rose-950/20'
-                    : isWarn
-                    ? 'text-amber-200 bg-amber-950/20'
-                    : 'text-neutral-300'
-                }`}
-              >
-                {/* 时间戳 */}
-                <span className="text-neutral-500 shrink-0 select-none">
-                  {log.timestamp ? log.timestamp.split(' ')[1] || log.timestamp : '--:--:--'}
-                </span>
-
-                {/* 级别 Badge */}
-                <span
-                  className={`px-1 py-0.2 rounded-2xs text-[9px] font-black uppercase shrink-0 ${
+          <>
+            {filteredLogs.map((log, idx) => {
+              const lvl = (log.level || 'INFO').toUpperCase();
+              const isError = lvl === 'ERROR';
+              const isWarn = lvl === 'WARN' || lvl === 'WARNING';
+
+              return (
+                <div
+                  key={log.id ? `${log.id}-${idx}` : idx}
+                  className={`flex items-start gap-2 py-0.5 hover:bg-neutral-800/60 rounded-xs px-1.5 transition ${
                     isError
-                      ? 'bg-rose-700 text-white'
+                      ? 'text-rose-300 bg-rose-950/20'
                       : isWarn
-                      ? 'bg-amber-500 text-black'
-                      : 'bg-neutral-800 text-emerald-400 border border-emerald-900/60'
+                      ? 'text-amber-200 bg-amber-950/20'
+                      : 'text-neutral-300'
                   }`}
                 >
-                  {lvl}
-                </span>
+                  {/* 时间戳 */}
+                  <span className="text-neutral-500 shrink-0 select-none">
+                    {log.timestamp ? log.timestamp.split(' ')[1] || log.timestamp : '--:--:--'}
+                  </span>
 
-                {/* Group 标识 (若有) */}
-                {log.group_id && (
-                  <span className="px-1 py-0.2 rounded-2xs text-[9px] font-mono font-bold bg-cyan-950 text-cyan-300 border border-cyan-800 shrink-0">
-                    {log.group_id}
+                  {/* 级别 Badge */}
+                  <span
+                    className={`px-1 py-0.2 rounded-2xs text-[9px] font-black uppercase shrink-0 ${
+                      isError
+                        ? 'bg-rose-700 text-white'
+                        : isWarn
+                        ? 'bg-amber-500 text-black'
+                        : 'bg-neutral-800 text-emerald-400 border border-emerald-900/60'
+                    }`}
+                  >
+                    {lvl}
                   </span>
-                )}
-
-                {/* 日志内容 */}
-                <span className="break-all whitespace-pre-wrap flex-1">
-                  {renderMessageWithHighlight(log.message)}
-                </span>
-              </div>
-            );
-          })
+
+                  {/* Group 标识 (若有) */}
+                  {log.group_id && (
+                    <span className="px-1 py-0.2 rounded-2xs text-[9px] font-mono font-bold bg-cyan-950 text-cyan-300 border border-cyan-800 shrink-0">
+                      {log.group_id}
+                    </span>
+                  )}
+
+                  {/* 日志内容 */}
+                  <span className="break-all whitespace-pre-wrap flex-1">
+                    {renderMessageWithHighlight(log.message)}
+                  </span>
+                </div>
+              );
+            })}
+
+            {/* 底部缓冲垫,确保最后一条日志即使自动置底时也不会被贴底截断或遮挡 */}
+            <div className="h-6 shrink-0" aria-hidden="true" />
+          </>
         )}
 
         {/* 浮动置底按钮 */}
@@ -459,7 +464,7 @@ export default function NodeLogTerminal({
       </div>
 
       {/* 3. 底部状态指示栏 */}
-      <div className="bg-neutral-950 border-t border-neutral-800 px-3 py-1 flex items-center justify-between text-[10px] text-neutral-400">
+      <div className="bg-neutral-950 border-t border-neutral-800 px-3 py-1.5 flex items-center justify-between text-[10px] text-neutral-400 shrink-0 select-none">
         <div className="flex items-center gap-3">
           <span>
             通道: <code>vs:stream:logs:{nodeId}:{selectedRole}</code>

+ 10 - 7
src/components/admin/node-configurations/NodeTelemetryModal.tsx

@@ -151,9 +151,9 @@ export default function NodeTelemetryModal({
 
   return (
     <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs font-mono">
-      <div className="bg-white border-4 border-black w-full max-w-5xl max-h-[92vh] flex flex-col shadow-[8px_8px_0px_#000] overflow-hidden">
+      <div className="bg-white border-4 border-black w-full max-w-5xl h-[88vh] max-h-[92vh] flex flex-col shadow-[8px_8px_0px_#000] overflow-hidden">
         {/* Modal Header */}
-        <div className="bg-neutral-200 border-b-2 border-black p-4 flex items-center justify-between select-none">
+        <div className="bg-neutral-200 border-b-2 border-black p-4 flex items-center justify-between select-none shrink-0">
           <div className="flex items-center gap-2.5">
             <Radio size={20} className="text-black animate-pulse" />
             <div>
@@ -210,7 +210,7 @@ export default function NodeTelemetryModal({
         </div>
 
         {/* Modal Tab Bar */}
-        <div className="bg-neutral-100 border-b-2 border-black px-4 py-2 flex items-center justify-between select-none">
+        <div className="bg-neutral-100 border-b-2 border-black px-4 py-2 flex items-center justify-between select-none shrink-0">
           <div className="flex items-center gap-2">
             <button
               type="button"
@@ -249,7 +249,7 @@ export default function NodeTelemetryModal({
         </div>
 
         {activeTab === 'logs' ? (
-          <div className="flex-1 p-3 overflow-hidden flex flex-col bg-neutral-900 min-h-[480px]">
+          <div className="flex-1 min-h-0 p-3 overflow-hidden flex flex-col bg-neutral-900">
             <NodeLogTerminal
               nodeId={node.node_id}
               initialRole={availableRoles[0] || 'sentinel'}
@@ -259,7 +259,7 @@ export default function NodeTelemetryModal({
           </div>
         ) : (
           /* Modal Scrollable Body */
-          <div className="p-5 overflow-y-auto space-y-5 text-xs flex-1">
+          <div className="p-5 pb-8 overflow-y-auto space-y-5 text-xs flex-1 min-h-0">
           {/* 1. 核心遥测生命体征看板 (Vitality Status Banner) */}
           {isOnline ? (
             <div className="p-4 bg-emerald-50 border-2 border-black shadow-[3px_3px_0px_#000] flex flex-col md:flex-row md:items-center justify-between gap-4">
@@ -579,12 +579,15 @@ export default function NodeTelemetryModal({
               • <strong>离线排查建议</strong>: 检查目标服务器是否已运行 <code>python main.py &lt;role&gt;</code>,或检查服务器与 Redis 之间的网络联通性。
             </p>
           </div>
+
+          {/* 底部缓冲留白,防止滚动到底部时最后一行文字贴底或被裁切 */}
+          <div className="h-6 shrink-0" aria-hidden="true" />
         </div>
       )}
 
         {/* Modal Footer */}
-        <div className="bg-neutral-200 border-t-2 border-black p-3 px-5 flex items-center justify-between">
-          <div className="text-[10px] text-neutral-500 font-bold">
+        <div className="bg-neutral-200 border-t-2 border-black p-3 px-5 flex items-center justify-between shrink-0 select-none">
+          <div className="text-[10px] text-neutral-600 font-bold">
             {activeTab === 'logs' ? (
               <span>控制台状态: <code className="text-black font-black">ACTIVE (SSE STREAM)</code> | 缓冲上限: 1500 条</span>
             ) : (