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 { invoke } from '@tauri-apps/api/core';
import {
Search,
Download,
RefreshCw,
AlertCircle,
CheckCircle,
Clock,
import {
Search,
Download,
RefreshCw,
AlertCircle,
CheckCircle,
Clock,
XCircle,
Eye,
RotateCcw
} from 'lucide-react';
import { LoadingSpinner } from './LoadingSpinner';
import { ErrorMessage } from './ErrorMessage';
import { CustomSelect } from './CustomSelect';
// 类型定义
interface AiAnalysisLogItem {
@ -67,7 +68,7 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
const [stats, setStats] = useState<AiAnalysisLogStats | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
// 查询参数
const [logType, setLogType] = useState<'records' | 'tasks'>('records');
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 });
setLogs(response.logs);
setTotalCount(response.total_count);
setTotalPages(response.total_pages);
@ -128,8 +129,8 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
if (!projectId) return;
try {
const statsData: AiAnalysisLogStats = await invoke('get_ai_analysis_stats', {
projectId
const statsData: AiAnalysisLogStats = await invoke('get_ai_analysis_stats', {
projectId
});
setStats(statsData);
} catch (err) {
@ -157,20 +158,6 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
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) => {
try {
@ -260,21 +247,19 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
<div className="flex space-x-2">
<button
onClick={() => setLogType('records')}
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${
logType === 'records'
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${logType === 'records'
? 'bg-blue-100 text-blue-700'
: 'text-gray-600 hover:text-gray-900 hover:bg-gray-100'
}`}
}`}
>
</button>
<button
onClick={() => setLogType('tasks')}
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${
logType === 'tasks'
className={`px-4 py-2 text-sm font-medium rounded-lg transition-colors ${logType === 'tasks'
? 'bg-blue-100 text-blue-700'
: 'text-gray-600 hover:text-gray-900 hover:bg-gray-100'
}`}
}`}
>
</button>
@ -296,21 +281,9 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
{/* 状态过滤 */}
{filterOptions && (
<select
value={statusFilter}
onChange={(e) => setStatusFilter(e.target.value)}
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>
<CustomSelect options={logType === 'records'
? filterOptions.record_statuses
: filterOptions.task_statuses} value={statusFilter} onChange={e => setStatusFilter(e)} />
)}
<button
@ -327,17 +300,6 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
<RefreshCw className="w-4 h-4" />
</button>
</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>
@ -386,7 +348,7 @@ export const AiAnalysisLogViewer: React.FC<AiAnalysisLogViewerProps> = ({ projec
</div>
</div>
</div>
{/* 操作按钮 */}
<div className="flex items-center space-x-2 ml-4">
{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" />
</button>
)}
<button
className="p-1 text-gray-600 hover:text-gray-800"
title="查看详情"
>
<Eye className="w-4 h-4" />
</button>
</div>
</div>
</div>