feat(workbench): stabilize junction tools workspace

This commit is contained in:
que01 committed 2026-09-04 09:46:19 +08:00
1 parent e6b822416d
commit f10a5da325
22 files changed
+1078 -53

No files matched your search

@@ -4,6 +4,9 @@ import { canEditJunction, type JunctionSession } from './workspace';
import { Button } from '../ui/button';
import { ParameterPanel } from '../components/ParameterPanel';
import type { EditHandle } from '../edit/types';
import type { Road } from '../types/state';
import type { Coordinate } from '../edit/meters';
import { junctionLabelForHandle, junctionRoadName } from './labels';
interface Props {
descriptor: JunctionDescriptor;
@@ -18,9 +21,13 @@ interface Props {
onEnableEdit?: () => void;
handles?: EditHandle[];
onDraft?: (handle: EditHandle, value: number) => void;
onDraftGroup?: (handles: EditHandle[], value: number) => void;
onSettle?: (handle: EditHandle, value: number) => void;
onSettleGroup?: (handles: EditHandle[], value: number) => void;
onAbandon?: () => void;
onReset?: (handle: EditHandle) => void;
roads?: Road[];
junctionCoordinate?: Coordinate;
}
export function JunctionWorkspace({
@@ -36,19 +43,22 @@ export function JunctionWorkspace({
facilitySummary = { crosswalks: 0, stopLines: 0, signals: 0 },
handles = [],
onDraft,
onDraftGroup,
onSettle,
onSettleGroup,
onAbandon,
onReset,
roads = [],
junctionCoordinate = descriptor.coordinate,
}: Props) {
const editable = useMemo(() => canEditJunction(descriptor), [descriptor]);
return (
<section className="junction-workspace" aria-label="路口编辑工作区">
<header className="junction-workspace__header">
<div>
<span className="junction-workspace__eyebrow">JunctionTools</span>
<h2>
{descriptor.ref.type === 'node' ? '路口节点' : '复杂路口上下文'} {descriptor.ref.id}
</h2>
<div className="junction-workspace__title-line">
<span className="junction-workspace__eyebrow">JunctionTools</span>
</div>
<p>
{editable
? editMode
@@ -65,9 +75,9 @@ export function JunctionWorkspace({
<div className="junction-workspace__body">
<dl>
<dt>组成节点</dt>
<dd>{descriptor.nodeIds.join(', ') || '—'}</dd>
<dd>{descriptor.nodeIds.length ? `${descriptor.nodeIds.length} 个路口节点` : '—'}</dd>
<dt>进口道路</dt>
<dd>{descriptor.approachRoadIds.join(', ') || '—'}</dd>
<dd>{roads.length ? roads.map((road) => junctionRoadName(road, roads)).join('、') : '—'}</dd>
<dt>诊断</dt>
<dd>{descriptor.diagnosticIds.length ? `${descriptor.diagnosticIds.length} 条` : '无'}</dd>
<dt>状态</dt>
@@ -98,10 +108,14 @@ export function JunctionWorkspace({
<ParameterPanel
handles={handles}
hasSelection
grouped
onDraft={onDraft ?? (() => undefined)}
onDraftGroup={onDraftGroup}
onSettle={onSettle ?? (() => undefined)}
onSettleGroup={onSettleGroup}
onAbandon={onAbandon ?? (() => undefined)}
onReset={onReset ?? (() => undefined)}
labelForHandle={(handle) => junctionLabelForHandle(handle, roads, junctionCoordinate)}
/>
<div className="junction-workspace__actions">
<Button onClick={onApply} disabled={!session.dirty}>