fix: preserve model selection when toggling series

This commit is contained in:
2026-08-26 11:01:47 +08:00
parent 185dd36bf3
commit 4b9a2f4cd9
2 changed files with 15 additions and 19 deletions

View File

@@ -171,10 +171,7 @@ export default function VehicleTree({ selection, onSelect }: Props) {
<div
className={`flex items-center gap-1 px-1 py-1 rounded cursor-pointer group text-xs
${isSeriesSelected ? 'bg-primary/20 text-primary' : 'hover:bg-secondary/60'}`}
onClick={() => {
toggleSeries(series.id);
onSelect({ seriesId: series.id, modelId: null, taskId: null });
}}
onClick={() => toggleSeries(series.id)}
>
{expanded ? <ChevronDown className="w-3 h-3 flex-shrink-0 text-muted-foreground" /> : <ChevronRight className="w-3 h-3 flex-shrink-0 text-muted-foreground" />}
<Train className="w-3 h-3 flex-shrink-0 text-muted-foreground" />

View File

@@ -278,14 +278,11 @@ export default function Home() {
// ── 左侧面板渲染 ───────────────────────────────────────────────────────────
const renderLeftPanel = () => {
if (selection.modelId == null) {
return (
<VehicleTree selection={selection} onSelect={setSelection} />
);
}
return (
<div className="flex min-h-0 flex-1 flex-col">
<VehicleTree selection={selection} onSelect={setSelection} />
{selection.modelId != null && (
<>
<div className="h-px bg-border my-1" />
<TaskManager
modelId={selection.modelId}
@@ -296,6 +293,8 @@ export default function Home() {
onCadFilesSelectionChange={setSelectedTaskCadFileIds}
onSelectTaskCad={handleSelectCad}
/>
</>
)}
</div>
);
};