import React from 'react'; import { X, Play, Clock, Tag, Users, Star, TrendingUp, FileVideo, MapPin, Zap, AlertCircle, Info } from 'lucide-react'; import { SegmentWithDetails } from '../types/materialSegmentView'; interface MaterialSegmentDetailModalProps { segmentWithDetails: SegmentWithDetails; isOpen: boolean; onClose: () => void; onPlay?: () => void; } /** * MaterialSegment详细信息模态框组件 * 遵循 Tauri 开发规范的组件设计模式 */ export const MaterialSegmentDetailModal: React.FC = ({ segmentWithDetails, isOpen, onClose, onPlay, }) => { const { segment, material_name, material_type, classification, model } = segmentWithDetails; if (!isOpen) return null; // 格式化时长 const formatDuration = (seconds: number) => { const minutes = Math.floor(seconds / 60); const secs = Math.round(seconds % 60); return `${minutes}:${secs.toString().padStart(2, '0')}`; }; // 格式化时间戳 const formatTimestamp = (seconds: number) => { const minutes = Math.floor(seconds / 60); const secs = Math.round(seconds % 60); return `${minutes}:${secs.toString().padStart(2, '0')}`; }; // 格式化日期 const formatDate = (dateString: string) => { return new Date(dateString).toLocaleString('zh-CN', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' }); }; // 获取置信度颜色和描述 const getConfidenceInfo = (confidence: number) => { if (confidence >= 0.9) return { color: 'text-green-600 bg-green-100', desc: '非常高' }; if (confidence >= 0.8) return { color: 'text-green-600 bg-green-100', desc: '高' }; if (confidence >= 0.6) return { color: 'text-yellow-600 bg-yellow-100', desc: '中等' }; if (confidence >= 0.4) return { color: 'text-orange-600 bg-orange-100', desc: '较低' }; return { color: 'text-red-600 bg-red-100', desc: '低' }; }; // 获取质量评分颜色和描述 const getQualityInfo = (score: number) => { if (score >= 0.9) return { color: 'text-green-600', desc: '优秀' }; if (score >= 0.8) return { color: 'text-green-600', desc: '良好' }; if (score >= 0.6) return { color: 'text-yellow-600', desc: '一般' }; if (score >= 0.4) return { color: 'text-orange-600', desc: '较差' }; return { color: 'text-red-600', desc: '差' }; }; return (
{/* 模态框头部 */}

{material_name}

片段 #{segment.segment_index}

{/* 模态框内容 */}
{/* 左侧:基本信息 */}
{/* 片段基本信息 */}

基本信息

片段ID {segment.id.slice(-12)}
素材类型 {material_type}
片段索引 #{segment.segment_index}
创建时间 {formatDate(segment.created_at)}
{/* 时间信息 */}

时间信息

开始时间 {formatTimestamp(segment.start_time)}
结束时间 {formatTimestamp(segment.end_time)}
片段时长 {formatDuration(segment.duration)}
{/* 文件信息 */}

文件信息

文件路径 {segment.file_path}
文件名 {segment.file_path.split('/').pop()}
{/* 播放控制 */}
{/* 右侧:AI分析信息 */}
{/* AI分类信息 */} {classification ? (

AI分类结果

{/* 分类名称和置信度 */}
{classification.category} {classification.product_match && ( 商品匹配 )}
{Math.round(classification.confidence * 100)}% ({getConfidenceInfo(classification.confidence).desc})
{/* 质量评分 */}
质量评分
{Math.round(classification.quality_score * 100)}% ({getQualityInfo(classification.quality_score).desc})
{/* 分类理由 */}
分类理由

{classification.reasoning}

{/* 关键特征 */} {classification.features.length > 0 && (
关键特征
{classification.features.map((feature, index) => ( {feature} ))}
)}
) : (

AI分类状态

该片段尚未进行AI分类

)} {/* 模特信息 */} {model ? (

关联模特

模特ID {model.id.slice(-8)}
模特名称 {model.name}
模特类型 {model.model_type}
) : (

模特关联

该片段尚未关联模特

)}
{/* 模态框底部 */}
); };