From 874c3fade37490ae5f29bb96fae19cd4436b93bf Mon Sep 17 00:00:00 2001 From: xudan Date: Wed, 10 Sep 2025 16:45:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E5=9B=BE=E7=89=87=E8=AE=BE=E7=BD=AE=E6=A8=A1=E6=80=81?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E9=87=8D=E5=91=BD=E5=90=8D=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E4=B8=BA=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9B=BE?= =?UTF-8?q?=E7=89=87=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=BF=80=E6=B4=BB=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=9B=BE=E7=89=87=E8=AE=BE=E7=BD=AE=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=BC=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BA=A4=E4=BA=92=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modal/robot-image-settings-modal.vue | 161 +++++++----------- src/services/color/color-config.service.ts | 59 ++++++- src/services/editor.service.ts | 2 +- 3 files changed, 113 insertions(+), 109 deletions(-) diff --git a/src/components/modal/robot-image-settings-modal.vue b/src/components/modal/robot-image-settings-modal.vue index 36686fe..1259706 100644 --- a/src/components/modal/robot-image-settings-modal.vue +++ b/src/components/modal/robot-image-settings-modal.vue @@ -31,8 +31,8 @@
图片设置 - - + +
- 选择普通状态图片 + 选择自定义图片
- 普通状态 + 自定义图片
删除
@@ -57,63 +57,11 @@
- - -
- - - - 选择激活状态图片 - - - -
- 激活状态 -
- 删除 -
-
-
-
- - - - - - - 宽度 (px) - - - - 高度 (px) - - - - 重置图片 - 清除所有图片 + 清除图片
@@ -125,9 +73,10 @@ @@ -385,11 +334,6 @@ const handleCancel = () => { opacity: 1; } -.size-label { - font-size: 12px; - color: #666; - margin-left: 8px; -} .ant-form-item { margin-bottom: 16px; @@ -398,4 +342,15 @@ const handleCancel = () => { .ant-divider { margin: 16px 0; } + +/* 确保模态框层级低于机器人菜单 (机器人菜单 z-index: 9999) */ +:deep(.ant-modal) { + z-index: 1000 !important; +} + +:deep(.ant-modal-mask) { + z-index: 999 !important; +} + + diff --git a/src/services/color/color-config.service.ts b/src/services/color/color-config.service.ts index 2613028..baa5299 100644 --- a/src/services/color/color-config.service.ts +++ b/src/services/color/color-config.service.ts @@ -890,10 +890,14 @@ class ColorConfigService { fillWarning: theme.robot['fill-warning'] || DEFAULT_COLORS.robot.fillWarning, strokeFault: theme.robot['stroke-fault'] || DEFAULT_COLORS.robot.strokeFault, fillFault: theme.robot['fill-fault'] || DEFAULT_COLORS.robot.fillFault, - imageWidth: DEFAULT_COLORS.robot.imageWidth, - imageHeight: DEFAULT_COLORS.robot.imageHeight, - customImages: DEFAULT_COLORS.robot.customImages, - useCustomImages: DEFAULT_COLORS.robot.useCustomImages + imageWidth: theme.robot.imageWidth || DEFAULT_COLORS.robot.imageWidth, + imageHeight: theme.robot.imageHeight || DEFAULT_COLORS.robot.imageHeight, + customImages: theme.robot.customImages || DEFAULT_COLORS.robot.customImages, + useCustomImages: theme.robot.useCustomImages !== undefined ? + (typeof theme.robot.useCustomImages === 'string' ? + theme.robot.useCustomImages === 'true' : + theme.robot.useCustomImages) : + DEFAULT_COLORS.robot.useCustomImages }; } @@ -1109,10 +1113,20 @@ class ColorConfigService { */ public getRobotCustomImage(robotName: string, state: 'normal' | 'active'): string | null { const customImages = this.config.value.robot.customImages; + if (!customImages || !customImages[robotName]) { return null; } - return customImages[robotName][state] || null; + + // 优先获取请求状态的图片,如果不存在则回退到 normal 状态 + let result = customImages[robotName][state] || null; + + // 如果请求的是 active 状态但没有 active 图片,回退到 normal 状态 + if (!result && state === 'active') { + result = customImages[robotName]['normal'] || null; + } + + return result; } /** @@ -1169,6 +1183,41 @@ class ColorConfigService { customImages[robotName].normal || customImages[robotName].active ); } + + /** + * 调试方法:打印当前配置状态 + */ + public debugConfig(): void { + console.log('🔧 当前颜色配置状态:', { + robot: { + useCustomImages: this.config.value.robot.useCustomImages, + imageWidth: this.config.value.robot.imageWidth, + imageHeight: this.config.value.robot.imageHeight, + customImages: this.config.value.robot.customImages + }, + fullConfig: this.config.value + }); + } + + /** + * 应用用户提供的完整配置 + * @param userConfig 用户配置对象 + */ + public applyUserConfig(userConfig: any): void { + console.log('📝 应用用户配置:', userConfig); + + // 合并用户配置到当前配置 + this.config.value = this.mergeConfig(this.config.value, userConfig); + + // 保存到本地存储 + this.saveToLocalStorage(this.config.value); + + // 触发重新渲染 + this.triggerRender(); + + console.log('✅ 用户配置已应用并保存'); + } + } export default new ColorConfigService(); diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index 0f624f4..4394302 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -1223,8 +1223,8 @@ export class EditorService extends Meta2d { // 检查是否启用自定义图片且有机器人名称 const useCustomImages = colorConfig.getColor('robot.useCustomImages') === 'true'; - let image: string; + let image: string; if (useCustomImages && robotName) { // 尝试获取自定义图片 const customImage = colorConfig.getRobotCustomImage(robotName, active ? 'active' : 'normal');