强制要求 onClose 属性,简化面板关闭逻辑

This commit is contained in:
2026-04-30 13:47:45 +08:00
parent 8f3c288823
commit c5b0f43a0d
2 changed files with 4 additions and 6 deletions
@@ -65,7 +65,7 @@ export interface SCADADataPanelProps {
/** 外部传入结束时间(ISO8601 字符串),用于初始化并触发查询 */
end_time?: string;
/** 关闭面板 */
onClose?: () => void;
onClose: () => void;
}
type PanelTab = "chart" | "table";
@@ -432,7 +432,6 @@ const SCADADataPanel: React.FC<SCADADataPanelProps> = ({
end_time,
onClose,
}) => {
const handleClose = onClose ?? (() => {});
// 从 featureInfos 中提取设备 ID 列表
const deviceIds = useMemo(
() => featureInfos.map(([id]) => id),
@@ -936,7 +935,7 @@ const SCADADataPanel: React.FC<SCADADataPanelProps> = ({
<IconButton
className="panel-close-button"
size="small"
onClick={handleClose}
onClick={onClose}
aria-label="关闭历史数据面板"
sx={panelHeaderActionSx}
>
@@ -26,7 +26,7 @@ interface PropertyPanelProps {
id?: string;
type?: string;
properties?: PropertyItem[];
onClose?: () => void;
onClose: () => void;
}
const PropertyPanel: React.FC<PropertyPanelProps> = ({
@@ -36,7 +36,6 @@ const PropertyPanel: React.FC<PropertyPanelProps> = ({
onClose,
}) => {
const draggableRef = useRef<HTMLDivElement>(null);
const handleClose = onClose ?? (() => {});
const headerActionSx = {
color: "common.white",
backgroundColor: "rgba(255,255,255,0.08)",
@@ -98,7 +97,7 @@ const PropertyPanel: React.FC<PropertyPanelProps> = ({
<IconButton
className="panel-close-button"
size="small"
onClick={handleClose}
onClick={onClose}
aria-label="关闭属性面板"
sx={headerActionSx}
>