From 93ddb841cdf082ed7a3d2ac4bac0aeed33a09d62 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Thu, 10 Sep 2026 18:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=87=BA=E8=B5=84=E6=BA=90=E8=90=BD?= =?UTF-8?q?=E7=9B=98=E5=88=A4=E6=8D=AE=20isResourceCanvasExportable?= =?UTF-8?q?=EF=BC=8C=E8=B5=84=E6=BA=90=E9=9D=A2=E6=9D=BF=E4=B8=8E=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=9D=A1=E5=85=B1=E7=94=A8=E4=B8=80=E6=9D=A1=E5=8F=A3?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - resourceCanvasAssetTransferModel.ts 新增 isResourceCanvasExportable:只有拿得到可落盘本地文件路径的资源(version 为空且 path 非空)才允许保存 - resolveResourceCanvasPanelEntries 的 downloadable 改为调用该判据,去掉内联的同一段表达式 - 纯重构,资源面板行为不变;目的是让画布工具条的下载放行判据与资源面板使用同一个权威口径,不再写第二份 --- .../resourceCanvasAssetTransferModel.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/ai-game-creator-shell/src/features/resource-canvas/resourceCanvasAssetTransferModel.ts b/apps/ai-game-creator-shell/src/features/resource-canvas/resourceCanvasAssetTransferModel.ts index 96e1e6216..d25bd9946 100644 --- a/apps/ai-game-creator-shell/src/features/resource-canvas/resourceCanvasAssetTransferModel.ts +++ b/apps/ai-game-creator-shell/src/features/resource-canvas/resourceCanvasAssetTransferModel.ts @@ -28,6 +28,19 @@ export type ResourceCanvasPanelEntryInput = { previewError: string | null; }; +/** + * 资源能否落盘到用户本地。 + * + * 保存走的是本地文件复制(原生保存对话框 + Rust 分块拷贝),因此只要求有可读路径; + * 虚拟版本条目没有对应文件,拿不到路径就不放行。资源面板的「下载」与画布工具条的 + * 「下载按钮」共用这一条判据,不要在别处再写第二份。 + */ +export function isResourceCanvasExportable( + resource: Pick, +) { + return resource.version === undefined && resource.path !== ''; +} + export function resolveResourceCanvasPanelEntries( inputs: readonly ResourceCanvasPanelEntryInput[], ): ResourceCanvasPanelEntry[] { @@ -39,9 +52,7 @@ export function resolveResourceCanvasPanelEntries( path: input.resource.path, mediaType: input.resource.mediaType, selectable: true, - // 保存走本地文件复制,因此只要求有可读路径;虚拟版本条目没有文件,不能保存。 - downloadable: - input.resource.version === undefined && input.resource.path !== '', + downloadable: isResourceCanvasExportable(input.resource), previewIdentity: input.previewIdentity, previewSourceUrl: input.previewSourceUrl, previewStatus: input.previewStatus,