/** * Celestial Bodies Management Page */ import { useState, useEffect } from 'react'; import { Table, Button, message } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { request } from '../../utils/request'; interface CelestialBody { id: string; name: string; name_zh: string; type: string; description: string; } export function CelestialBodies() { const [loading, setLoading] = useState(false); const [data, setData] = useState([]); useEffect(() => { loadData(); }, []); const loadData = async () => { setLoading(true); try { const { data: result } = await request.get('/celestial/list'); setData(result.bodies || []); } catch (error) { message.error('加载数据失败'); } finally { setLoading(false); } }; const columns: ColumnsType = [ { title: 'ID', dataIndex: 'id', key: 'id', width: 100, }, { title: '英文名', dataIndex: 'name', key: 'name', }, { title: '中文名', dataIndex: 'name_zh', key: 'name_zh', }, { title: '类型', dataIndex: 'type', key: 'type', render: (type: string) => { const typeMap: Record = { star: '恒星', planet: '行星', dwarf_planet: '矮行星', probe: '探测器', }; return typeMap[type] || type; }, }, { title: '描述', dataIndex: 'description', key: 'description', ellipsis: true, }, ]; return (

天体数据列表

); }