+
{groups.map((group, index) => {
- const cluster = group.radius * pxPerUnit;
- const ringRadius = cluster * 0.7;
+ const unit = base * group.radius;
// 机数多的舱室缩小点位,避免十几个点糊成一团
+ const orbit = unit * 0.28;
const dot = group.engines > 4
- ? Math.min(8, Math.max(3, (Math.PI * 2 * ringRadius) / (group.engines * 1.7)))
- : Math.min(8, Math.max(4, cluster * 0.5));
- const placements = engineLayout(group.engines, 1);
+ ? Math.min(8, Math.max(3, (Math.PI * 2 * orbit) / (group.engines * 1.7)))
+ : Math.min(9, Math.max(4, unit * 0.2));
return (
- {placements.map((placement, dotIndex) => (
+ {engineLayout(group.engines, 1).map((placement, dotIndex) => (
))}
@@ -452,7 +448,7 @@ function EngineGauge({
);
})}
-
{label}
+
{caption}
);
}
@@ -486,7 +482,6 @@ function RocketMission({ rockets }: { rockets: RocketConfig[] }) {
const [viewScaleResetTrigger, setViewScaleResetTrigger] = useState(0);
const rocket = rockets.find((item) => item.code === selectedCode) || rockets[0];
const { state, toggle, reset, speed, setSpeed } = useRocketSimulation(rocket);
- const environment = environmentAt(state.altitude, rocket.target_orbit_km);
const totalFuel = rocket.stage_1.fuel_mass_kg + rocket.stage_2.fuel_mass_kg;
const remainingFuel = state.stage1Fuel + state.stage2Fuel;
@@ -589,20 +584,14 @@ function RocketMission({ rockets }: { rockets: RocketConfig[] }) {
- {/* Bottom: environment + mission clock + progress + gauges + controls */}
+ {/* Bottom: engine bank + mission clock + progress + attitude + controls */}
-
-
- {environment.code}
- {environment.label}
- {rocket.launch_site_name} · {environment.detail}
-
-
- NEXT EVENT
- {nextMilestone ? nextMilestone.code : (state.phase === 'mission_complete' ? 'COMPLETE' : '—')}
- {nextMilestone ? nextMilestone.label : '任务完成'}
-
-
+
{clockText}
@@ -617,12 +606,6 @@ function RocketMission({ rockets }: { rockets: RocketConfig[] }) {
-
diff --git a/frontend/src/pages/admin/RocketEvents.tsx b/frontend/src/pages/admin/RocketEvents.tsx
new file mode 100644
index 0000000..a42845a
--- /dev/null
+++ b/frontend/src/pages/admin/RocketEvents.tsx
@@ -0,0 +1,205 @@
+/**
+ * 火箭发射事件页面
+ *
+ * 数据来自定时任务同步的 Launch Library,本页面只读:
+ * 按「即将发射 / 已结束 / 全部」浏览,并可模糊搜索任务、型号与发射场。
+ */
+import { useCallback, useEffect, useState } from 'react';
+import { Segmented, Tag, Tooltip } from 'antd';
+import { RocketOutlined } from '@ant-design/icons';
+import type { ColumnsType } from 'antd/es/table';
+import { DataTable } from '../../components/admin/DataTable';
+import { AdminPage, HeaderStat } from '../../components/admin/AdminPage';
+import { useListPageSize } from './useListPageSize';
+import { request } from '../../utils/request';
+import { useToast } from '../../contexts/ToastContext';
+
+interface RocketEvent {
+ id: number;
+ name: string;
+ mission_name: string | null;
+ mission_type: string | null;
+ rocket_name: string | null;
+ provider: string | null;
+ orbit: string | null;
+ launch_site_name: string | null;
+ location_name: string | null;
+ net: string;
+ status: string;
+ source_url: string | null;
+ rocket: { code: string; name: string; name_zh: string | null } | null;
+}
+
+interface Stats {
+ total: number;
+ upcoming: number;
+ last_synced_at: string | null;
+}
+
+/** 时间范围筛选:即将发射按时间升序,已结束按时间倒序。 */
+type RangeKey = 'upcoming' | 'past' | 'all';
+
+const RANGE_OPTIONS = [
+ { value: 'upcoming', label: '即将发射' },
+ { value: 'past', label: '已结束' },
+ { value: 'all', label: '全部' },
+] as const;
+
+/** 后端存的是不带时区的 UTC 时间,补上 Z 才能按本地时区正确显示。 */
+function formatNet(value: string) {
+ const iso = /Z|[+-]\d{2}:?\d{2}$/.test(value) ? value : `${value}Z`;
+ return new Date(iso).toLocaleString('zh-CN', {
+ month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit',
+ });
+}
+
+export function RocketEvents() {
+ const systemPageSize = useListPageSize();
+ const [data, setData] = useState
([]);
+ const [loading, setLoading] = useState(false);
+ const [total, setTotal] = useState(0);
+ const [page, setPage] = useState(1);
+ const [range, setRange] = useState('upcoming');
+ const [search, setSearch] = useState('');
+ const [stats, setStats] = useState(null);
+ const toast = useToast();
+
+ const load = useCallback(async () => {
+ setLoading(true);
+ try {
+ const params = {
+ limit: systemPageSize,
+ offset: (page - 1) * systemPageSize,
+ upcoming: range === 'all' ? undefined : range === 'upcoming',
+ search: search.trim() || undefined,
+ };
+ const [{ data: pageData }, { data: statsData }] = await Promise.all([
+ request.get('/rocket-events', { params }),
+ request.get('/rocket-events/stats'),
+ ]);
+ setData(pageData.events || []);
+ setTotal(pageData.total || 0);
+ setStats(statsData);
+ } catch {
+ toast.error('加载火箭发射事件失败');
+ } finally {
+ setLoading(false);
+ }
+ }, [page, range, search, systemPageSize, toast]);
+
+ useEffect(() => { void load(); }, [load]);
+
+ const columns: ColumnsType = [
+ {
+ title: '发射时间',
+ dataIndex: 'net',
+ width: 130,
+ render: (value: string) => formatNet(value),
+ },
+ {
+ title: '任务',
+ dataIndex: 'mission_name',
+ width: 240,
+ ellipsis: true,
+ render: (value: string | null, record) => value || record.name,
+ },
+ {
+ title: '型号',
+ dataIndex: 'rocket_name',
+ width: 200,
+ ellipsis: true,
+ render: (value: string | null, record) => (
+
+ {value || '-'}{record.rocket ? 已关联 : null}
+
+ ),
+ },
+ {
+ title: '发射服务商',
+ dataIndex: 'provider',
+ width: 130,
+ render: (value: string | null) => value || '-',
+ },
+ {
+ title: '轨道',
+ dataIndex: 'orbit',
+ width: 150,
+ ellipsis: true,
+ render: (value: string | null) => value || '-',
+ },
+ {
+ title: '发射场',
+ dataIndex: 'launch_site_name',
+ width: 220,
+ ellipsis: true,
+ render: (value: string | null, record) => (
+
+ {value || record.location_name || '-'}
+
+ ),
+ },
+ {
+ title: '状态',
+ dataIndex: 'status',
+ width: 150,
+ render: (value: string) => {value || '-'},
+ },
+ {
+ title: '详情',
+ dataIndex: 'source_url',
+ width: 90,
+ render: (value: string | null) => (
+ value
+ ? Launch Library
+ : '-'
+ ),
+ },
+ ];
+
+ return (
+ }
+ title="火箭发射事件"
+ description="由定时任务从 Launch Library 同步的真实发射计划,可与火箭数据管理的型号关联"
+ actions={
+ <>
+
+
+
+ >
+ }
+ >
+ setPage(next)}
+ onRefresh={() => void load()}
+ onSearch={(value) => { setSearch(value); setPage(1); }}
+ searchPlaceholder="搜索任务名 / 型号 / 发射场"
+ toolbar={
+ ({ value: item.value, label: item.label }))}
+ onChange={(value) => { setRange(value as RangeKey); setPage(1); }}
+ />
+ }
+ rowKey="id"
+ showAdd={false}
+ showEdit={false}
+ />
+
+ );
+}
+
+function statusColor(status: string) {
+ const lower = status.toLowerCase();
+ if (lower.includes('success')) return 'success';
+ if (lower.includes('fail') || lower.includes('failure')) return 'error';
+ if (lower.includes('launch') || lower.includes('go for')) return 'processing';
+ if (lower.includes('hold')) return 'warning';
+ return 'default';
+}
diff --git a/frontend/src/pages/admin/Rockets.tsx b/frontend/src/pages/admin/Rockets.tsx
index f4efdce..6fc4e0f 100644
--- a/frontend/src/pages/admin/Rockets.tsx
+++ b/frontend/src/pages/admin/Rockets.tsx
@@ -12,7 +12,7 @@ import { useToast } from '../../contexts/ToastContext';
const defaultStage1 = { name: '一级推进器', dry_mass_kg: 25000, fuel_mass_kg: 400000, max_thrust_n: 7500000, specific_impulse_s: 285, engine_count: 9, length_ratio: 0.65 };
const defaultStage2 = { name: '二级推进器', dry_mass_kg: 4000, fuel_mass_kg: 100000, max_thrust_n: 1000000, specific_impulse_s: 350, engine_count: 1, length_ratio: 0.35 };
-const createDefaults = { color: '#f8fafc', launch_site_name: '发射场', launch_latitude_deg: 0, launch_longitude_deg: 0, payload_mass_kg: 15000, drag_coefficient: 0.4, target_orbit_km: 200, target_velocity_mps: 7800, separation_delay_seconds: 2, second_stage_ignition_delay_seconds: 1, is_active: true, sort_order: 0, stage_1: defaultStage1, stage_2: defaultStage2, appearance: {} };
+const createDefaults = { color: '#f8fafc', launch_site_name: '发射场', launch_latitude_deg: 0, launch_longitude_deg: 0, payload_mass_kg: 15000, drag_coefficient: 0.4, target_orbit_km: 200, target_velocity_mps: 7800, separation_delay_seconds: 2, second_stage_ignition_delay_seconds: 1, is_active: true, sort_order: 0, stage_1: defaultStage1, stage_2: defaultStage2, appearance: {}, boosters: {} };
function NumberField({ name, label, suffix, min = 0, max, step }: { name: string | (string | number)[]; label: string; suffix?: string; min?: number; max?: number; step?: number }) {
return ;
@@ -47,6 +47,26 @@ function AppearanceFields() {
);
}
+/**
+ * 助推器参数(可选)。
+ *
+ * 一级参数登记的是「芯级 + 助推器」的合计值,这里单独登记助推器那一组,
+ * 芯级由减法推导,因此捆绑构型的火箭才能算出真实的助推器分离与一级关机时序。
+ * 整组留空即不拆分,一级按整体燃烧到关机。
+ */
+function BoosterFields() {
+ return (
+
+
+
+
+
+
+
+
+ );
+}
+
export function Rockets() {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(false);
@@ -100,6 +120,8 @@ export function Rockets() {
const save = async () => {
try {
const values = await form.validateFields();
+ // 助推器是整组可选的:没填数量就当不拆分,避免把半个对象提交给后端
+ if (!values.boosters?.count) values.boosters = null;
if (editing) await request.put(`/rockets/admin/${editing.id}`, values);
else await request.post('/rockets/admin', values);
toast.success(editing ? '火箭配置已更新' : '火箭配置已创建');
@@ -182,6 +204,7 @@ export function Rockets() {
{ key: 'mission', label: '发射与任务', children:
},
{ key: 'stage1', label: '一级参数', children: },
{ key: 'stage2', label: '二级参数', children: },
+ { key: 'boosters', label: '助推器参数(可选)', children: },
{ key: 'appearance', label: '外观构型(可选)', children: },
]} />