import React, { useRef, useEffect } from 'react'; import { Table, Tag, Button, Tooltip } from 'antd'; import { ClearOutlined, CloseOutlined, CaretRightOutlined, BugOutlined } from '@ant-design/icons'; import { useStore } from '../store'; import { blurToFilter, normalizeBlurForPlatform, normalizeOpacityForPlatform } from '../utils/appearance'; interface LogPanelProps { height: number; onClose: () => void; onResizeStart: (e: React.MouseEvent) => void; } const LogPanel: React.FC = ({ height, onClose, onResizeStart }) => { const sqlLogs = useStore(state => state.sqlLogs); const clearSqlLogs = useStore(state => state.clearSqlLogs); const theme = useStore(state => state.theme); const appearance = useStore(state => state.appearance); const darkMode = theme === 'dark'; const opacity = normalizeOpacityForPlatform(appearance.opacity); const blur = normalizeBlurForPlatform(appearance.blur); // Background Helper const getBg = (darkHex: string) => { if (!darkMode) return `rgba(255, 255, 255, ${opacity})`; const hex = darkHex.replace('#', ''); const r = parseInt(hex.substring(0, 2), 16); const g = parseInt(hex.substring(2, 4), 16); const b = parseInt(hex.substring(4, 6), 16); return `rgba(${r}, ${g}, ${b}, ${opacity})`; }; const bgMain = getBg('#1f1f1f'); const bgToolbar = getBg('#2a2a2a'); const blurFilter = blurToFilter(blur); const columns = [ { title: 'Time', dataIndex: 'timestamp', width: 80, render: (ts: number) => {new Date(ts).toLocaleTimeString()} }, { title: 'Status', dataIndex: 'status', width: 70, render: (status: string) => ( {status === 'success' ? 'OK' : 'ERR'} ) }, { title: 'Duration', dataIndex: 'duration', width: 70, render: (d: number) => 1000 ? 'orange' : 'inherit', fontSize: '12px' }}>{d}ms }, { title: 'SQL / Message', dataIndex: 'sql', render: (text: string, record: any) => (
{text}
{record.message &&
{record.message}
} {record.affectedRows !== undefined &&
Affected: {record.affectedRows}
}
) } ]; return (
{/* Resize Handle */}
{/* Toolbar */}
SQL 执行日志
{/* List */}
); }; export default LogPanel;