import { useState, type CSSProperties } from 'react'; import { getLocalizedPath, type Locale } from '../i18n/utils'; type NetNode = { id: string; title: string; desc: string; link?: string; }; export type OrgNetworkData = { center: { title: string; subtitle: string; desc: string }; nodes: NetNode[]; }; // 6 个子节点均匀分布在圆周上(从正上方开始,顺时针 60° 间隔) const ANGLES = [-90, -30, 30, 90, 150, 210]; const R = 38; // 半径(占容器百分比) function nodePos(i: number) { const a = (ANGLES[i] * Math.PI) / 180; return { x: 50 + R * Math.cos(a), y: 50 + R * Math.sin(a), }; } export default function OrgNetwork({ data, locale }: { data: OrgNetworkData; locale: Locale }) { const [active, setActive] = useState('center'); const current = active === 'center' ? { title: data.center.title, desc: data.center.desc } : data.nodes.find((n) => n.id === active) ?? { title: data.center.title, desc: data.center.desc }; const link = active === 'center' ? undefined : data.nodes.find((n) => n.id === active)?.link; const learnMore = locale === 'en' ? 'Learn more' : '了解更多'; return (
{/* 辐射网络图 */}
{/* 中心节点 */} {/* 子节点 */} {data.nodes.map((n, i) => { const p = nodePos(i); return ( ); })}
{/* 详情面板 */}

{current.title}

{current.desc}

{link && ( {learnMore} )}
); }