import React from "react"; interface BaseProperty { label: string; value: string | number; unit?: string; formatter?: (value: string | number) => string; } interface PropertyPanelProps { id?: string; type?: string; properties?: BaseProperty[]; } const PropertyPanel: React.FC = ({ id, type = "未知类型", properties = [], }) => { if (!id) { return (

属性面板

请选择一个要素以查看其属性。

); } const formatValue = (property: BaseProperty) => { if (property.formatter) { return property.formatter(property.value); } if (property.unit) { return `${property.value} ${property.unit}`; } return property.value; }; return (

属性面板

ID: {id}
类型: {type}
{properties.map((property, index) => (
{property.label}: {formatValue(property)}
))}
); }; export default PropertyPanel;