From 8117b61fb17f7dad4501ea45e8e49abb90a8656a Mon Sep 17 00:00:00 2001 From: dengqichen Date: Wed, 17 Dec 2025 09:54:23 +0800 Subject: [PATCH] 1.40 --- .../Dashboard/components/ApplicationCard.tsx | 2 +- .../components/DockerRuntimeStatus.tsx | 80 +--- .../Dashboard/components/K8sRuntimeStatus.tsx | 81 +--- .../Dashboard/components/LogStreamViewer.tsx | 2 +- .../Dashboard/components/LogViewerWindow.tsx | 357 ++++++++++-------- .../components/ServerRuntimeStatus.tsx | 76 +--- 6 files changed, 232 insertions(+), 366 deletions(-) diff --git a/frontend/src/pages/Dashboard/components/ApplicationCard.tsx b/frontend/src/pages/Dashboard/components/ApplicationCard.tsx index 4a6cc92b..74bbf121 100644 --- a/frontend/src/pages/Dashboard/components/ApplicationCard.tsx +++ b/frontend/src/pages/Dashboard/components/ApplicationCard.tsx @@ -101,7 +101,7 @@ export const ApplicationCard: React.FC = ({ - 运行时 + 实例 diff --git a/frontend/src/pages/Dashboard/components/DockerRuntimeStatus.tsx b/frontend/src/pages/Dashboard/components/DockerRuntimeStatus.tsx index 5984505c..291cacac 100644 --- a/frontend/src/pages/Dashboard/components/DockerRuntimeStatus.tsx +++ b/frontend/src/pages/Dashboard/components/DockerRuntimeStatus.tsx @@ -11,14 +11,6 @@ export const DockerRuntimeStatus: React.FC = ({ dockerServerName, dockerContainerName, }) => { - // MOCK数据 - 后续替换为真实API - const mockStatus = { - status: 'running', - uptime: '2h 15m', - cpu: { used: 0.5, total: 2, percentage: 25 }, - memory: { used: 512, total: 1024, percentage: 50 }, - }; - return (
{/* 运行时类型 */} @@ -27,70 +19,16 @@ export const DockerRuntimeStatus: React.FC = ({ Docker - {/* 运行状态 */} -
-
-
- 运行中 -
- -
-
- 容器状态 - Running -
- -
- 运行时长 - {mockStatus.uptime} -
- -
-
- CPU - {mockStatus.cpu.percentage}% -
-
-
-
-
- {mockStatus.cpu.used}/{mockStatus.cpu.total} cores -
-
- -
-
- 内存 - {mockStatus.memory.percentage}% -
-
-
-
-
- {mockStatus.memory.used}MB/{mockStatus.memory.total}MB -
-
-
-
- - {/* 配置详情 */} -
-
配置详情
-
-
- 服务器 - {dockerServerName || '-'} -
-
- 容器 - {dockerContainerName || '-'} + {/* 运行状态 - 研发中 */} +
+
+
实例监控功能
+
+
+
+
+
研发中...
diff --git a/frontend/src/pages/Dashboard/components/K8sRuntimeStatus.tsx b/frontend/src/pages/Dashboard/components/K8sRuntimeStatus.tsx index 4f535f86..e59ced80 100644 --- a/frontend/src/pages/Dashboard/components/K8sRuntimeStatus.tsx +++ b/frontend/src/pages/Dashboard/components/K8sRuntimeStatus.tsx @@ -13,14 +13,6 @@ export const K8sRuntimeStatus: React.FC = ({ k8sNamespaceName, k8sDeploymentName, }) => { - // MOCK数据 - 后续替换为真实API - const mockStatus = { - status: 'running', - podCount: { ready: 3, total: 3 }, - cpu: { used: 0.9, total: 2, percentage: 45 }, - memory: { used: 1.2, total: 2, percentage: 60 }, - }; - return (
{/* 运行时类型 */} @@ -29,71 +21,16 @@ export const K8sRuntimeStatus: React.FC = ({ Kubernetes - {/* 运行状态 */} -
-
-
- 运行中 -
- -
-
- Pod - - {mockStatus.podCount.ready}/{mockStatus.podCount.total} Running - -
- -
-
- CPU - {mockStatus.cpu.percentage}% -
-
-
-
-
- {mockStatus.cpu.used}/{mockStatus.cpu.total} cores -
-
- -
-
- 内存 - {mockStatus.memory.percentage}% -
-
-
-
-
- {mockStatus.memory.used}GB/{mockStatus.memory.total}GB -
-
-
-
- - {/* 配置详情 */} -
-
配置详情
-
-
- 系统 - {k8sSystemName || '-'} -
-
- 命名空间 - {k8sNamespaceName || '-'} -
-
- 部署 - {k8sDeploymentName || '-'} + {/* 运行状态 - 研发中 */} +
+
+
实例监控功能
+
+
+
+
+
研发中...
diff --git a/frontend/src/pages/Dashboard/components/LogStreamViewer.tsx b/frontend/src/pages/Dashboard/components/LogStreamViewer.tsx index 1e4f3127..50fd1ae4 100644 --- a/frontend/src/pages/Dashboard/components/LogStreamViewer.tsx +++ b/frontend/src/pages/Dashboard/components/LogStreamViewer.tsx @@ -98,7 +98,7 @@ export const LogStreamViewer: React.FC = ({ return (
{logs.map((log) => (
diff --git a/frontend/src/pages/Dashboard/components/LogViewerWindow.tsx b/frontend/src/pages/Dashboard/components/LogViewerWindow.tsx index e6173973..8512f124 100644 --- a/frontend/src/pages/Dashboard/components/LogViewerWindow.tsx +++ b/frontend/src/pages/Dashboard/components/LogViewerWindow.tsx @@ -24,6 +24,8 @@ import { Loader2, ScrollText, Circle, + ChevronUp, + ChevronDown, } from "lucide-react"; import { LogStreamViewer } from './LogStreamViewer'; import { useLogStream } from '../hooks/useLogStream'; @@ -53,6 +55,7 @@ export const LogViewerWindow: React.FC = ({ const [podName, setPodName] = useState(''); const [podNames, setPodNames] = useState([]); const [loadingPods, setLoadingPods] = useState(false); + const [isControlBarCollapsed, setIsControlBarCollapsed] = useState(false); const closeAllRef = useRef<(() => void) | null>(null); const onCloseReadyRef = useRef(onCloseReady); @@ -190,34 +193,32 @@ export const LogViewerWindow: React.FC = ({ } }; - const runtimeConfig = getRuntimeIcon(); - const RuntimeIcon = runtimeConfig.icon; - - const getStatusIndicator = () => { - switch (status) { - case LogStreamStatus.CONNECTING: - return { color: 'text-yellow-500', label: '连接中' }; - case LogStreamStatus.CONNECTED: - return { color: 'text-blue-500', label: '已连接' }; - case LogStreamStatus.STREAMING: - return { color: 'text-green-500', label: '流式传输中' }; - case LogStreamStatus.PAUSED: - return { color: 'text-orange-500', label: '已暂停' }; - case LogStreamStatus.STOPPED: - return { color: 'text-gray-500', label: '已停止' }; - case LogStreamStatus.ERROR: - return { color: 'text-red-500', label: '错误' }; - default: - return { color: 'text-gray-500', label: '未连接' }; - } - }; - - const statusIndicator = getStatusIndicator(); - // 构建动态标题 const buildTitle = useCallback(() => { + const runtimeConfig = getRuntimeIcon(); const RuntimeIcon = runtimeConfig.icon; - const statusColor = statusIndicator.color; + + let statusColor = 'text-gray-500'; + switch (status) { + case LogStreamStatus.CONNECTING: + statusColor = 'text-yellow-500'; + break; + case LogStreamStatus.CONNECTED: + statusColor = 'text-blue-500'; + break; + case LogStreamStatus.STREAMING: + statusColor = 'text-green-500'; + break; + case LogStreamStatus.PAUSED: + statusColor = 'text-orange-500'; + break; + case LogStreamStatus.STOPPED: + statusColor = 'text-gray-500'; + break; + case LogStreamStatus.ERROR: + statusColor = 'text-red-500'; + break; + } return (
@@ -238,14 +239,15 @@ export const LogViewerWindow: React.FC = ({ 日志查看
); - }, [app.applicationName, runtimeConfig, statusIndicator.color]); + }, [app.applicationName, app.runtimeType, status]); // 状态变化时更新标题 useEffect(() => { + console.log('[LogViewerWindow] 更新标题, status:', status, 'updateWindowTitleRef:', !!updateWindowTitleRef.current); if (updateWindowTitleRef.current) { updateWindowTitleRef.current(buildTitle()); } - }, [buildTitle]); + }, [buildTitle, status]); const handleRestart = () => { clearLogs(); @@ -265,145 +267,192 @@ export const LogViewerWindow: React.FC = ({ return (
- {/* 紧凑控制栏 */} -
-
- setLines(Number(e.target.value))} - min={10} - max={1000} - placeholder="行数" - className="h-7 w-16 text-xs" - /> - - {app.runtimeType === 'K8S' && ( - <> - {loadingPods ? ( -
- -
- ) : podNames.length > 0 ? ( - - ) : ( - setPodName(e.target.value)} - placeholder="无可用Pod" - className="h-7 w-40 text-xs" - disabled - /> - )} - - )} - - -
- {/* 启动/恢复/重试按钮 */} - {(status === LogStreamStatus.DISCONNECTED || - status === LogStreamStatus.CONNECTED || - status === LogStreamStatus.ERROR) && ( - - - - - - {status === LogStreamStatus.ERROR ? '重试' : '启动'} - - - )} - - {/* 连接中按钮 */} - {status === LogStreamStatus.CONNECTING && ( - - - - - 连接中 - - )} - - {/* 恢复按钮(暂停状态) */} - {status === LogStreamStatus.PAUSED && ( - - - - - 恢复 - - )} - - {/* 暂停按钮(流式传输中) */} - {status === LogStreamStatus.STREAMING && ( - - - - - 暂停 - - )} - - {/* 停止按钮 */} - {(status === LogStreamStatus.CONNECTING || - status === LogStreamStatus.STREAMING || - status === LogStreamStatus.PAUSED) && ( - - - - - 停止 - - )} - - {/* 清空按钮 */} + {/* 紧凑控制栏 - 收缩时完全隐藏 */} +
+
+
+ + {/* 折叠/展开按钮 */} - 清空 + + {isControlBarCollapsed ? '展开控制栏' : '折叠控制栏'} + -
- + + {/* 控制按钮区域 - 折叠时隐藏 */} + {!isControlBarCollapsed && ( +
+ setLines(Number(e.target.value))} + min={10} + max={1000} + placeholder="行数" + className="h-7 w-16 text-xs" + /> + + {app.runtimeType === 'K8S' && ( + <> + {loadingPods ? ( +
+ +
+ ) : podNames.length > 0 ? ( + + ) : ( + setPodName(e.target.value)} + placeholder="无可用Pod" + className="h-7 w-40 text-xs" + disabled + /> + )} + + )} + +
+ {/* 启动/恢复/重试按钮 */} + {(status === LogStreamStatus.DISCONNECTED || + status === LogStreamStatus.CONNECTED || + status === LogStreamStatus.ERROR) && ( + + + + + + {status === LogStreamStatus.ERROR ? '重试' : '启动'} + + + )} + + {/* 连接中按钮 */} + {status === LogStreamStatus.CONNECTING && ( + + + + + 连接中 + + )} + + {/* 恢复按钮(暂停状态) */} + {status === LogStreamStatus.PAUSED && ( + + + + + 恢复 + + )} + + {/* 暂停按钮(流式传输中) */} + {status === LogStreamStatus.STREAMING && ( + + + + + 暂停 + + )} + + {/* 停止按钮 */} + {(status === LogStreamStatus.CONNECTING || + status === LogStreamStatus.STREAMING || + status === LogStreamStatus.PAUSED) && ( + + + + + 停止 + + )} + + {/* 清空按钮 */} + + + + + 清空 + +
+
+ )} + +
- {/* 日志显示区域 */} -
+ {/* 日志显示区域 - 无padding直接填充 */} +
+ {/* 悬浮展开按钮 - 收缩时显示 */} + {isControlBarCollapsed && ( + + + + + + 展开控制栏 + + + )} + = ({ serverName, logQueryCommand, }) => { - // MOCK数据 - 后续替换为真实API - const mockStatus = { - status: 'running', - pid: 12345, - uptime: '2h 15m', - cpu: { percentage: 15 }, - memory: { used: 256 }, - }; - return (
{/* 运行时类型 */} @@ -28,65 +19,16 @@ export const ServerRuntimeStatus: React.FC = ({ 服务器 - {/* 运行状态 */} -
-
-
- 运行中 -
- -
-
- 进程状态 - Running -
- -
- 进程PID - {mockStatus.pid} -
- -
- 运行时长 - {mockStatus.uptime} -
- -
-
- CPU - {mockStatus.cpu.percentage}% -
-
-
-
-
- -
-
- 内存 - {mockStatus.memory.used}MB -
-
-
-
- - {/* 配置详情 */} -
-
配置详情
-
-
- 服务器 - {serverName || '-'} -
-
- 查询命令 - - {logQueryCommand || '-'} - + {/* 运行状态 - 研发中 */} +
+
+
实例监控功能
+
+
+
+
+
研发中...