中英文切换 初始化

This commit is contained in:
mmc
2026-08-12 11:29:44 +08:00
parent 541e16f742
commit a8af55a856
76 changed files with 5847 additions and 1962 deletions

View File

@@ -30,11 +30,13 @@ import { useMqtt } from '@/hooks/useMqtt';
import envConfig from '../../../env';
import { useSelector } from 'react-redux';
import { RootState } from '@/store';
import { useTranslation } from 'react-i18next';
const { Text, Title } = Typography;
const { RangePicker } = DatePicker;
export default function WayLinePage({ onRefresh }) {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
const { stationId } = useSelector((state: RootState) => state.station);
@@ -74,7 +76,7 @@ export default function WayLinePage({ onRefresh }) {
latitude: item.latitude || 0,
},
deviceAlias: item.drone_callsign || item.device_sn
|| '无人机',
|| t('constants.uav'),
}));
@@ -356,7 +358,7 @@ export default function WayLinePage({ onRefresh }) {
const _list = res?.data?.list.map(item => {
return {
...item,
label: item.name || `航线_${item.id || '未知'}`,
label: item.name || `航线_${item.id || t('constants.locationUnknown')}`,
value: item.id
}
})
@@ -576,12 +578,12 @@ export default function WayLinePage({ onRefresh }) {
const statusMap = {
success: { color: 'success', text: '执行成功' },
preparing: { color: 'blue', text: '准备中' },
running: { color: 'processing', text: '执行中' },
running: { color: 'processing', text: t('workOrder.inProgress') },
failed: { color: 'error', text: '执行失败' },
waiting: { color: 'default', text: '待开始' },
starting_failure: { color: 'error', text: '启动失败' },
executing: { color: 'processing', text: '执行中' },
suspended: { color: 'warning', text: '已挂起' },
executing: { color: 'processing', text: t('workOrder.inProgress') },
suspended: { color: 'warning', text: t('workOrder.suspended') },
restored: { color: 'processing', text: '恢复执行' },
terminated: { color: 'default', text: '已终止' },
timeout: { color: 'error', text: '执行超时' },
@@ -592,15 +594,15 @@ export default function WayLinePage({ onRefresh }) {
// 列表表格列
const taskColumns = [
{ title: '任务名称', dataIndex: 'name', width: 260, ellipsis: true, fixed: "left" },
{ title: t('devices.taskName'), dataIndex: 'name', width: 260, ellipsis: true, fixed: "left" },
{ title: '设备SN', dataIndex: 'sn', width: 140 },
{ title: '状态', dataIndex: 'status', width: 80, render: getStatusTag },
{ title: t('roles.status'), dataIndex: 'status', width: 80, render: getStatusTag },
{
title: '开始时间', dataIndex: 'begin_at', width: 170,
title: t('devices.startTime'), dataIndex: 'begin_at', width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
{
title: '结束时间', dataIndex: 'end_at', width: 170,
title: t('devices.endTime'), dataIndex: 'end_at', width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
];
@@ -824,7 +826,7 @@ export default function WayLinePage({ onRefresh }) {
return (
<div className="normal-spacing" style={{ background: '#f5f7fa', minHeight: '100%', padding: '0px', paddingTop: 0 }}>
<div style={{ padding: '4px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>航线任务</Typography.Title>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('devices.waylineTask')}</Typography.Title>
</div>
<Row gutter={[16, 16]} style={{ marginBottom: 8 }}>
{topCards.map((item, index) => (
@@ -881,10 +883,10 @@ export default function WayLinePage({ onRefresh }) {
>
清空规划航线
</Button>
<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>新增</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>导入</Button>
<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>{t('common.addNew')}</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>{t('common.import')}</Button>
<Button size="small" icon={<NodeIndexOutlined />} style={{ borderRadius: 4 }}>优化</Button>
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>保存</Button>
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>{t('common.save')}</Button>
<Button size="small" icon={<Maximize2 size={12} />} />
</Space>
}
@@ -921,7 +923,7 @@ export default function WayLinePage({ onRefresh }) {
format="YYYY-MM-DD HH:mm:ss"
value={listDateRange}
onChange={(val) => setListDateRange(val)}
placeholder={['开始时间', '结束时间']}
placeholder={[t('devices.startTime'), t('devices.endTime')]}
/>
<Select
style={{ width: 180 }}
@@ -996,11 +998,11 @@ export default function WayLinePage({ onRefresh }) {
]}
columns={[
{ title: '编号', dataIndex: 'id', width: 70, render: (t) => <Text style={{ color: '#165DFF', fontWeight: 600 }}>{t}</Text> },
{ title: '装备', dataIndex: 'device', width: 80 },
{ title: '类型', dataIndex: 'type', ellipsis: true },
{ title: '优先级', dataIndex: 'level', width: 80, render: (l) => <span style={{ color: l === '高' ? '#F53F3F' : l === '中' ? '#FF7D00' : '#86909C', fontSize: 11, fontWeight: 600 }}>▲ {l}</span> },
{ title: t('constants.sourceEquipment'), dataIndex: 'device', width: 80 },
{ title: t('common.type'), dataIndex: 'type', ellipsis: true },
{ title: t('workOrder.priority'), dataIndex: 'level', width: 80, render: (l) => <span style={{ color: l === '高' ? '#F53F3F' : l === '中' ? '#FF7D00' : '#86909C', fontSize: 11, fontWeight: 600 }}>▲ {l}</span> },
{ title: '建议时间', dataIndex: 'time', width: 110 },
{ title: '状态', dataIndex: 'status', width: 90, render: (s) => <Text style={{ color: s.includes('建议') ? '#165DFF' : '#86909C', fontSize: 11, fontWeight: 500 }}>{s}</Text> },
{ title: t('roles.status'), dataIndex: 'status', width: 90, render: (s) => <Text style={{ color: s.includes('建议') ? '#165DFF' : '#86909C', fontSize: 11, fontWeight: 500 }}>{s}</Text> },
]}
/>
<div style={{ background: '#F8F9FB', padding: '2px 14px', borderRadius: 8, marginTop: 8, border: '1px solid #F1F2F5' }}>
@@ -1016,7 +1018,7 @@ export default function WayLinePage({ onRefresh }) {
<Row gutter={12} style={{ marginTop: 8 }}>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>一键排程</Button></Col>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>智能分配</Button></Col>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>生成工单</Button></Col>
<Col span={8}><Button type="primary" block style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600 }}>{t('clean.generateOrder')}</Button></Col>
</Row>
</Card>
@@ -1051,7 +1053,7 @@ export default function WayLinePage({ onRefresh }) {
taskDetail?.repeat_type === 'relative_monthly' ? '按月(星期)' : '-',
unit: ''
},
{ label: '失控动作', value: taskDetail?.out_of_control_action_in_flight === 'return_home' ? '返航' : '-', unit: '' },
{ label: '失控动作', value: taskDetail?.out_of_control_action_in_flight === 'return_home' ? t('devices.returnHome') : '-', unit: '' },
].map((item, idx) => (
<div
key={idx}
@@ -1111,7 +1113,7 @@ export default function WayLinePage({ onRefresh }) {
style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 4 }}
>
恢复任务
{/*{selectedTask?.status === 'suspended' ? '继续任务' : '执行任务'}*/}
{/*{selectedTask?.status === 'suspended' ? '继续任务' : t('devices.executeTask')}*/}
</Button>
)}
<Button
@@ -1122,7 +1124,7 @@ export default function WayLinePage({ onRefresh }) {
loading={flightCommandLoading}
style={{ background: '#165DFF', height: 28, borderRadius: 18, fontWeight: 600, display: 'inline-flex', alignItems: 'center', gap: 4 }}
>
{isReturningHome ? '取消返航' : '返航'}
{isReturningHome ? '取消返航' : t('devices.returnHome')}
</Button>
<Button
@@ -1170,7 +1172,7 @@ export default function WayLinePage({ onRefresh }) {
<Thermometer size={20} style={{ color: '#FF7D00' }} />
</div>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>温度</div>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('home.temperature')}</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{fix2((mqttDerivedData || listDroneRealtime || listDrone)?.environment_temperature)}℃</div>
<div style={{ fontSize: 12, color: '#00B42A' }}>适宜</div>
</div>
@@ -1184,7 +1186,7 @@ export default function WayLinePage({ onRefresh }) {
<div style={{ fontSize: 12, color: '#86909C' }}>降水状态</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{getVal((mqttDerivedData || listDroneRealtime || listDrone)?.rainfall)}</div>
<div style={{ fontSize: 12, color: (mqttDerivedData || listDroneRealtime || listDrone)?.rainfall === 'no_rain' ? '#00B42A' : '#F53F3F' }}>
{(mqttDerivedData || listDroneRealtime || listDrone)?.rainfall === 'no_rain' ? '低风险' : '有雨'}
{(mqttDerivedData || listDroneRealtime || listDrone)?.rainfall === 'no_rain' ? t('aiAnalysis.lowRisk') : '有雨'}
</div>
</div>
</div>
@@ -1407,7 +1409,7 @@ export default function WayLinePage({ onRefresh }) {
}))
},
{
title: '执行中', count: runList.length, color: '#165DFF', bg: '#E8F3FF',
title: t('workOrder.inProgress'), count: runList.length, color: '#165DFF', bg: '#E8F3FF',
list: runList.map(item => ({
id: item.sn?.slice(-5) || '',
name: item.name,
@@ -1416,7 +1418,7 @@ export default function WayLinePage({ onRefresh }) {
}))
},
{
title: '已完成', count: finishList.length, color: '#00B42A', bg: '#E8FFEA',
title: t('workOrder.completed'), count: finishList.length, color: '#00B42A', bg: '#E8FFEA',
list: finishList.map(item => ({
id: item.sn?.slice(-5) || '',
name: item.name,
@@ -1482,7 +1484,7 @@ export default function WayLinePage({ onRefresh }) {
<Input
value={taskForm.name}
onChange={(e) => setTaskForm({ ...taskForm, name: e.target.value })}
placeholder="请输入"
placeholder={t('common.pleaseInput')}
/>
</div>
<div>
@@ -1581,7 +1583,7 @@ export default function WayLinePage({ onRefresh }) {
{(taskForm.task_type === 'timed' || taskForm.task_type === 'recurring' || taskForm.task_type === 'continuous') && (
<div className="grid grid-cols-2 gap-4">
<div>
<label className="text-sm block mb-1">开始时间</label>
<label className="text-sm block mb-1">{t('devices.startTime')}</label>
<DatePicker
showTime
value={taskForm.begin_at}
@@ -1591,7 +1593,7 @@ export default function WayLinePage({ onRefresh }) {
</div>
{(taskForm.task_type === 'recurring' || taskForm.task_type === 'continuous') && (
<div>
<label className="text-sm block mb-1">结束时间</label>
<label className="text-sm block mb-1">{t('devices.endTime')}</label>
<DatePicker
showTime
value={taskForm.end_at}
@@ -1735,7 +1737,7 @@ export default function WayLinePage({ onRefresh }) {
{/* 按钮 */}
<div className="flex justify-end gap-2 mt-4">
<Button onClick={resetModals}>取消</Button>
<Button onClick={resetModals}>{t('common.cancel')}</Button>
<Button type="primary" loading={loading} onClick={createFlightTask}>确认创建</Button>
</div>
</div>
@@ -1749,7 +1751,7 @@ export default function WayLinePage({ onRefresh }) {
onCancel={() => setRthModalVisible(false)}
confirmLoading={loading}
okText="立即执行"
cancelText="取消"
cancelText={t('common.cancel')}
centered
width={400}
>