算法分析页面接入

This commit is contained in:
mmc
2026-05-21 12:55:07 +08:00
parent 0aad6659dd
commit bdaa0c352a
4 changed files with 783 additions and 1 deletions

2
env.js
View File

@@ -17,7 +17,7 @@ const envConfig = {
// baseURL: 'http://192.168.2.56:8081',
baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
//baseURL: 'https://serviceri.satabot.com',
WS_URL: 'wss://ri.satabot.com/ws/'
WS_URL: 'ws://1.95.137.212:59017/ws/'
},
};

56
src/api/aiAnalysis.ts Normal file
View File

@@ -0,0 +1,56 @@
import request from '../request';
// 检测服务 Base URL
const DETECT_BASE = 'http://50.50.50.117:10101';
// 热成像分割服务 Base URL
const SEGMENT_BASE = 'http://50.50.50.117:10102';
/**
* 获取检测模型列表
*/
export function getDetectModels() {
return fetch(`${DETECT_BASE}/api/v1/detect/models`).then(res => res.json());
}
/**
* 提交检测任务
* @param formData 包含 files, inputType, modelAlias, conf, iou, imgsz, device, maxDet, vidStride
*/
export function submitDetectJob(formData: FormData) {
return fetch(`${DETECT_BASE}/api/v1/detect/jobs`, {
method: 'POST',
body: formData
}).then(res => res.json());
}
/**
* 查询检测任务状态
*/
export function getDetectJobStatus(jobId: string) {
return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}`).then(res => res.json());
}
/**
* 查询检测结果
*/
export function getDetectJobResult(jobId: string) {
return fetch(`${DETECT_BASE}/api/v1/detect/jobs/${jobId}/result`).then(res => res.json());
}
/**
* 提交热成像分析 (同步返回结果)
* @param formData 包含 thermal_file, array_mask_file, panel_geojson_file, threshold_c, min_area_px, max_regions, open_k, close_k, shrink_in, include_panel_segments
*/
export function submitSegmentationAnalyze(formData: FormData) {
return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyze`, {
method: 'POST',
body: formData
}).then(res => res.json());
}
/**
* 获取热成像分析报告历史
*/
export function getSegmentationHistory() {
return fetch(`${SEGMENT_BASE}/api/v1/segmentation/analyses/report`).then(res => res.json());
}

724
src/pages/Agri.jsx Normal file
View File

@@ -0,0 +1,724 @@
import React, { useState, useEffect, useRef } from 'react';
import {
Row, Col, Card, Button, Tag, Typography, Space, Statistic, message,
Divider, Input, Select, Switch, Upload, Progress, Tabs, Empty,
InputNumber, Radio, Spin
} from 'antd';
import {
ReloadOutlined, InfoCircleOutlined, ThunderboltOutlined,
AppstoreOutlined, CheckCircleOutlined, CloudOutlined,
AimOutlined, FireOutlined, InboxOutlined,
PlayCircleOutlined, FileTextOutlined, HistoryOutlined,
SearchOutlined, SettingOutlined, FullscreenOutlined,
UploadOutlined, LoadingOutlined, CheckOutlined,
SyncOutlined
} from '@ant-design/icons';
import {
getDetectModels,
submitDetectJob,
getDetectJobStatus,
getDetectJobResult,
submitSegmentationAnalyze
} from '../api/aiAnalysis';
import utils from '../lib/utils';
const { Title, Text } = Typography;
const { Dragger } = Upload;
const { Option } = Select;
// 算法列表定义
const algorithmList = [
{
id: 'detect',
name: '目标检测',
alias: 'waterway-trt',
desc: '图片/视频检测,创建任务后轮询结果。',
icon: <AimOutlined />,
status: '运行中'
},
{
id: 'segmentation',
name: '热成像分割',
alias: 'v1.0.0',
desc: '热成像热点、面板分区和温度统计。',
icon: <FireOutlined />,
status: '运行中'
}
];
export default function Agri() {
const [activeAlgo, setActiveAlgo] = useState('detect');
const [models, setModels] = useState([]);
const [loadingModels, setLoadingModels] = useState(false);
const [history, setHistory] = useState([]);
// 检测任务状态
const [detectForm, setDetectForm] = useState({
modelAlias: '',
inputType: 'image',
conf: 0.25,
iou: 0.45,
imgsz: 1280,
device: 'auto',
maxDet: 300,
vidStride: 1,
half: false,
speedPreset: 'speed'
});
const [detectFiles, setDetectFiles] = useState([]);
const [detectJobId, setDetectJobId] = useState(null);
const [detectStatus, setDetectStatus] = useState(null);
const [detectResult, setDetectResult] = useState(null);
const [polling, setPolling] = useState(false);
// 分割任务状态
const [segForm, setSegForm] = useState({
threshold_c: 48,
min_area_px: 25,
max_regions: 120,
include_panel_segments: true
});
const [thermalFile, setThermalFile] = useState(null);
const [maskFile, setMaskFile] = useState(null);
const [geojsonFile, setGeojsonFile] = useState(null);
const [segResult, setSegResult] = useState(null);
const [segLoading, setSegLoading] = useState(false);
const pollTimer = useRef(null);
// 初始化:加载模型列表
useEffect(() => {
fetchModels();
}, []);
const fetchModels = async () => {
setLoadingModels(true);
try {
const res = await getDetectModels();
if (res && res.list) {
setModels(res.list);
const defaultModel = res.list.find(m => m.default) || res.list[0];
if (defaultModel) {
setDetectForm(prev => ({ ...prev, modelAlias: defaultModel.alias }));
}
}
} catch (err) {
utils.message.error('获取模型列表失败');
} finally {
setLoadingModels(false);
}
};
// --- 目标检测逻辑 ---
const handleSubmitDetect = async () => {
if (detectFiles.length === 0) {
utils.message.warning('请先上传图片或视频');
return;
}
const formData = new FormData();
detectFiles.forEach(file => {
formData.append('files', file.originFileObj);
});
formData.append('inputType', detectForm.inputType);
formData.append('modelAlias', detectForm.modelAlias);
formData.append('conf', detectForm.conf.toString());
formData.append('iou', detectForm.iou.toString());
formData.append('imgsz', detectForm.imgsz.toString());
formData.append('device', detectForm.device);
formData.append('maxDet', detectForm.maxDet.toString());
formData.append('vidStride', detectForm.vidStride.toString());
formData.append('half', detectForm.half.toString());
try {
setDetectStatus('submitting');
const res = await submitDetectJob(formData);
if (res && res.jobId) {
setDetectJobId(res.jobId);
setDetectStatus('queued');
setPolling(true);
startPolling(res.jobId);
// 添加到历史
addToHistory('detect', res.jobId);
}
} catch (err) {
utils.message.error('提交任务失败');
setDetectStatus(null);
}
};
const startPolling = (jobId) => {
if (pollTimer.current) clearInterval(pollTimer.current);
pollTimer.current = setInterval(async () => {
try {
const statusRes = await getDetectJobStatus(jobId);
setDetectStatus(statusRes.status);
if (statusRes.status === 'succeeded') {
clearInterval(pollTimer.current);
setPolling(false);
const resultRes = await getDetectJobResult(jobId);
setDetectResult(resultRes);
utils.message.success('任务执行成功');
} else if (['failed', 'cancelled'].includes(statusRes.status)) {
clearInterval(pollTimer.current);
setPolling(false);
utils.message.error(`任务执行${statusRes.status === 'failed' ? '失败' : '被取消'}`);
}
} catch (err) {
console.error('轮询失败', err);
}
}, 2000);
};
// --- 热成像分割逻辑 ---
const handleSubmitSeg = async () => {
if (!thermalFile) {
utils.message.warning('请先上传热成像文件');
return;
}
const formData = new FormData();
formData.append('thermal_file', thermalFile.originFileObj);
if (maskFile) formData.append('array_mask_file', maskFile.originFileObj);
if (geojsonFile) formData.append('panel_geojson_file', geojsonFile.originFileObj);
formData.append('threshold_c', segForm.threshold_c.toString());
formData.append('min_area_px', segForm.min_area_px.toString());
formData.append('max_regions', segForm.max_regions.toString());
formData.append('include_panel_segments', segForm.include_panel_segments.toString());
setSegLoading(true);
try {
const res = await submitSegmentationAnalyze(formData);
setSegResult(res);
utils.message.success('热成像分析完成');
addToHistory('segmentation', res.analysisId || 'seg-' + Date.now());
} catch (err) {
utils.message.error('热成像分析失败');
} finally {
setSegLoading(false);
}
};
const addToHistory = (type, id) => {
const newItem = {
id,
type,
time: new Date().toLocaleString(),
name: type === 'detect' ? '目标检测任务' : '热成像分割分析'
};
setHistory(prev => [newItem, ...prev]);
};
// 渲染统计卡片
const renderStats = () => (
<Row gutter={[8, 8]} style={{ marginBottom: 12 }}>
<Col span={6}>
<Card bordered={false} bodyStyle={{ padding: '12px' }}>
<Statistic
title={<Text type="secondary" style={{ fontSize: 12 }}>算法数量</Text>}
value={2}
suffix={<Text type="secondary" style={{ fontSize: 11 }}>检测 + 分割</Text>}
valueStyle={{ color: '#1677ff', fontWeight: 800, fontSize: 20 }}
/>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} bodyStyle={{ padding: '12px' }}>
<Statistic
title={<Text type="secondary" style={{ fontSize: 12 }}>在线服务</Text>}
value={2}
suffix={<Text type="secondary" style={{ fontSize: 11 }}>health 实时检查</Text>}
valueStyle={{ color: '#1677ff', fontWeight: 800, fontSize: 20 }}
/>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} bodyStyle={{ padding: '12px' }}>
<Statistic
title={<Text type="secondary" style={{ fontSize: 12 }}>模型数量</Text>}
value={models.length || 3}
suffix={<Text type="secondary" style={{ fontSize: 11 }}>检测模型 registry</Text>}
valueStyle={{ color: '#1677ff', fontWeight: 800, fontSize: 20 }}
/>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} bodyStyle={{ padding: '12px' }}>
<Statistic
title={<Text type="secondary" style={{ fontSize: 12 }}>历史记录</Text>}
value={history.length}
suffix={<Text type="secondary" style={{ fontSize: 11 }}>本页联调记录</Text>}
valueStyle={{ color: '#1677ff', fontWeight: 800, fontSize: 20 }}
/>
</Card>
</Col>
</Row>
);
// 渲染检测工作区
const renderDetectWorkspace = () => (
<div style={{ padding: '0 8px' }}>
<div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 15 }}>检测模型</Text>
<Select
style={{ width: '100%', marginTop: 8 }}
value={detectForm.modelAlias}
onChange={val => setDetectForm(prev => ({ ...prev, modelAlias: val }))}
loading={loadingModels}
>
{models.map(m => (
<Option key={m.alias} value={m.alias}>{m.alias} {m.default ? '(默认)' : ''}</Option>
))}
</Select>
</div>
<Row gutter={[16, 16]}>
<Col span={12}>
<Text strong style={{ fontSize: 13, display: 'block', marginBottom: 8 }}>输入类型</Text>
<Radio.Group
value={detectForm.inputType}
onChange={e => setDetectForm(prev => ({ ...prev, inputType: e.target.value }))}
buttonStyle="solid"
size="small"
>
<Radio.Button value="image">图片</Radio.Button>
<Radio.Button value="video">视频</Radio.Button>
</Radio.Group>
</Col>
<Col span={12}>
<Text strong style={{ fontSize: 13, display: 'block', marginBottom: 8 }}>推理预设</Text>
<Radio.Group
value={detectForm.speedPreset}
onChange={e => setDetectForm(prev => ({ ...prev, speedPreset: e.target.value }))}
size="small"
>
<Radio.Button value="quality">质量</Radio.Button>
<Radio.Button value="speed">速度</Radio.Button>
</Radio.Group>
</Col>
</Row>
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>conf</Text>
<InputNumber
size="small"
min={0} max={1} step={0.01}
value={detectForm.conf}
onChange={val => setDetectForm(prev => ({ ...prev, conf: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>iou</Text>
<InputNumber
size="small"
min={0} max={1} step={0.01}
value={detectForm.iou}
onChange={val => setDetectForm(prev => ({ ...prev, iou: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>imgsz</Text>
<InputNumber
size="small"
value={detectForm.imgsz}
onChange={val => setDetectForm(prev => ({ ...prev, imgsz: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>device</Text>
<Select
size="small"
value={detectForm.device}
onChange={val => setDetectForm(prev => ({ ...prev, device: val }))}
style={{ width: '100%' }}
>
<Option value="auto">auto</Option>
<Option value="cpu">cpu</Option>
<Option value="cuda:0">cuda:0</Option>
</Select>
</Col>
</Row>
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>max_det</Text>
<InputNumber
size="small"
value={detectForm.maxDet}
onChange={val => setDetectForm(prev => ({ ...prev, maxDet: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>vid_stride</Text>
<InputNumber
size="small"
value={detectForm.vidStride}
onChange={val => setDetectForm(prev => ({ ...prev, vidStride: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>half</Text>
<Switch
size="small"
checked={detectForm.half}
onChange={val => setDetectForm(prev => ({ ...prev, half: val }))}
/>
</Col>
</Row>
<div style={{ marginTop: 24 }}>
<Dragger
multiple={detectForm.inputType === 'image'}
fileList={detectFiles}
onChange={info => setDetectFiles(info.fileList)}
beforeUpload={() => false}
style={{ background: '#fafafa', borderRadius: 8 }}
>
<p className="ant-upload-drag-icon">
<InboxOutlined style={{ color: '#1677ff' }} />
</p>
<p className="ant-upload-text">拖拽文件到此处,或点击选择</p>
<p className="ant-upload-hint">支持 jpg/png/webp/mp4 等格式</p>
</Dragger>
</div>
<Space style={{ marginTop: 24 }}>
<Button
type="primary"
icon={polling ? <LoadingOutlined /> : <CheckCircleOutlined />}
onClick={handleSubmitDetect}
disabled={polling}
>
{polling ? '任务处理中...' : '提交检测任务'}
</Button>
<Button icon={<PlayCircleOutlined />}>调用服务器样例</Button>
<Button icon={<SyncOutlined />} onClick={fetchModels}>刷新模型</Button>
</Space>
</div>
);
// 渲染分割工作区
const renderSegWorkspace = () => (
<div style={{ padding: '0 8px' }}>
<Row gutter={[16, 16]}>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>threshold_c</Text>
<InputNumber
size="small"
value={segForm.threshold_c}
onChange={val => setSegForm(prev => ({ ...prev, threshold_c: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>min_area_px</Text>
<InputNumber
size="small"
value={segForm.min_area_px}
onChange={val => setSegForm(prev => ({ ...prev, min_area_px: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>max_regions</Text>
<InputNumber
size="small"
value={segForm.max_regions}
onChange={val => setSegForm(prev => ({ ...prev, max_regions: val }))}
style={{ width: '100%' }}
/>
</Col>
<Col span={6}>
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>include_panel_segments</Text>
<Switch
size="small"
checked={segForm.include_panel_segments}
onChange={val => setSegForm(prev => ({ ...prev, include_panel_segments: val }))}
/>
</Col>
</Row>
<div style={{ marginTop: 24 }}>
<Text strong style={{ fontSize: 13, display: 'block', marginBottom: 8 }}>热成像文件 thermal_file</Text>
<Dragger
fileList={thermalFile ? [thermalFile] : []}
onChange={info => setThermalFile(info.fileList[0])}
beforeUpload={() => false}
maxCount={1}
style={{ background: '#fafafa', borderRadius: 8, height: 120 }}
>
<p className="ant-upload-drag-icon" style={{ fontSize: 24 }}>
<CloudOutlined style={{ color: '#1677ff' }} />
</p>
<p style={{ fontSize: 12 }}>上传 TIFF / PNG / JPG 热成像文件</p>
</Dragger>
</div>
<Space style={{ marginTop: 16 }}>
<Upload
fileList={maskFile ? [maskFile] : []}
onChange={info => setMaskFile(info.fileList[0])}
beforeUpload={() => false}
maxCount={1}
>
<Button size="small">阵列 mask</Button>
</Upload>
<Upload
fileList={geojsonFile ? [geojsonFile] : []}
onChange={info => setGeojsonFile(info.fileList[0])}
beforeUpload={() => false}
maxCount={1}
>
<Button size="small">面板 GeoJSON</Button>
</Upload>
</Space>
<Space style={{ marginTop: 24 }}>
<Button
type="primary"
icon={segLoading ? <LoadingOutlined /> : <CheckOutlined />}
onClick={handleSubmitSeg}
loading={segLoading}
>
提交热成像分析
</Button>
<Button icon={<PlayCircleOutlined />}>调用服务器样例</Button>
<Button icon={<HistoryOutlined />}>读取服务器历史</Button>
</Space>
</div>
);
// 渲染结果展示
const renderResults = () => {
const result = activeAlgo === 'detect' ? detectResult : segResult;
const inputFiles = activeAlgo === 'detect' ? detectFiles : (thermalFile ? [thermalFile] : []);
return (
<Card
title={<Text strong style={{ fontSize: 14 }}>结果展示</Text>}
bordered={false}
style={{ marginTop: 12, borderRadius: 8 }}
bodyStyle={{ padding: '12px' }}
>
<Text type="secondary" style={{ fontSize: 11, display: 'block', marginBottom: 12 }}>
原始预览、结果图与完整 JSON 同屏查看
</Text>
{activeAlgo === 'segmentation' && segResult && (
<div style={{ marginBottom: 16 }}>
<Row gutter={8}>
<Col span={6}>
<Card size="small" bodyStyle={{ padding: 8 }}>
<Statistic title="热点数量" value={segResult.summary?.panel_hotspot_count || 0} valueStyle={{ fontSize: 16 }} />
</Card>
</Col>
<Col span={6}>
<Card size="small" bodyStyle={{ padding: 8 }}>
<Statistic title="面板区域" value={segResult.summary?.panel_polygon_count || 0} valueStyle={{ fontSize: 16 }} />
</Card>
</Col>
<Col span={6}>
<Card size="small" bodyStyle={{ padding: 8 }}>
<Statistic title="最高温度" value="-" valueStyle={{ fontSize: 16 }} />
</Card>
</Col>
<Col span={6}>
<Card size="small" bodyStyle={{ padding: 8 }}>
<Statistic title="分析编号" value={segResult.analysisId?.substring(0, 8) || '-'} valueStyle={{ fontSize: 16 }} />
</Card>
</Col>
</Row>
</div>
)}
<Row gutter={12}>
<Col span={16}>
<div style={{ background: '#001529', borderRadius: 8, height: 450, display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden', position: 'relative' }}>
{result ? (
activeAlgo === 'detect' ? (
detectForm.inputType === 'image' ? (
<img
src={result.files?.[0]?.annotatedUrl}
style={{ maxWidth: '100%', maxHeight: '100%' }}
alt="result"
/>
) : (
<video
src={result.files?.[0]?.annotatedUrl}
controls
style={{ maxWidth: '100%', maxHeight: '100%' }}
/>
)
) : (
<img
src={result.image?.overlay_image_url}
style={{ maxWidth: '100%', maxHeight: '100%' }}
alt="result"
/>
)
) : (
<div style={{ textAlign: 'center', color: '#fff' }}>
<Empty description={<span style={{ color: '#fff' }}>等待上传或调用服务器样例后显示结果图</span>} image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div>
)}
</div>
<div style={{ textAlign: 'center', marginTop: 8 }}><Text strong style={{ fontSize: 13 }}>分析结果视图</Text></div>
</Col>
<Col span={8}>
<div style={{ background: '#f5f5f5', borderRadius: 8, height: 450, padding: 8, display: 'flex', flexDirection: 'column' }}>
<div style={{ flex: 1, overflowY: 'auto' }}>
<Text strong style={{ fontSize: 13, display: 'block', marginBottom: 8 }}>点位详情</Text>
{activeAlgo === 'segmentation' && segResult ? (
<div>
<div style={{ padding: '8px', background: '#fff', borderRadius: 4, marginBottom: 8 }}>
<div style={{ fontSize: 12, color: '#999' }}>热点 GPS 样例</div>
<div style={{ fontSize: 12 }}>{segResult.hotspots?.[0]?.gps?.text || '暂无 GPS 信息'}</div>
</div>
<Divider style={{ margin: '8px 0' }} />
<Text strong style={{ fontSize: 12 }}>热点/面板列表</Text>
<div style={{ marginTop: 8 }}>
{segResult.panel_overview?.slice(0, 10).map((p, i) => (
<div key={i} style={{ fontSize: 11, padding: '4px 0', borderBottom: '1px solid #eee' }}>
面板 #{i + 1}: {p.gps_text}
</div>
))}
</div>
</div>
) : (
<Empty description="请选择热点或面板" image={Empty.PRESENTED_IMAGE_SIMPLE} />
)}
</div>
<Divider style={{ margin: '8px 0' }} />
<div style={{ flex: 1, overflowY: 'auto' }}>
<Text strong style={{ fontSize: 13, display: 'block', marginBottom: 8 }}>结果 JSON</Text>
{result ? (
<pre style={{ fontSize: 10, margin: 0 }}>{JSON.stringify(result, null, 2)}</pre>
) : <Empty description="暂无结果" image={Empty.PRESENTED_IMAGE_SIMPLE} />}
</div>
</div>
<div style={{ textAlign: 'center', marginTop: 8 }}><Text strong style={{ fontSize: 13 }}>详细数据</Text></div>
</Col>
</Row>
</Card>
);
};
return (
<div style={{ padding: '8px', background: '#f4f7f9', minHeight: '100vh' }}>
{renderStats()}
<Row gutter={12}>
{/* 左侧:算法列表 */}
<Col span={5}>
<Card
title={<Text strong style={{ fontSize: 14 }}>算法列表</Text>}
bordered={false}
bodyStyle={{ padding: '8px' }}
style={{ borderRadius: 8, height: '100%' }}
extra={<Text type="secondary" style={{ fontSize: 11 }}>已接入 2 套</Text>}
>
{algorithmList.map(algo => (
<div
key={algo.id}
onClick={() => setActiveAlgo(algo.id)}
style={{
padding: '12px',
borderRadius: 8,
cursor: 'pointer',
marginBottom: 8,
border: `1px solid ${activeAlgo === algo.id ? '#1677ff' : '#f0f0f0'}`,
background: activeAlgo === algo.id ? '#e6f4ff' : '#fff',
transition: 'all 0.3s'
}}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4 }}>
<Space>
<span style={{ color: activeAlgo === algo.id ? '#1677ff' : '#666', fontSize: 16 }}>{algo.icon}</span>
<Text strong style={{ color: activeAlgo === algo.id ? '#1677ff' : '#333' }}>{algo.name}</Text>
</Space>
<Tag color="blue" size="small" style={{ margin: 0, fontSize: 10 }}>{algo.status}</Tag>
</div>
<div style={{ fontSize: 11, color: '#999', marginBottom: 4 }}>{algo.alias}</div>
<div style={{ fontSize: 11, color: '#999' }}>{algo.desc}</div>
</div>
))}
</Card>
</Col>
{/* 中间:工作区 */}
<Col span={14}>
<Card
title={
<Space>
<Text strong style={{ fontSize: 14 }}>
{activeAlgo === 'detect' ? '检测任务工作区' : '热成像分割工作区'}
</Text>
<Tag color="blue" size="small">
{activeAlgo === 'detect' ? '异步任务' : '同步分析'}
</Tag>
</Space>
}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ borderRadius: 8 }}
>
<Text type="secondary" style={{ fontSize: 11, display: 'block', marginBottom: 16 }}>
{activeAlgo === 'detect'
? '提交图片或视频检测任务,轮询状态并查看检测结果图。'
: '上传热成像图与可选 mask/geojson,同步返回叠加图和热点 JSON。'}
</Text>
{activeAlgo === 'detect' ? renderDetectWorkspace() : renderSegWorkspace()}
</Card>
{renderResults()}
</Col>
{/* 右侧:历史记录 */}
<Col span={5}>
<Card
title={<Text strong style={{ fontSize: 14 }}>历史分析记录</Text>}
bordered={false}
bodyStyle={{ padding: '8px' }}
style={{ borderRadius: 8, height: '100%' }}
extra={<Text type="secondary" style={{ fontSize: 11 }}>{history.length} 条</Text>}
>
{history.length === 0 ? (
<Empty description="暂无历史" image={Empty.PRESENTED_IMAGE_SIMPLE} />
) : (
history.map(item => (
<div
key={item.id}
style={{
padding: '10px',
borderRadius: 6,
border: '1px solid #f0f0f0',
marginBottom: 8,
fontSize: 12
}}
>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
<Text strong>{item.name}</Text>
<Tag size="small" color={item.type === 'detect' ? 'cyan' : 'purple'}>
{item.type === 'detect' ? '检测' : '分割'}
</Tag>
</div>
<div style={{ color: '#999', fontSize: 11, marginBottom: 4 }}>ID: {item.id.substring(0, 12)}...</div>
<div style={{ color: '#ccc', fontSize: 10 }}>{item.time}</div>
</div>
))
)}
</Card>
</Col>
</Row>
</div>
);
}

View File

@@ -7,6 +7,7 @@ import CleanOptimizationPage from '../pages/CleanOptimization';
import WorkOrderPage from '../pages/WorkOrder';
import ReportCenterPage from '../pages/ReportCenter';
import RealTimeMonitorPage from '../pages/RealTimeMonitor';
import Agri from '../pages/Agri';
const Layout = lazy(() => import('../components/Layout'));
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
@@ -88,6 +89,7 @@ const routes: RouteObject[] = [
{ path: 'video', element: <Video /> },
{ path: 'RealtimeMonitor', element: <RealTimeMonitorPage /> },
{ path: 'monitor', element: <VideoMonitorPage /> },
{ path: 'agri', element: <Agri /> },
{ path: 'alerts', element: <Alerts /> },
{ path: 'AIanalysis', element: <AIDiagnosisPage /> },
{ path: 'clean', element: <CleanOptimizationPage /> },