Embed external workbench workspaces in project shell stage

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-11-13 23:11:34 +08:00
parent 7a3989eb99
commit 1454e259be
4 changed files with 24 additions and 2 deletions

View File

@@ -90,6 +90,7 @@ import { PreferencesDialog, loadWebPreferences } from "./shell/preferences-dialo
import { formatLength, formatVolume, unitInfo } from "./shell/units.js";
import { ShortcutEditor, ShortcutManager } from "./shell/shortcut-manager.js";
import { BottomDock } from "./shell/bottom-dock.js";
import { WorkbenchFrame, isExternalWorkbench } from "./shell/workbench-frame.js";
import { DesktopCommandDispatcher } from "./desktop-command-dispatcher.js";
import type { WorkbenchCommandRecord } from "./workbench-command-facade.js";
import { DocumentTree, type DocumentTreeNode } from "./document-tree.js";
@@ -2198,7 +2199,8 @@ function App() {
{openScadSnapshots[active] && <OpenScadDesktopView document={openScadSnapshots[active]}
selected={selectedObjects[active] ? [selectedObjects[active]!.replace(/^native:/, "")] : []}
onSelect={name => selectPrimaryObject(`native:${name}`)} />}
<div ref={viewportRef} style={openScadDocuments.current.has(active) || testDocuments.current.has(active) ? { display: "none" } : undefined} className="viewport" aria-label="Imported native 3D view" />
<div ref={viewportRef} style={openScadDocuments.current.has(active) || testDocuments.current.has(active) || isExternalWorkbench(workbench) ? { display: "none" } : undefined} className="viewport" aria-label="Imported native 3D view" />
{isExternalWorkbench(workbench) && <WorkbenchFrame workbench={workbench} />}
<div className="viewport-transform-bar" role="toolbar" aria-label="Object transform">
{([["translate", "移动"], ["rotate", "旋转"], ["off", "关闭"]] as const).map(([mode, label]) => (
<button key={mode} className="tool" title={`${label}控制器`} aria-label={`${label}控制器`} aria-pressed={transformMode === mode}

View File

@@ -0,0 +1,14 @@
import React from "react";
const LOCAL_WORKBENCHES = new Set(["Part", "Sketcher", "PartDesign", "Spreadsheet", "Surface", "Assembly", "Draft"]);
export const isExternalWorkbench = (workbench: string) => !LOCAL_WORKBENCHES.has(workbench);
export function WorkbenchFrame({ workbench }: { workbench: string }) {
return <div className="workbench-frame" aria-label={`${workbench} workbench workspace`}>
<style>{`
.workbench-frame{flex:1;min-height:0;display:flex;border-top:1px solid #2a3a45;background:#0f1419}
.workbench-frame iframe{flex:1;width:100%;border:0;background:#0f1419}
`}</style>
<iframe title={`${workbench} workbench`} src={`/workbench.html?module=${encodeURIComponent(workbench)}`} />
</div>;
}