import { Button, Input, Modal, Tag } from '@/components/ui'; import { formatDateTime } from '@/utils/dateTime'; import { connectionStatusLabelMap, formatLogDetail } from './channelModel'; import type { ChannelLogState } from './channelTypes'; export function ChannelLogModal({ logState, keyword, onKeywordChange, onClose, }: { logState: ChannelLogState; keyword: string; onKeywordChange: (keyword: string) => void; onClose: () => void; }) { const normalizedKeyword = keyword.trim().toLowerCase(); const filteredLogs = (logState.data?.logs ?? []).filter((log) => !normalizedKeyword || `${log.event} ${log.resourceId ?? ''} ${formatLogDetail(log.detail)}`.toLowerCase().includes(normalizedKeyword), ); return ( 关闭} onClose={onClose} open size="xl" title={

连接日志

{logState.channel.name}

} >
{logState.data ? (
{logState.data.connectionStates.map((connection) => (
连接 ID {connection.connectionId}
{connectionStatusLabelMap[connection.status] ?? connection.status}
当前 / 期望 {connection.currentConnections} / {connection.desiredConnections}
最近心跳 {formatDateTime(connection.lastHeartbeatAt)}
自动重连 {connection.reconnectCount} 次 / {formatDateTime(connection.nextReconnectAt)}
{connection.lastError ?

{connection.lastError}

: null}
))} {logState.data.connectionStates.length === 0 ?

暂无连接状态回写

: null}
) : null} onKeywordChange(event.target.value)} placeholder="事件、资源或详情关键词" value={keyword} />
{filteredLogs.map((log) => (
{log.event} {formatDateTime(log.time)}
{log.resourceId}
{formatLogDetail(log.detail)}
))} {logState.data && filteredLogs.length === 0 ?

未找到匹配的连接日志

: null} {!logState.data ?

正在加载连接日志...

: null}
); }