/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React, { useState, useEffect } from 'react'; import { Card, Typography, Tabs, TabPane, Button, Dropdown, } from '@douyinfe/semi-ui'; import { Code, Zap, Clock, X, Eye, Send } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import CodeViewer from './CodeViewer'; const DebugPanel = ({ debugData, activeDebugTab, onActiveDebugTabChange, styleState, onCloseDebugPanel, customRequestMode, }) => { const { t } = useTranslation(); const [activeKey, setActiveKey] = useState(activeDebugTab); useEffect(() => { setActiveKey(activeDebugTab); }, [activeDebugTab]); const handleTabChange = (key) => { setActiveKey(key); onActiveDebugTabChange(key); }; const renderArrow = (items, pos, handleArrowClick, defaultNode) => { const style = { width: 32, height: 32, margin: '0 12px', display: 'flex', justifyContent: 'center', alignItems: 'center', borderRadius: '100%', background: 'rgba(var(--semi-grey-1), 1)', color: 'var(--semi-color-text)', cursor: 'pointer', }; return ( {items.map((item) => { return ( handleTabChange(item.itemKey)} > {item.tab} ); })} } > {pos === 'start' ? (
) : (
)}
); }; return (
{t('调试信息')}
{styleState.isMobile && onCloseDebugPanel && (
{t('预览请求体')} {customRequestMode && ( 自定义 )}
} itemKey='preview' > {t('实际请求体')} } itemKey='request' > {t('响应')} } itemKey='response' >
{(debugData.timestamp || debugData.previewTimestamp) && (
{activeKey === 'preview' && debugData.previewTimestamp ? `${t('预览更新')}: ${new Date(debugData.previewTimestamp).toLocaleString()}` : debugData.timestamp ? `${t('最后请求')}: ${new Date(debugData.timestamp).toLocaleString()}` : ''}
)}
); }; export default DebugPanel;