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');