feat(workbench): expose junction geometry parameters

This commit is contained in:
que01 committed 2026-09-03 12:02:16 +08:00
1 parent f6f51fe90b
commit 60e28f6b7a
2 files changed
+80 -13

No files matched your search

@@ -2,6 +2,8 @@ import { useMemo } from 'react';
import type { JunctionDescriptor } from './hotspots';
import { canEditJunction, type JunctionSession } from './workspace';
import { Button } from '../ui/button';
import { ParameterPanel } from '../components/ParameterPanel';
import type { EditHandle } from '../edit/types';
interface Props {
descriptor: JunctionDescriptor;
@@ -10,9 +12,26 @@ interface Props {
onApply: () => void;
onDiscard: () => void;
onSave: () => void;
handles?: EditHandle[];
onDraft?: (handle: EditHandle, value: number) => void;
onSettle?: (handle: EditHandle, value: number) => void;
onAbandon?: () => void;
onReset?: (handle: EditHandle) => void;
}
export function JunctionWorkspace({ descriptor, session, onClose, onApply, onDiscard, onSave }: Props) {
export function JunctionWorkspace({
descriptor,
session,
onClose,
onApply,
onDiscard,
onSave,
handles = [],
onDraft,
onSettle,
onAbandon,
onReset,
}: Props) {
const editable = useMemo(() => canEditJunction(descriptor), [descriptor]);
return (
<section className="junction-workspace" aria-label="路口编辑工作区">
@@ -41,17 +60,27 @@ export function JunctionWorkspace({ descriptor, session, onClose, onApply, onDis
</dd>
</dl>
{editable ? (
<div className="junction-workspace__actions">
<Button onClick={onApply} disabled={!session.dirty}>
应用到工作区
</Button>
<Button onClick={onSave} disabled={session.dirty}>
保存
</Button>
<Button onClick={onDiscard} disabled={!session.dirty}>
放弃草稿
</Button>
</div>
<>
<ParameterPanel
handles={handles}
hasSelection
onDraft={onDraft ?? (() => undefined)}
onSettle={onSettle ?? (() => undefined)}
onAbandon={onAbandon ?? (() => undefined)}
onReset={onReset ?? (() => undefined)}
/>
<div className="junction-workspace__actions">
<Button onClick={onApply} disabled={!session.dirty}>
应用到工作区
</Button>
<Button onClick={onSave} disabled={session.dirty}>
保存
</Button>
<Button onClick={onDiscard} disabled={!session.dirty}>
放弃草稿
</Button>
</div>
</>
) : null}
</div>
</section>