From 6ec61b484138ae59970f1061827774a04f473e8e Mon Sep 17 00:00:00 2001 From: mes123456 Date: Wed, 2 Dec 2026 07:00:49 +0800 Subject: [PATCH] feat(web): Outliner object and collection rows open the desktop menus - Rebuild the row menus from shared builders following space_outliner.py: OUTLINER_MT_object (Copy/Paste | Delete | Select* | Unlink/New Collection | ID Data | common groups) and OUTLINER_MT_collection (New/Duplicate/Copy/ Paste | Delete | Select Objects | Instance/Unlink | Visibility | View Layer | Color Tag | ID Data | common groups). - The ID Data, visibility, view layer, color tag, asset, library override and view submenus are shared by the row-type menus and the empty-area menu; the asset entries are inlined like draw_common_operators' menu_contents, and the library override operations now nest under their desktop submenu. - Top-level Copy/Paste dispatch OUTLINER_OT_id_copy/id_paste; the ID Data submenu keeps its enum entries. - New headed case [outliner-menu-structure-web]; separator and submenu expectations updated. Full headed suite 45/45, validator PASS. Co-Authored-By: Claude Fable 5.2 --- tools/web/check-outliner-headed.mjs | 2 +- tools/web/run-outliner-headed.mjs | 1 + web/app/src/app/App.tsx | 171 +++++++++++++++--- .../e2e/outliner-headed-production.spec.ts | 77 +++++++- 4 files changed, 215 insertions(+), 36 deletions(-) diff --git a/tools/web/check-outliner-headed.mjs b/tools/web/check-outliner-headed.mjs index e2c0df746..674513f04 100644 --- a/tools/web/check-outliner-headed.mjs +++ b/tools/web/check-outliner-headed.mjs @@ -19,7 +19,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); -const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web", "outliner-collection-new-web", "outliner-collection-select-web", "outliner-object-select-web", "outliner-collection-duplicate-web", "outliner-collection-instance-web", "outliner-collection-color-tag-web", "outliner-view-ops-web", "outliner-show-active-web", "outliner-collection-visibility-web", "outliner-collection-view-layer-web", "outliner-collection-link-web", "outliner-select-linked-web", "outliner-edit-menu-web", "outliner-collection-view-layer-gate-web", "outliner-filter-collection-toggle-web", "outliner-id-data-submenu-web", "outliner-menu-separators-web", "outliner-relocate-web", "outliner-liboverride-troubleshoot-web", "outliner-filter-options-web", "outliner-header-controls-web", "outliner-row-type-menus-web"]; +const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web", "outliner-mode-dot-web", "outliner-rename-bone-web", "outliner-eyedropper-web", "outliner-fake-user-purge-web", "outliner-asset-ops-web", "outliner-liboverride-web", "outliner-make-local-web", "outliner-select-hierarchy-web", "outliner-delete-hierarchy-web", "outliner-collection-new-web", "outliner-collection-select-web", "outliner-object-select-web", "outliner-collection-duplicate-web", "outliner-collection-instance-web", "outliner-collection-color-tag-web", "outliner-view-ops-web", "outliner-show-active-web", "outliner-collection-visibility-web", "outliner-collection-view-layer-web", "outliner-collection-link-web", "outliner-select-linked-web", "outliner-edit-menu-web", "outliner-collection-view-layer-gate-web", "outliner-filter-collection-toggle-web", "outliner-id-data-submenu-web", "outliner-menu-separators-web", "outliner-relocate-web", "outliner-liboverride-troubleshoot-web", "outliner-filter-options-web", "outliner-header-controls-web", "outliner-row-type-menus-web", "outliner-menu-structure-web"]; /* Desktop Layout geometry the metrics case must reproduce (batch 2: UI sizes). */ const GEOMETRY_GOLDEN = path.join(REPO_ROOT, "tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json"); const errors = []; diff --git a/tools/web/run-outliner-headed.mjs b/tools/web/run-outliner-headed.mjs index f1380a3e6..88ab9c5db 100644 --- a/tools/web/run-outliner-headed.mjs +++ b/tools/web/run-outliner-headed.mjs @@ -75,6 +75,7 @@ const KNOWN_CASES = [ { id: "outliner-relocate-web", title: /\[outliner-relocate-web\]/ }, { id: "outliner-liboverride-troubleshoot-web", title: /\[outliner-liboverride-troubleshoot-web\]/ }, { id: "outliner-row-type-menus-web", title: /\[outliner-row-type-menus-web\]/ }, + { id: "outliner-menu-structure-web", title: /\[outliner-menu-structure-web\]/ }, ]; function usage() { diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 91692d8a6..b0e2bbde6 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -2835,30 +2835,6 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onToggleExpa * offers New Collection and Paste Data-Blocks, then draw_common_operators * appends the asset, library override and view groups (the Area submenu is * desktop window management and is not offered in the browser). */ - const emptyAreaItems: DesktopMenuItem[] = [ - ...(tree?.displayMode === 'VIEW_LAYER' ? [ - {label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !workspace?.writable, reason: '在主集合内新建集合(桌面 OUTLINER_MT_collection_new,nested=True 回退主集合)', action: () => { if (nativeArea) onIdOperation?.('', 'COLLECTION_NEW', nativeArea.id); }}, - {label: '粘贴数据块 (Paste Data-Blocks)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !workspace?.writable, reason: '把内部剪贴板中的数据块粘贴到主集合(桌面 outliner.id_paste)', action: () => { if (nativeArea) onIdOperation?.('', 'PASTE', nativeArea.id); }}, - {label: '', separator: true}, - ] : []), - ...(tree?.displayMode !== 'SEQUENCE' && tree?.displayMode !== 'LIBRARY_OVERRIDES' ? [{label: '资产', reason: '桌面 draw_common_operators 的资产组(ASSET_OT_mark/clear,作用于选中的数据块)', children: [ - {label: '标记为资产 (Mark as Asset)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.asset !== false || menuTarget.assetSupported !== true || !workspace?.writable, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'ASSET_MARK', nativeArea.id); }}, - {label: '清除资产 (Clear Asset)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.asset !== true || menuTarget.assetSupported !== true || !workspace?.writable, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'ASSET_CLEAR', nativeArea.id); }}, - {label: '清除资产(设置伪用户)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.asset !== true || menuTarget.assetSupported !== true || !workspace?.writable, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'ASSET_CLEAR_FAKE', nativeArea.id); }}, - ]}] : []), - {label: '库覆盖', reason: '桌面 draw_common_operators 的库覆盖组(outliner.liboverride_operation,selection_set=SELECTED)', children: [ - {label: '创建库覆盖 (Make Library Override)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.linked !== true || !workspace?.writable, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LIBOVERRIDE_MAKE', nativeArea.id); }}, - {label: '重置库覆盖 (Reset Library Override)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.libraryOverride !== true || !workspace?.writable, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LIBOVERRIDE_RESET', nativeArea.id); }}, - {label: '清除库覆盖 (Clear Library Override)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.libraryOverride !== true || !workspace?.writable, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LIBOVERRIDE_CLEAR', nativeArea.id); }}, - ]}, - {label: '视图 (View)', disabled: treeRenameBusy || remapBusy || !onViewOperation || !nativeArea, reason: '树形显示操作(桌面 OUTLINER_MT_context_menu_view)', children: [ - {label: '显示活动 (Show Active)', action: () => { if (nativeArea) onViewOperation?.('SHOW_ACTIVE', nativeArea.id); }}, - {label: '展开/折叠全部 (Expand/Collapse All)', action: () => { if (nativeArea) onViewOperation?.('EXPANDED_TOGGLE', nativeArea.id); }}, - {label: '显示层级 (Show Object Hierarchy)', action: () => { if (nativeArea) onViewOperation?.('SHOW_HIERARCHY', nativeArea.id); }}, - {label: '展开一层 (Show One Level)', action: () => { if (nativeArea) onViewOperation?.('SHOW_ONE_LEVEL', nativeArea.id); }}, - {label: '折叠一层 (Hide One Level)', action: () => { if (nativeArea) onViewOperation?.('HIDE_ONE_LEVEL', nativeArea.id); }}, - ]}, - ]; const sourceIDs = remap ? tree?.remapIds?.filter(id => id.id === remap.oldId) ?? [] : []; const sourceID = sourceIDs.length === 1 ? sourceIDs[0] : undefined; const choices = sourceID ? tree?.remapIds?.filter(id => id.idType === sourceID.idType && id.id !== sourceID.id) ?? [] : []; @@ -2892,6 +2868,151 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onToggleExpa } catch (error) { setRemapFeedback(error instanceof Error ? error.message : String(error)); } finally { remapPending.current = false; setRemapBusy(false); } }; + /* Desktop space_outliner.py menus: OUTLINER_MT_object and OUTLINER_MT_collection + * share the ID Data, visibility, view-layer, asset, library override and view + * groups. The row-type dispatch below feeds the same builders. */ + const colorTagItems: DesktopMenuItem[] = [ + {label: '无颜色 (None)', checked: (menuTarget?.colorTag ?? -1) === -1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'NONE'); }}, + {label: '颜色 01 (Color 01)', checked: (menuTarget?.colorTag ?? -1) === 0, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_01'); }}, + {label: '颜色 02 (Color 02)', checked: (menuTarget?.colorTag ?? -1) === 1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_02'); }}, + {label: '颜色 03 (Color 03)', checked: (menuTarget?.colorTag ?? -1) === 2, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_03'); }}, + {label: '颜色 04 (Color 04)', checked: (menuTarget?.colorTag ?? -1) === 3, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_04'); }}, + {label: '颜色 05 (Color 05)', checked: (menuTarget?.colorTag ?? -1) === 4, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_05'); }}, + {label: '颜色 06 (Color 06)', checked: (menuTarget?.colorTag ?? -1) === 5, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_06'); }}, + {label: '颜色 07 (Color 07)', checked: (menuTarget?.colorTag ?? -1) === 6, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_07'); }}, + {label: '颜色 08 (Color 08)', checked: (menuTarget?.colorTag ?? -1) === 7, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_08'); }}, + ]; + const visibilityItems: DesktopMenuItem[] = [ + {label: '隔离 (Isolate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ISOLATE', nativeArea.id); }}, + {label: '', separator: true}, + {label: '显示 (Show)', disabled: menuTarget?.restrict?.hide !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW', nativeArea.id); }}, + {label: '显示内部 (Show All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW_INSIDE', nativeArea.id); }}, + {label: '隐藏 (Hide)', disabled: menuTarget?.restrict?.hide === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE', nativeArea.id); }}, + {label: '隐藏内部 (Hide All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE_INSIDE', nativeArea.id); }}, + {label: '', separator: true}, + {label: '在视口中启用 (Enable in Viewports)', disabled: menuTarget?.restrict?.viewport !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE', nativeArea.id); }}, + {label: '在视口中禁用 (Disable in Viewports)', disabled: menuTarget?.restrict?.viewport === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE', nativeArea.id); }}, + {label: '', separator: true}, + {label: '在渲染中启用 (Enable in Render)', disabled: menuTarget?.restrict?.render !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE_RENDER', nativeArea.id); }}, + {label: '在渲染中禁用 (Disable in Render)', disabled: menuTarget?.restrict?.render === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE_RENDER', nativeArea.id); }}, + ]; + const viewLayerItems: DesktopMenuItem[] = [ + {label: '排除 (Exclude)', disabled: menuTarget?.restrict?.enable === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_SET', nativeArea.id); }}, + {label: '取消排除 (Clear Exclude)', disabled: menuTarget?.restrict?.enable !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_CLEAR', nativeArea.id); }}, + {label: '阻隔 (Holdout)', disabled: menuTarget?.restrict?.holdout === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_SET', nativeArea.id); }}, + {label: '取消阻隔 (Clear Holdout)', disabled: menuTarget?.restrict?.holdout !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_CLEAR', nativeArea.id); }}, + ...(outlinerEngineIsCycles ? [{label: '仅间接贡献 (Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_SET', nativeArea.id); }}, {label: '取消仅间接贡献 (Clear Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_CLEAR', nativeArea.id); }}] : []), + ]; + const idDataItems: DesktopMenuItem[] = [ + {label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_MT_id_data 的 Unlink)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}, + {label: '本地化 (Make Local)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.linked !== true || !workspace?.writable, reason: '把所选链接数据块复制为本地数据块(桌面 OUTLINER_OT_id_operation LOCAL)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LOCAL', nativeArea.id); }}, + {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, + {label: 'Remap Users', + disabled: remapBusy || treeRenameBusy || !onRemap || !workspace?.writable || !menuTarget?.remapId || + tree?.remapIds?.filter(id => id.id === menuTarget.remapId).length !== 1, + reason: 'Remap all local usages of this data-block to another one of the same type', action: () => openRemap()}, + {label: '', separator: true}, + {label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, + {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, + {label: '', separator: true}, + {label: '添加伪用户 (Add Fake User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.fakeUser !== false || !workspace?.writable, reason: '确保数据块即使未使用也会保存(桌面 outliner.id_operation ADD_FAKE)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'FAKE_ADD', nativeArea.id); }}, + {label: '清除伪用户 (Clear Fake User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.fakeUser !== true || !workspace?.writable, reason: '清除数据块的伪用户标记(桌面 outliner.id_operation CLEAR_FAKE)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'FAKE_CLEAR', nativeArea.id); }}, + {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, + {label: '选择链接 (Select Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '选中共享同一数据块的全部对象(桌面 OUTLINER_IDOP_SELECT_LINKED)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT_LINKED', nativeArea.id); }}, + ...(menuTarget?.linked === true && onRelocate && nativeArea ? [{label: '', separator: true}, {label: 'Relocate(重新定位链接数据)', disabled: treeRenameBusy || remapBusy || !workspace?.writable, reason: '选择另一个库中的数据块替换该链接数据块(桌面 OUTLINER_MT_id_data 的 Relocate → OUTLINER_OT_id_linked_relocate)', action: () => { if (menuTarget && nativeArea) onRelocate?.(menuTarget.id, nativeArea.id); }}] : []), + ]; + const assetItems: DesktopMenuItem[] = [ + {label: '标记为资产 (Mark as Asset)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.asset !== false || menuTarget.assetSupported !== true || !workspace?.writable, reason: '把所选数据块标记为资产(桌面 asset.mark)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'ASSET_MARK', nativeArea.id); }}, + {label: '清除资产 (Clear Asset)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.asset !== true || menuTarget.assetSupported !== true || !workspace?.writable, reason: '删除资产元数据并转回普通数据块(桌面 asset.clear)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'ASSET_CLEAR', nativeArea.id); }}, + {label: '清除资产(设置伪用户)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.asset !== true || menuTarget.assetSupported !== true || !workspace?.writable, reason: '清除资产并设置伪用户以继续保存(桌面 asset.clear set_fake_user=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'ASSET_CLEAR_FAKE', nativeArea.id); }}, + ]; + const libOverrideItems: DesktopMenuItem[] = [ + {label: '创建库覆盖 (Make Library Override)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.linked !== true || !workspace?.writable, reason: '为所选链接数据块创建本地库覆盖(桌面 outliner.liboverride_operation type=OVERRIDE_LIBRARY_CREATE_HIERARCHY)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LIBOVERRIDE_MAKE', nativeArea.id); }}, + {label: '重置库覆盖 (Reset Library Override)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.libraryOverride !== true || !workspace?.writable, reason: '把所选覆盖重置为链接参考值(桌面 type=OVERRIDE_LIBRARY_RESET)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LIBOVERRIDE_RESET', nativeArea.id); }}, + {label: '清除库覆盖 (Clear Library Override)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || menuTarget.libraryOverride !== true || !workspace?.writable, reason: '删除所选覆盖并重新链接到库数据块(桌面 type=OVERRIDE_LIBRARY_CLEAR_SINGLE)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'LIBOVERRIDE_CLEAR', nativeArea.id); }}, + ...(menuTarget?.libraryOverride === true && onLiboverrideTroubleshoot && nativeArea ? [{label: '', separator: true}, {label: '库覆盖排查 (Troubleshoot)', reason: '桌面 OUTLINER_MT_liboverride 末尾的 Troubleshoot 枚举菜单(outliner.liboverride_troubleshoot_operation,selection_set=SELECTED)', children: [ + {label: '重同步 (Resync)', disabled: treeRenameBusy || remapBusy || !workspace?.writable, reason: '从链接参考重建所选覆盖及其依赖层级(桌面 type=OVERRIDE_LIBRARY_RESYNC_HIERARCHY)', action: () => { if (menuTarget && nativeArea) onLiboverrideTroubleshoot?.(menuTarget.id, 'OVERRIDE_LIBRARY_RESYNC_HIERARCHY', nativeArea.id); }}, + {label: '重同步(强制)(Resync Enforce)', disabled: treeRenameBusy || remapBusy || !workspace?.writable, reason: '强制重建并让覆盖层级匹配链接数据(桌面 type=OVERRIDE_LIBRARY_RESYNC_HIERARCHY_ENFORCE)', action: () => { if (menuTarget && nativeArea) onLiboverrideTroubleshoot?.(menuTarget.id, 'OVERRIDE_LIBRARY_RESYNC_HIERARCHY_ENFORCE', nativeArea.id); }}, + {label: '', separator: true}, + {label: '删除 (Delete)', disabled: treeRenameBusy || remapBusy || !workspace?.writable, reason: '删除所选覆盖及层级并重新链接库数据块(桌面 type=OVERRIDE_LIBRARY_DELETE_HIERARCHY)', action: () => { if (menuTarget && nativeArea) onLiboverrideTroubleshoot?.(menuTarget.id, 'OVERRIDE_LIBRARY_DELETE_HIERARCHY', nativeArea.id); }}, + ]}] : []), + ]; + const viewItems: DesktopMenuItem[] = [ + {label: '显示活动 (Show Active)', action: () => { if (nativeArea) onViewOperation?.('SHOW_ACTIVE', nativeArea.id); }}, + {label: '', separator: true}, + {label: '展开/折叠全部 (Expand/Collapse All)', action: () => { if (nativeArea) onViewOperation?.('EXPANDED_TOGGLE', nativeArea.id); }}, + {label: '显示层级 (Show Object Hierarchy)', action: () => { if (nativeArea) onViewOperation?.('SHOW_HIERARCHY', nativeArea.id); }}, + {label: '展开一层 (Show One Level)', action: () => { if (nativeArea) onViewOperation?.('SHOW_ONE_LEVEL', nativeArea.id); }}, + {label: '折叠一层 (Hide One Level)', action: () => { if (nativeArea) onViewOperation?.('HIDE_ONE_LEVEL', nativeArea.id); }}, + ]; + const unlinkRowItem: DesktopMenuItem = {label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}; + const copyPasteItems: DesktopMenuItem[] = [ + {label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, + {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, + ]; + const assetVisible = tree?.displayMode !== 'SEQUENCE' && tree?.displayMode !== 'LIBRARY_OVERRIDES'; + const commonGroups: DesktopMenuItem[] = [ + ...(assetVisible ? [...assetItems, {label: '', separator: true}] : []), + {label: '库覆盖 (Library Override)', reason: '桌面 OUTLINER_MT_liboverride(Make / Reset / Clear 与 Troubleshoot)', children: libOverrideItems}, + {label: '', separator: true}, + {label: '视图 (View)', disabled: treeRenameBusy || remapBusy || !onViewOperation || !nativeArea, reason: '树形显示操作(桌面 OUTLINER_MT_context_menu_view)', children: viewItems}, + ]; + /* Desktop OUTLINER_MT_context_menu on empty tree space: the View Layer mode + * offers New Collection and Paste Data-Blocks, then draw_common_operators + * appends the asset, library override and view groups (the Area submenu is + * desktop window management and is not offered in the browser). */ + const emptyAreaItems: DesktopMenuItem[] = [ + ...(tree?.displayMode === 'VIEW_LAYER' ? [ + {label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !workspace?.writable, reason: '在主集合内新建集合(桌面 OUTLINER_MT_collection_new,nested=True 回退主集合)', action: () => { if (nativeArea) onIdOperation?.('', 'COLLECTION_NEW', nativeArea.id); }}, + {label: '粘贴数据块 (Paste Data-Blocks)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !workspace?.writable, reason: '把内部剪贴板中的数据块粘贴到主集合(桌面 outliner.id_paste)', action: () => { if (nativeArea) onIdOperation?.('', 'PASTE', nativeArea.id); }}, + {label: '', separator: true}, + ] : []), + ...commonGroups, + ]; + /* Desktop OUTLINER_MT_object (space_outliner.py:326-362). */ + const objectMenuItems: DesktopMenuItem[] = [ + ...copyPasteItems, + {label: '', separator: true}, + {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, + {label: '删除层级 (Delete Hierarchy)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象及其全部子级(桌面 OUTLINER_OT_delete hierarchy=True)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId, true); }}, + {label: '', separator: true}, + {label: '选择 (Select)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '选中所选对象行对应的对象(桌面 OUTLINER_OT_object_operation type=SELECT)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT', nativeArea.id); }}, + {label: '选择层级 (Select Hierarchy)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '选择所选对象及其全部子级(桌面 OUTLINER_OT_object_operation type=SELECT_HIERARCHY)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT_HIERARCHY', nativeArea.id); }}, + {label: '取消选择 (Deselect)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '取消所选对象行对应对象的选择(桌面 OUTLINER_OT_object_operation type=DESELECT)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'DESELECT', nativeArea.id); }}, + {label: '', separator: true}, + ...(tree?.displayMode === 'VIEW_LAYER' && tree?.filter?.showCollections === false ? [] : [unlinkRowItem, {label: '', separator: true}]), + {label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '在所选对象所在的集合内新建子集合(桌面 OUTLINER_OT_collection_new nested=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_NEW', nativeArea.id); }}, + {label: '', separator: true}, + {label: 'ID Data', reason: '桌面 OUTLINER_MT_id_data:outliner.id_operation 枚举与重命名/重映射入口', children: idDataItems}, + {label: '', separator: true}, + ...commonGroups, + ]; + /* Desktop OUTLINER_MT_collection (space_outliner.py:255-305). */ + const collectionMenuItems: DesktopMenuItem[] = [ + {label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '在所选集合内新建子集合(桌面 OUTLINER_OT_collection_new nested=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_NEW', nativeArea.id); }}, + {label: '复制集合 (Duplicate Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合及其全部子集合、对象与对象数据(桌面 OUTLINER_OT_collection_duplicate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE', nativeArea.id); }}, + {label: '复制链接 (Duplicate Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合与对象,但对象数据保持链接(桌面 OUTLINER_OT_collection_duplicate_linked)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE_LINKED', nativeArea.id); }}, + ...copyPasteItems, + {label: '', separator: true}, + {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, + {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }}, + {label: '', separator: true}, + {label: '选择对象 (Select Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '选中该集合内的全部对象(桌面 OUTLINER_OT_collection_objects_select)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SELECT', nativeArea.id); }}, + {label: '取消选择对象 (Deselect Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '取消该集合内全部对象的选择(桌面 OUTLINER_OT_collection_objects_deselect)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DESELECT', nativeArea.id); }}, + {label: '', separator: true}, + {label: '实例化到场景 (Instance to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合实例化为活动场景中的空物体(桌面 OUTLINER_OT_collection_instance)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INSTANCE', nativeArea.id); }}, + ...(tree?.displayMode && tree.displayMode !== 'VIEW_LAYER' ? [{label: '链接到场景 (Link to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合链接到当前场景的活动集合(桌面 OUTLINER_OT_collection_link)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_LINK', nativeArea.id); }}] : []), + unlinkRowItem, + {label: '', separator: true}, + {label: '可见性 (Visibility)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合可见性操作(桌面 OUTLINER_MT_collection_visibility)', children: visibilityItems}, + ...(tree?.displayMode === 'VIEW_LAYER' ? [{label: '', separator: true}, {label: '视图层 (View Layer)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合在视图层中的状态(桌面 OUTLINER_MT_collection_view_layer)', children: viewLayerItems}] : []), + {label: '', separator: true}, + {label: '颜色标签 (Color Tag)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '为所选集合设置颜色标签(桌面 OUTLINER_MT_collection 的 collection_color_tag_set 色块)', children: colorTagItems}, + {label: '', separator: true}, + {label: 'ID Data', reason: '桌面 OUTLINER_MT_id_data:outliner.id_operation 枚举与重命名/重映射入口', children: idDataItems}, + {label: '', separator: true}, + ...commonGroups, + ]; if (workflow) return
{ /* Desktop OUTLINER_MT_context_menu: right-click anywhere in the region @@ -2908,7 +3029,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onToggleExpa {/* Desktop OUTLINER_HT_header: library override view mode selector. */} {onSetLibOverrideViewMode && tree?.displayMode === 'LIBRARY_OVERRIDES' ? : null} { setMenuRow(null); setDataMenu(!dataMenu); }} - onClose={() => setDataMenu(false)} items={menuRow != null && menuTarget?.kind === 'library' ? libraryRowItems : menuRow != null && menuTarget?.kind === 'scene' ? sceneRowItems : [{label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除层级 (Delete Hierarchy)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象及其全部子级(桌面 OUTLINER_OT_delete hierarchy=True)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId, true); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }}, {label: '', separator: true}, {label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '在所选集合内新建子集合,选中对象行时建在主集合内(桌面 OUTLINER_OT_collection_new nested=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_NEW', nativeArea.id); }}, {label: '复制集合 (Duplicate Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合及其全部子集合、对象与对象数据(桌面 OUTLINER_OT_collection_duplicate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE', nativeArea.id); }}, {label: '复制链接 (Duplicate Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合与对象,但对象数据保持链接(桌面 OUTLINER_OT_collection_duplicate_linked)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE_LINKED', nativeArea.id); }}, {label: '实例化到场景 (Instance to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合实例化为活动场景中的空物体(桌面 OUTLINER_OT_collection_instance)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INSTANCE', nativeArea.id); }}, /* Desktop draws Link to Scene only outside the View Layer mode (space_outliner.py OUTLINER_MT_collection). */ ...(tree?.displayMode && tree.displayMode !== 'VIEW_LAYER' ? [{label: '链接到场景 (Link to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合链接到当前场景的活动集合(桌面 OUTLINER_OT_collection_link)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_LINK', nativeArea.id); }}] : []), {label: '颜色标签 (Color Tag)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '为所选集合设置颜色标签(桌面 OUTLINER_MT_collection 的 collection_color_tag_set 色块)', children: [{label: '无颜色 (None)', checked: (menuTarget?.colorTag ?? -1) === -1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'NONE'); }}, {label: '颜色 01 (Color 01)', checked: (menuTarget?.colorTag ?? -1) === 0, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_01'); }}, {label: '颜色 02 (Color 02)', checked: (menuTarget?.colorTag ?? -1) === 1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_02'); }}, {label: '颜色 03 (Color 03)', checked: (menuTarget?.colorTag ?? -1) === 2, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_03'); }}, {label: '颜色 04 (Color 04)', checked: (menuTarget?.colorTag ?? -1) === 3, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_04'); }}, {label: '颜色 05 (Color 05)', checked: (menuTarget?.colorTag ?? -1) === 4, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_05'); }}, {label: '颜色 06 (Color 06)', checked: (menuTarget?.colorTag ?? -1) === 5, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_06'); }}, {label: '颜色 07 (Color 07)', checked: (menuTarget?.colorTag ?? -1) === 6, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_07'); }}, {label: '颜色 08 (Color 08)', checked: (menuTarget?.colorTag ?? -1) === 7, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_08'); }}]}, {label: '可见性 (Visibility)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合可见性操作(桌面 OUTLINER_MT_collection_visibility)', children: [{label: '隔离 (Isolate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ISOLATE', nativeArea.id); }}, {label: '显示 (Show)', disabled: menuTarget?.restrict?.hide !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW', nativeArea.id); }}, {label: '显示内部 (Show All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW_INSIDE', nativeArea.id); }}, {label: '隐藏 (Hide)', disabled: menuTarget?.restrict?.hide === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE', nativeArea.id); }}, {label: '隐藏内部 (Hide All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE_INSIDE', nativeArea.id); }}, {label: '在视口中启用 (Enable in Viewports)', disabled: menuTarget?.restrict?.viewport !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE', nativeArea.id); }}, {label: '在视口中禁用 (Disable in Viewports)', disabled: menuTarget?.restrict?.viewport === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE', nativeArea.id); }}, {label: '在渲染中启用 (Enable in Render)', disabled: menuTarget?.restrict?.render !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE_RENDER', nativeArea.id); }}, {label: '在渲染中禁用 (Disable in Render)', disabled: menuTarget?.restrict?.render === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE_RENDER', nativeArea.id); }},]}, ...(tree?.displayMode === 'VIEW_LAYER' ? [{label: '视图层 (View Layer)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合在视图层中的状态(桌面 OUTLINER_MT_collection_view_layer)', children: [{label: '排除 (Exclude)', disabled: menuTarget?.restrict?.enable === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_SET', nativeArea.id); }}, {label: '取消排除 (Clear Exclude)', disabled: menuTarget?.restrict?.enable !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_CLEAR', nativeArea.id); }}, {label: '阻隔 (Holdout)', disabled: menuTarget?.restrict?.holdout === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_SET', nativeArea.id); }}, {label: '取消阻隔 (Clear Holdout)', disabled: menuTarget?.restrict?.holdout !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_CLEAR', nativeArea.id); }}, ...(outlinerEngineIsCycles ? [{label: '仅间接贡献 (Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_SET', nativeArea.id); }}, {label: '取消仅间接贡献 (Clear Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_CLEAR', nativeArea.id); }}] : []),]}] : []), {label: '', separator: true}, {label: '选择对象 (Select Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '选中该集合内的全部对象(桌面 OUTLINER_OT_collection_objects_select)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SELECT', nativeArea.id); }}, {label: '取消选择对象 (Deselect Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '取消该集合内全部对象的选择(桌面 OUTLINER_OT_collection_objects_deselect)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DESELECT', nativeArea.id); }},...(tree?.displayMode === 'VIEW_LAYER' && tree?.filter?.showCollections === false ? [] : [{label: '', separator: true}, {label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}]), /* Desktop's object menu block (space_outliner.py OUTLINER_MT_object): + onClose={() => setDataMenu(false)} items={menuRow != null && menuTarget?.kind === 'library' ? libraryRowItems : menuRow != null && menuTarget?.kind === 'scene' ? sceneRowItems : menuTarget?.kind === 'object' ? objectMenuItems : menuTarget?.kind === 'collection' ? collectionMenuItems : [{label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除层级 (Delete Hierarchy)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象及其全部子级(桌面 OUTLINER_OT_delete hierarchy=True)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId, true); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }}, {label: '', separator: true}, {label: '新建集合 (New Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '在所选集合内新建子集合,选中对象行时建在主集合内(桌面 OUTLINER_OT_collection_new nested=True)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_NEW', nativeArea.id); }}, {label: '复制集合 (Duplicate Collection)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合及其全部子集合、对象与对象数据(桌面 OUTLINER_OT_collection_duplicate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE', nativeArea.id); }}, {label: '复制链接 (Duplicate Linked)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '递归复制该集合与对象,但对象数据保持链接(桌面 OUTLINER_OT_collection_duplicate_linked)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DUPLICATE_LINKED', nativeArea.id); }}, {label: '实例化到场景 (Instance to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合实例化为活动场景中的空物体(桌面 OUTLINER_OT_collection_instance)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INSTANCE', nativeArea.id); }}, /* Desktop draws Link to Scene only outside the View Layer mode (space_outliner.py OUTLINER_MT_collection). */ ...(tree?.displayMode && tree.displayMode !== 'VIEW_LAYER' ? [{label: '链接到场景 (Link to Scene)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '把所选集合链接到当前场景的活动集合(桌面 OUTLINER_OT_collection_link)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_LINK', nativeArea.id); }}] : []), {label: '颜色标签 (Color Tag)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '为所选集合设置颜色标签(桌面 OUTLINER_MT_collection 的 collection_color_tag_set 色块)', children: [{label: '无颜色 (None)', checked: (menuTarget?.colorTag ?? -1) === -1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'NONE'); }}, {label: '颜色 01 (Color 01)', checked: (menuTarget?.colorTag ?? -1) === 0, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_01'); }}, {label: '颜色 02 (Color 02)', checked: (menuTarget?.colorTag ?? -1) === 1, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_02'); }}, {label: '颜色 03 (Color 03)', checked: (menuTarget?.colorTag ?? -1) === 2, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_03'); }}, {label: '颜色 04 (Color 04)', checked: (menuTarget?.colorTag ?? -1) === 3, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_04'); }}, {label: '颜色 05 (Color 05)', checked: (menuTarget?.colorTag ?? -1) === 4, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_05'); }}, {label: '颜色 06 (Color 06)', checked: (menuTarget?.colorTag ?? -1) === 5, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_06'); }}, {label: '颜色 07 (Color 07)', checked: (menuTarget?.colorTag ?? -1) === 6, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_07'); }}, {label: '颜色 08 (Color 08)', checked: (menuTarget?.colorTag ?? -1) === 7, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_COLOR_TAG', nativeArea.id, 'COLOR_08'); }}]}, {label: '可见性 (Visibility)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合可见性操作(桌面 OUTLINER_MT_collection_visibility)', children: [{label: '隔离 (Isolate)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ISOLATE', nativeArea.id); }}, {label: '显示 (Show)', disabled: menuTarget?.restrict?.hide !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW', nativeArea.id); }}, {label: '显示内部 (Show All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SHOW_INSIDE', nativeArea.id); }}, {label: '隐藏 (Hide)', disabled: menuTarget?.restrict?.hide === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE', nativeArea.id); }}, {label: '隐藏内部 (Hide All Inside)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HIDE_INSIDE', nativeArea.id); }}, {label: '在视口中启用 (Enable in Viewports)', disabled: menuTarget?.restrict?.viewport !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE', nativeArea.id); }}, {label: '在视口中禁用 (Disable in Viewports)', disabled: menuTarget?.restrict?.viewport === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE', nativeArea.id); }}, {label: '在渲染中启用 (Enable in Render)', disabled: menuTarget?.restrict?.render !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_ENABLE_RENDER', nativeArea.id); }}, {label: '在渲染中禁用 (Disable in Render)', disabled: menuTarget?.restrict?.render === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DISABLE_RENDER', nativeArea.id); }},]}, ...(tree?.displayMode === 'VIEW_LAYER' ? [{label: '视图层 (View Layer)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '集合在视图层中的状态(桌面 OUTLINER_MT_collection_view_layer)', children: [{label: '排除 (Exclude)', disabled: menuTarget?.restrict?.enable === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_SET', nativeArea.id); }}, {label: '取消排除 (Clear Exclude)', disabled: menuTarget?.restrict?.enable !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_EXCLUDE_CLEAR', nativeArea.id); }}, {label: '阻隔 (Holdout)', disabled: menuTarget?.restrict?.holdout === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_SET', nativeArea.id); }}, {label: '取消阻隔 (Clear Holdout)', disabled: menuTarget?.restrict?.holdout !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_HOLDOUT_CLEAR', nativeArea.id); }}, ...(outlinerEngineIsCycles ? [{label: '仅间接贡献 (Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly === true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_SET', nativeArea.id); }}, {label: '取消仅间接贡献 (Clear Indirect Only)', disabled: menuTarget?.restrict?.indirectOnly !== true, action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_INDIRECT_ONLY_CLEAR', nativeArea.id); }}] : []),]}] : []), {label: '', separator: true}, {label: '选择对象 (Select Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '选中该集合内的全部对象(桌面 OUTLINER_OT_collection_objects_select)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_SELECT', nativeArea.id); }}, {label: '取消选择对象 (Deselect Objects)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.collectionId ?? menuTarget.remapId) || !workspace?.writable, reason: '取消该集合内全部对象的选择(桌面 OUTLINER_OT_collection_objects_deselect)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COLLECTION_DESELECT', nativeArea.id); }},...(tree?.displayMode === 'VIEW_LAYER' && tree?.filter?.showCollections === false ? [] : [{label: '', separator: true}, {label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}]), /* Desktop's object menu block (space_outliner.py OUTLINER_MT_object): * Select, Select Hierarchy and Deselect run on the outliner selection. */ {label: '', separator: true}, {label: '选择 (Select)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget?.objectId || !workspace?.writable, reason: '选中所选对象行对应的对象(桌面 OUTLINER_OT_object_operation type=SELECT)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'SELECT', nativeArea.id); }}, diff --git a/web/tests/e2e/outliner-headed-production.spec.ts b/web/tests/e2e/outliner-headed-production.spec.ts index 0f43b90b3..67e9c441b 100644 --- a/web/tests/e2e/outliner-headed-production.spec.ts +++ b/web/tests/e2e/outliner-headed-production.spec.ts @@ -758,7 +758,13 @@ test.describe("Outliner headed baseline", () => { const make = page.getByRole("menuitem", { name: "创建库覆盖 (Make Library Override)", exact: true }); const reset = page.getByRole("menuitem", { name: "重置库覆盖 (Reset Library Override)", exact: true }); const clear = page.getByRole("menuitem", { name: "清除库覆盖 (Clear Library Override)", exact: true }); - await overrideRow.locator(".tree-node-name").first().click({ button: "right" }); + /* Desktop draws OUTLINER_MT_liboverride as a submenu (space_outliner.py); + * the three operations live under it. */ + const openOverrideMenu = async () => { + await overrideRow.locator(".tree-node-name").first().click({ button: "right" }); + await page.getByRole("menuitem", { name: "库覆盖 (Library Override)", exact: true }).click(); + }; + await openOverrideMenu(); await expect(reset).toBeEnabled(); await expect(clear).toBeEnabled(); /* Only linked references can be overridden; an existing override cannot. */ @@ -767,7 +773,7 @@ test.describe("Outliner headed baseline", () => { await expect(status).toContainText("已重置库覆盖", { timeout: 30_000 }); await expect(overrideRow).toBeVisible(); - await overrideRow.locator(".tree-node-name").first().click({ button: "right" }); + await openOverrideMenu(); await clear.click(); await expect(status).toContainText("已清除库覆盖", { timeout: 30_000 }); /* Clearing drops the local override and relinks the library original, so @@ -1487,9 +1493,10 @@ test.describe("Outliner headed baseline", () => { } await expect(page.getByRole("menuitem", { name: "‹ ID Data", exact: true })).toHaveCount(1); - /* The moved operations no longer sit in the flat menu. */ + /* Back in the collection menu: the desktop object/collection menus carry + * their own top-level Copy/Paste next to the ID Data submenu. */ await page.getByRole("menuitem", { name: "‹ ID Data", exact: true }).click(); - await expect(page.getByRole("menuitem", { name: "复制", exact: true })).toHaveCount(0); + await expect(page.getByRole("menuitem", { name: "复制", exact: true })).toHaveCount(1); await expect(page.getByRole("menuitem", { name: "标记为资产 (Mark as Asset)", exact: true })).toHaveCount(1); }); @@ -1505,14 +1512,15 @@ test.describe("Outliner headed baseline", () => { await expect(partsRow).toBeVisible({ timeout: 30_000 }); await partsRow.locator(".tree-node-name").first().click({ button: "right" }); - /* Desktop space_outliner.py groups the menu with separators: New/Duplicate | - * Delete | Select Objects | Instance/Link/Unlink | Visibility | [View Layer] - * | Color Tag | ID Data | …; the web Data menu keeps the same boundaries. */ + /* Desktop OUTLINER_MT_collection groups the menu with separators: + * New/Duplicate/Copy/Paste | Delete | Select Objects | Instance/Unlink | + * Visibility | [View Layer] | Color Tag | ID Data | assets | overrides | + * View; the web Data menu keeps the same boundaries. */ const panel = page.locator(".desktop-menu-panel").first(); await expect(page.getByRole("menuitem", { name: "视图 (View)", exact: true })).toHaveCount(1, { timeout: 15_000 }); const sequence: string[] = await panel.evaluate((el) => Array.from(el.children).map((child) => child.getAttribute("role") === "separator" ? "|" : (child.getAttribute("aria-label") ?? ""))); - expect(sequence.filter((entry) => entry === "|")).toHaveLength(8); - for (const [above, below] of [["删除层级", "新建集合 (New Collection)"], ["视图层 (View Layer)", "选择对象 (Select Objects)"], ["取消选择对象 (Deselect Objects)", "取消链接"], ["取消链接", "选择 (Select)"], ["取消选择 (Deselect)", "ID Data"], ["ID Data", "标记为资产 (Mark as Asset)"], ["清除资产(设置伪用户)", "创建库覆盖 (Make Library Override)"], ["清除库覆盖 (Clear Library Override)", "视图 (View)"]]) { + expect(sequence.filter((entry) => entry === "|")).toHaveLength(10); + for (const [above, below] of [["粘贴", "删除集合"], ["删除层级", "选择对象 (Select Objects)"], ["取消选择对象 (Deselect Objects)", "实例化到场景 (Instance to Scene)"], ["取消链接", "可见性 (Visibility)"], ["可见性 (Visibility)", "视图层 (View Layer)"], ["视图层 (View Layer)", "颜色标签 (Color Tag)"], ["颜色标签 (Color Tag)", "ID Data"], ["ID Data", "标记为资产 (Mark as Asset)"], ["清除资产(设置伪用户)", "库覆盖 (Library Override)"], ["库覆盖 (Library Override)", "视图 (View)"]]) { const boundary = sequence.findIndex((entry, index) => entry === "|" && sequence[index - 1] === above && sequence[index + 1] === below); expect(boundary, `${above} | ${below}`).toBeGreaterThan(0); } @@ -1607,6 +1615,7 @@ test.describe("Outliner headed baseline", () => { /* Desktop OUTLINER_MT_liboverride ends with Troubleshoot: * Resync | Resync Enforce | separator | Delete. */ await overrideRow.locator(".tree-node-name").first().click({ button: "right" }); + await page.getByRole("menuitem", { name: "库覆盖 (Library Override)", exact: true }).click(); const troubleshoot = page.getByRole("menuitem", { name: "库覆盖排查 (Troubleshoot)", exact: true }); await expect(troubleshoot).toHaveCount(1, { timeout: 15_000 }); await troubleshoot.click(); @@ -1620,6 +1629,7 @@ test.describe("Outliner headed baseline", () => { /* Delete removes the override hierarchy and relinks the usage to the * linked data-block, so the Current File object row disappears. */ await overrideRow.locator(".tree-node-name").first().click({ button: "right" }); + await page.getByRole("menuitem", { name: "库覆盖 (Library Override)", exact: true }).click(); await page.getByRole("menuitem", { name: "库覆盖排查 (Troubleshoot)", exact: true }).click(); await page.getByRole("menuitem", { name: "删除 (Delete)", exact: true }).click(); await expect(status).toContainText("已删除库覆盖层级", { timeout: 30_000 }); @@ -1821,7 +1831,7 @@ test.describe("Outliner headed baseline", () => { * right-click target, so dispatch the contextmenu on it directly. */ await page.locator(".outliner-content:visible").first() .dispatchEvent("contextmenu", { button: 2, buttons: 2, clientX: 8, clientY: 8 }); - for (const label of ["新建集合 (New Collection)", "粘贴数据块 (Paste Data-Blocks)", "资产", "库覆盖", "视图 (View)"]) { + for (const label of ["新建集合 (New Collection)", "粘贴数据块 (Paste Data-Blocks)", "标记为资产 (Mark as Asset)", "库覆盖 (Library Override)", "视图 (View)"]) { await expect(page.getByRole("menuitem", { name: label, exact: true })).toHaveCount(1, { timeout: 15_000 }); } await page.getByRole("menuitem", { name: "新建集合 (New Collection)", exact: true }).click(); @@ -1868,4 +1878,51 @@ test.describe("Outliner headed baseline", () => { await expect(status).toContainText("已重新加载库", { timeout: 120_000 }); await expect(libraryRow).toBeVisible({ timeout: 30_000 }); }); + + test("[outliner-menu-structure-web] object and collection rows open the desktop menus with top-level copy/paste", async ({ page }) => { + test.setTimeout(240_000); + await openWorkbench(page); + const objectRows = page.locator('.outliner-tree .tree-row[data-node-id]:not([data-node-id=""])'); + await expect.poll(() => objectRows.count(), { timeout: 20_000 }).toBeGreaterThan(0); + const panel = page.locator(".desktop-menu-panel").first(); + const sequence = () => panel.evaluate((el) => Array.from(el.children).map((child) => + child.getAttribute("role") === "separator" ? "|" : (child.getAttribute("aria-label") ?? ""))); + + /* OUTLINER_MT_object starts with top-level Copy/Paste, then Delete, + * Select*, Unlink, New Collection, ID Data and the common groups. */ + const cube = page.locator('.tree-row[aria-label="BasicCube"]').first(); + await cube.locator(".tree-node-name").first().click({ button: "right" }); + await expect(page.getByRole("menuitem", { name: "复制", exact: true })).toHaveCount(1, { timeout: 15_000 }); + const objectSequence = await sequence(); + expect(objectSequence.slice(0, 3)).toEqual(["复制", "粘贴", "|"]); + expect(objectSequence).toContain("删除 (X)"); + expect(objectSequence.indexOf("删除 (X)")).toBeGreaterThan(2); + expect(objectSequence).toContain("选择 (Select)"); + expect(objectSequence).toContain("选择层级 (Select Hierarchy)"); + expect(objectSequence).toContain("取消选择 (Deselect)"); + expect(objectSequence).toContain("ID Data"); + expect(objectSequence).toContain("视图 (View)"); + /* Collection-only entries stay out of the object menu. */ + expect(objectSequence).not.toContain("选择对象 (Select Objects)"); + expect(objectSequence).not.toContain("删除集合"); + + /* The top-level entries run OUTLINER_OT_id_copy/id_paste directly. */ + await page.getByRole("menuitem", { name: "复制", exact: true }).click(); + await expect(page.locator('[data-testid="engine-status"]')).toContainText("已复制数据块", { timeout: 20_000 }); + const before = await objectRows.count(); + await cube.locator(".tree-node-name").first().click({ button: "right" }); + await page.getByRole("menuitem", { name: "粘贴", exact: true }).click(); + await expect.poll(() => objectRows.count(), { timeout: 20_000 }).toBe(before + 1); + + /* OUTLINER_MT_collection starts with New/Duplicate Collection and Copy/ + * Paste, keeps Select Objects, and drops the object-only entries. */ + const collection = page.locator('.tree-row[aria-label="Collection"]').first(); + await collection.locator(".tree-node-name").first().click({ button: "right" }); + await expect(page.getByRole("menuitem", { name: "选择对象 (Select Objects)", exact: true })).toHaveCount(1, { timeout: 15_000 }); + const collectionSequence = await sequence(); + expect(collectionSequence.slice(0, 5)).toEqual(["新建集合 (New Collection)", "复制集合 (Duplicate Collection)", "复制链接 (Duplicate Linked)", "复制", "粘贴"]); + expect(collectionSequence).toContain("选择对象 (Select Objects)"); + expect(collectionSequence).not.toContain("删除 (X)"); + expect(collectionSequence).not.toContain("选择 (Select)"); + }); });