fix: 智能视频分类 测试完成

This commit is contained in:
imeepos 2025-07-14 16:51:33 +08:00
parent c3c0bb8c08
commit 708075f17e
1 changed files with 20 additions and 64 deletions

View File

@ -1,18 +1,19 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { invoke } from '@tauri-apps/api/core'; import { invoke } from '@tauri-apps/api/core';
import { import {
Search, Search,
Download, Download,
RefreshCw, RefreshCw,
AlertCircle, AlertCircle,
CheckCircle, CheckCircle,
Clock, Clock,
XCircle, XCircle,
Eye, Eye,
RotateCcw RotateCcw
} from 'lucide-react'; } from 'lucide-react';
import { LoadingSpinner } from './LoadingSpinner'; import { LoadingSpinner } from './LoadingSpinner';
import { ErrorMessage } from './ErrorMessage'; import { ErrorMessage } from './ErrorMessage';
import { CustomSelect } from './CustomSelect';
// 类型定义 // 类型定义
interface AiAnalysisLogItem { interface AiAnalysisLogItem {
@ -67,7 +68,7 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
const [stats, setStats] = useState<AiAnalysisLogStats | null>(null); const [stats, setStats] = useState<AiAnalysisLogStats | null>(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
// 查询参数 // 查询参数
const [logType, setLogType] = useState<'records' | 'tasks'>('records'); const [logType, setLogType] = useState<'records' | 'tasks'>('records');
const [statusFilter, setStatusFilter] = useState<string>(''); const [statusFilter, setStatusFilter] = useState<string>('');
@ -112,7 +113,7 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
}; };
const response: AiAnalysisLogResponse = await invoke('get_ai_analysis_logs', { query }); const response: AiAnalysisLogResponse = await invoke('get_ai_analysis_logs', { query });
setLogs(response.logs); setLogs(response.logs);
setTotalCount(response.total_count); setTotalCount(response.total_count);
setTotalPages(response.total_pages); setTotalPages(response.total_pages);
@ -128,8 +129,8 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
if (!projectId) return; if (!projectId) return;
try { try {
const statsData: AiAnalysisLogStats = await invoke('get_ai_analysis_stats', { const statsData: AiAnalysisLogStats = await invoke('get_ai_analysis_stats', {
projectId projectId
}); });
setStats(statsData); setStats(statsData);
} catch (err) { } catch (err) {
@ -157,20 +158,6 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
loadLogs(); loadLogs();
}; };
// 导出日志
const handleExport = async (format: 'csv' | 'json') => {
try {
const result = await invoke('export_ai_analysis_logs', {
projectId,
format,
});
console.log('导出结果:', result);
// TODO: 处理导出结果,可能需要保存文件
} catch (err) {
console.error('导出失败:', err);
}
};
// 重试失败任务 // 重试失败任务
const handleRetryTask = async (taskId: string) => { const handleRetryTask = async (taskId: string) => {
try { try {
@ -260,21 +247,19 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
<div className="flex space-x-2"> <div className="flex space-x-2">
<button <button
onClick={() => setLogType('records')} onClick={() => setLogType('records')}
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${ className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${logType === 'records'
logType === 'records'
? 'bg-blue-100 text-blue-700' ? 'bg-blue-100 text-blue-700'
: 'text-gray-600 hover:text-gray-900 hover:bg-gray-100' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-100'
}`} }`}
> >
</button> </button>
<button <button
onClick={() => setLogType('tasks')} onClick={() => setLogType('tasks')}
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${ className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${logType === 'tasks'
logType === 'tasks'
? 'bg-blue-100 text-blue-700' ? 'bg-blue-100 text-blue-700'
: 'text-gray-600 hover:text-gray-900 hover:bg-gray-100' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-100'
}`} }`}
> >
</button> </button>
@ -296,21 +281,9 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
{/* 状态过滤 */} {/* 状态过滤 */}
{filterOptions && ( {filterOptions && (
<select <CustomSelect options={logType === 'records'
value={statusFilter} ? filterOptions.record_statuses
onChange={(e) => setStatusFilter(e.target.value)} : filterOptions.task_statuses} value={statusFilter} onChange={e => setStatusFilter(e)} />
className="px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
>
<option value=""></option>
{(logType === 'records'
? filterOptions.record_statuses
: filterOptions.task_statuses
).map((status: any) => (
<option key={status.value} value={status.value}>
{status.label}
</option>
))}
</select>
)} )}
<button <button
@ -327,17 +300,6 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
<RefreshCw className="w-4 h-4" /> <RefreshCw className="w-4 h-4" />
</button> </button>
</div> </div>
{/* 操作按钮 */}
<div className="flex gap-2">
<button
onClick={() => handleExport('csv')}
className="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"
title="导出CSV"
>
<Download className="w-4 h-4" />
</button>
</div>
</div> </div>
</div> </div>
@ -386,7 +348,7 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
</div> </div>
</div> </div>
</div> </div>
{/* 操作按钮 */} {/* 操作按钮 */}
<div className="flex items-center space-x-2 ml-4"> <div className="flex items-center space-x-2 ml-4">
{log.log_type === 'task' && log.status.includes('Failed') && ( {log.log_type === 'task' && log.status.includes('Failed') && (
@ -398,12 +360,6 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
<RotateCcw className="w-4 h-4" /> <RotateCcw className="w-4 h-4" />
</button> </button>
)} )}
<button
className="p-1 text-gray-600 hover:text-gray-800"
title="查看详情"
>
<Eye className="w-4 h-4" />
</button>
</div> </div>
</div> </div>
</div> </div>