完善建模交互、组件图标与系统协议
This commit is contained in:
1 parent
456c29b3b6
commit
6572defaa4
66 files changed
+10067
-4163
No files matched your search
@@ -77,8 +77,11 @@ type ResultProjectEdge = {
|
||||
id: string;
|
||||
source: string;
|
||||
target: string;
|
||||
sourceHandle: string | null;
|
||||
targetHandle: string | null;
|
||||
sourceHandle: string;
|
||||
targetHandle: string;
|
||||
data: {
|
||||
isContactEdge: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
type ResultSimulationConfig = {
|
||||
@@ -131,8 +134,8 @@ export type SimulationResultsSnapshot = {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
project: {
|
||||
projectSchemaVersion: 1;
|
||||
name: string;
|
||||
presentationLayoutVersion?: 1 | null;
|
||||
nodes: ResultProjectNode[];
|
||||
edges: ResultProjectEdge[];
|
||||
simulation: ResultSimulationConfig;
|
||||
@@ -384,7 +387,18 @@ export function SimulationResultsView({
|
||||
};
|
||||
clampLayoutToWorkbench();
|
||||
window.addEventListener("resize", clampLayoutToWorkbench);
|
||||
return () => window.removeEventListener("resize", clampLayoutToWorkbench);
|
||||
const workbench = workbenchRef.current;
|
||||
const observer =
|
||||
workbench && typeof ResizeObserver !== "undefined"
|
||||
? new ResizeObserver(clampLayoutToWorkbench)
|
||||
: null;
|
||||
if (workbench) {
|
||||
observer?.observe(workbench);
|
||||
}
|
||||
return () => {
|
||||
window.removeEventListener("resize", clampLayoutToWorkbench);
|
||||
observer?.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1138,6 +1152,7 @@ export function SimulationResultsView({
|
||||
nodes={readOnlyNodes}
|
||||
nodesConnectable={false}
|
||||
nodesDraggable={false}
|
||||
proOptions={{ hideAttribution: true }}
|
||||
nodesFocusable
|
||||
onNodeClick={(_, node) => setSelectedNodeId(node.id)}
|
||||
onPaneClick={() => setSelectedNodeId(null)}
|
||||
@@ -3910,10 +3925,8 @@ function isSimulationResultsSnapshotValue(
|
||||
const result = value.result;
|
||||
if (
|
||||
!isRecord(project) ||
|
||||
project.projectSchemaVersion !== 1 ||
|
||||
typeof project.name !== "string" ||
|
||||
(project.presentationLayoutVersion !== undefined &&
|
||||
project.presentationLayoutVersion !== null &&
|
||||
project.presentationLayoutVersion !== 1) ||
|
||||
!Array.isArray(project.nodes) ||
|
||||
!project.nodes.every(isResultProjectNode) ||
|
||||
!Array.isArray(project.edges) ||
|
||||
@@ -3954,6 +3967,7 @@ function isResultProjectNode(value: unknown): value is ResultProjectNode {
|
||||
typeof data.componentType === "string" &&
|
||||
typeof data.modelType === "string" &&
|
||||
Array.isArray(data.ports) &&
|
||||
data.ports.every(isResultPortDefinition) &&
|
||||
isRecord(data.parameters) &&
|
||||
(data.parameterUnits === undefined || isRecord(data.parameterUnits)) &&
|
||||
[0, 90, 180, 270].includes(Number(data.rotation)) &&
|
||||
@@ -3961,14 +3975,32 @@ function isResultProjectNode(value: unknown): value is ResultProjectNode {
|
||||
);
|
||||
}
|
||||
|
||||
function isResultPortDefinition(value: unknown): value is ResultPortDefinition {
|
||||
return (
|
||||
isRecord(value) &&
|
||||
typeof value.name === "string" &&
|
||||
value.name.length > 0 &&
|
||||
typeof value.kind === "string" &&
|
||||
typeof value.domain === "string" &&
|
||||
typeof value.nominalRole === "string" &&
|
||||
(value.positiveFlowDirection === undefined ||
|
||||
typeof value.positiveFlowDirection === "string") &&
|
||||
(value.side === "left" || value.side === "right")
|
||||
);
|
||||
}
|
||||
|
||||
function isResultProjectEdge(value: unknown): value is ResultProjectEdge {
|
||||
return (
|
||||
isRecord(value) &&
|
||||
typeof value.id === "string" &&
|
||||
typeof value.source === "string" &&
|
||||
typeof value.target === "string" &&
|
||||
(value.sourceHandle === null || typeof value.sourceHandle === "string") &&
|
||||
(value.targetHandle === null || typeof value.targetHandle === "string")
|
||||
typeof value.sourceHandle === "string" &&
|
||||
value.sourceHandle.length > 0 &&
|
||||
typeof value.targetHandle === "string" &&
|
||||
value.targetHandle.length > 0 &&
|
||||
isRecord(value.data) &&
|
||||
typeof value.data.isContactEdge === "boolean"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user