From 2e0bc3aeb1ea912fd0fc7e24e0ec6a2907ae5d94 Mon Sep 17 00:00:00 2001 From: kdletters <61648117+kdletters@users.noreply.github.com> Date: Tue, 6 Oct 2026 14:38:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E7=95=99=E8=B5=84=E6=BA=90=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E5=86=B2=E7=AA=81=E5=85=B7=E4=BD=93=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已知冲突分类继续给出动作文案并附带脱敏对象详情 --- .../resourceVersionReplacementModel.ts | 35 +++++++++++++++---- .../projectAssetCommandErrorMessage.ts | 24 +++++++++++-- .../resourceVersionReplacementModel.test.ts | 6 ++-- 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/apps/ai-game-creator-shell/src/features/resource-canvas/resourceVersionReplacementModel.ts b/apps/ai-game-creator-shell/src/features/resource-canvas/resourceVersionReplacementModel.ts index 598a63944..8a000b471 100644 --- a/apps/ai-game-creator-shell/src/features/resource-canvas/resourceVersionReplacementModel.ts +++ b/apps/ai-game-creator-shell/src/features/resource-canvas/resourceVersionReplacementModel.ts @@ -261,31 +261,54 @@ export function resourceVersionReplacementErrorMessage(error: unknown): string { 0, 400, ); + const withDetail = (base: string, marker: string) => { + const markerIndex = message.indexOf(marker); + const detail = + markerIndex < 0 + ? '' + : message + .slice(markerIndex + marker.length) + .replace(/^[\s::;,;]+/u, '') + .trim(); + return detail ? `${base}:${detail}` : base; + }; if (message.includes('project-revision-conflict')) { - return '项目已被其它操作改动,请重试替换'; + return withDetail( + '项目已被其它操作改动,请重试替换', + 'project-revision-conflict', + ); } if (message.includes('project-identity-conflict')) { - return '项目身份不一致,请重新打开项目后再试'; + return withDetail( + '项目身份不一致,请重新打开项目后再试', + 'project-identity-conflict', + ); } if (message.includes('resource-replacement-incompatible')) { const reason = message.split(':').pop()?.trim(); return reason ? `替换素材不兼容:${reason}` : '替换素材不兼容'; } if (message.includes('源项目版本不存在')) { - return '当前版本已不存在,请刷新项目后重试'; + return withDetail('当前版本已不存在,请刷新项目后重试', '源项目版本不存在'); } if (message.includes('源版本未绑定该素材')) { - return '该素材不在当前版本的绑定里,不能替换'; + return withDetail( + '该素材不在当前版本的绑定里,不能替换', + '源版本未绑定该素材', + ); } if (message.includes('项目资源不存在')) { - return '替换素材未登记或已被删除'; + return withDetail('替换素材未登记或已被删除', '项目资源不存在'); } if (message.includes('替换素材与源素材相同')) { return '替换素材与源素材相同'; } if (message.includes('不可修改、删除或重排')) { // 版本记录写入边界的拒绝:直接替换只允许改一个版本的绑定,走到这里说明写入被守门挡下了。 - return '替换被项目版本写入边界拒绝,请刷新项目后重试'; + return withDetail( + '替换被项目版本写入边界拒绝,请刷新项目后重试', + '项目版本记录写入后不可修改、删除或重排', + ); } if (message.includes('必须在客户端内执行')) { return '替换素材需要在客户端内执行'; diff --git a/apps/ai-game-creator-shell/src/view/project-development/projectAssetCommandErrorMessage.ts b/apps/ai-game-creator-shell/src/view/project-development/projectAssetCommandErrorMessage.ts index 0119f4c3e..4239ade05 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/projectAssetCommandErrorMessage.ts +++ b/apps/ai-game-creator-shell/src/view/project-development/projectAssetCommandErrorMessage.ts @@ -10,16 +10,36 @@ */ import { visibleClientErrorMessage } from '../../services/errorReporting'; +function withMappedDetail(base: string, message: string, marker: string) { + const markerIndex = message.indexOf(marker); + const detail = + markerIndex < 0 + ? '' + : message + .slice(markerIndex + marker.length) + .replace(/^[\s::;,;]+/u, '') + .trim(); + return detail ? `${base}:${detail}` : base; +} + export function projectAssetCommandErrorMessage( error: unknown, fallback: string, ): string { const message = visibleClientErrorMessage(error, fallback); if (message.includes('project-revision-conflict')) { - return '项目已被其它操作改动,请刷新后重试'; + return withMappedDetail( + '项目已被其它操作改动,请刷新后重试', + message, + 'project-revision-conflict', + ); } if (message.includes('project-identity-conflict')) { - return '项目身份不一致,请重新打开项目后再试'; + return withMappedDetail( + '项目身份不一致,请重新打开项目后再试', + message, + 'project-identity-conflict', + ); } return message; } diff --git a/apps/ai-game-creator-shell/tests/resourceVersionReplacementModel.test.ts b/apps/ai-game-creator-shell/tests/resourceVersionReplacementModel.test.ts index 33babee0c..7e6d5af2c 100644 --- a/apps/ai-game-creator-shell/tests/resourceVersionReplacementModel.test.ts +++ b/apps/ai-game-creator-shell/tests/resourceVersionReplacementModel.test.ts @@ -204,17 +204,17 @@ describe('资源替换的展示层口径', () => { resourceVersionReplacementErrorMessage( new Error('源项目版本不存在:initial-1'), ), - ).toBe('当前版本已不存在,请刷新项目后重试'); + ).toBe('当前版本已不存在,请刷新项目后重试:initial-1'); expect( resourceVersionReplacementErrorMessage( new Error('源版本未绑定该素材:initial-1 · asset-1'), ), - ).toBe('该素材不在当前版本的绑定里,不能替换'); + ).toBe('该素材不在当前版本的绑定里,不能替换:initial-1 · asset-1'); expect( resourceVersionReplacementErrorMessage( new Error('项目资源不存在:asset-x'), ), - ).toBe('替换素材未登记或已被删除'); + ).toBe('替换素材未登记或已被删除:asset-x'); expect( resourceVersionReplacementErrorMessage(new Error('替换素材与源素材相同')), ).toBe('替换素材与源素材相同');