From df78b4d59a1f77903ceed472fc7ef4fd769a5db1 Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Fri, 16 Jan 2026 17:15:16 +0800 Subject: [PATCH] fix: type error --- .../selectionToolbox/ColorPickerButton.vue | 5 +++-- src/composables/graph/useGroupMenuOptions.ts | 3 ++- src/composables/graph/useNodeColorOptions.ts | 19 ++----------------- src/composables/graph/useNodeCustomization.ts | 5 +++-- src/composables/graph/useNodeMenuOptions.ts | 3 ++- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/components/graph/selectionToolbox/ColorPickerButton.vue b/src/components/graph/selectionToolbox/ColorPickerButton.vue index 7ee0897f1..91b8f781d 100644 --- a/src/components/graph/selectionToolbox/ColorPickerButton.vue +++ b/src/components/graph/selectionToolbox/ColorPickerButton.vue @@ -93,7 +93,8 @@ const currentColor = computed(() => currentColorOption.value ? isLightTheme.value ? colorOptions.value.find( - (option) => option.value.dark === currentColorOption.value?.bgcolor + (option: NodeColorOption) => + option.value.dark === currentColorOption.value?.bgcolor )?.value.light : currentColorOption.value?.bgcolor : null @@ -102,7 +103,7 @@ const currentColor = computed(() => const localizedCurrentColorName = computed(() => { if (!currentColorOption.value?.bgcolor) return null const colorOption = colorOptions.value.find( - (option) => + (option: NodeColorOption) => option.value.dark === currentColorOption.value?.bgcolor || option.value.light === currentColorOption.value?.bgcolor ) diff --git a/src/composables/graph/useGroupMenuOptions.ts b/src/composables/graph/useGroupMenuOptions.ts index 8f6977665..c5c0d8c82 100644 --- a/src/composables/graph/useGroupMenuOptions.ts +++ b/src/composables/graph/useGroupMenuOptions.ts @@ -7,6 +7,7 @@ import { useWorkflowStore } from '@/platform/workflow/management/stores/workflow import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useCanvasRefresh } from './useCanvasRefresh' +import type { NodeColorOption } from './useNodeColorOptions' import type { MenuOption } from './useMoreOptionsMenu' import { useNodeCustomization } from './useNodeCustomization' @@ -65,7 +66,7 @@ export function useGroupMenuOptions() { label: t('contextMenu.Color'), icon: 'icon-[lucide--palette]', hasSubmenu: true, - submenu: colorOptions.value.map((colorOption) => ({ + submenu: colorOptions.value.map((colorOption: NodeColorOption) => ({ label: typeof colorOption.localizedName === 'function' ? colorOption.localizedName() diff --git a/src/composables/graph/useNodeColorOptions.ts b/src/composables/graph/useNodeColorOptions.ts index 0f44de1d5..6c78afbef 100644 --- a/src/composables/graph/useNodeColorOptions.ts +++ b/src/composables/graph/useNodeColorOptions.ts @@ -1,4 +1,3 @@ -import type { ComputedRef } from 'vue' import { computed } from 'vue' import { useI18n } from 'vue-i18n' @@ -30,7 +29,7 @@ export interface NodeColorOption { /** * Configuration for useNodeColorOptions composable */ -export interface UseNodeColorOptionsConfig { +interface UseNodeColorOptionsConfig { /** * Whether to include ring color variants for UI elements like borders * @default false @@ -56,18 +55,6 @@ export interface UseNodeColorOptionsConfig { localizedNameAsFunction?: boolean } -/** - * Return type for useNodeColorOptions composable - */ -export interface UseNodeColorOptionsReturn { - colorOptions: ComputedRef - NO_COLOR_OPTION: ComputedRef - getColorValue: (color: string) => ColorVariants - applyColorToItems: (items: IColorable[], colorName: string) => void - getCurrentColorName: (items: IColorable[]) => string | null - isLightTheme: ComputedRef -} - /** * Composable for managing node color options with flexible configuration. * Consolidates color picker logic across SetNodeColor, ColorPickerButton, and useNodeCustomization. @@ -87,9 +74,7 @@ export interface UseNodeColorOptionsReturn { * }) * ``` */ -export function useNodeColorOptions( - config: UseNodeColorOptionsConfig = {} -): UseNodeColorOptionsReturn { +export function useNodeColorOptions(config: UseNodeColorOptionsConfig = {}) { const { includeRingColors = false, lightnessAdjustments = {}, diff --git a/src/composables/graph/useNodeCustomization.ts b/src/composables/graph/useNodeCustomization.ts index 4ff9ed361..954c1ec03 100644 --- a/src/composables/graph/useNodeCustomization.ts +++ b/src/composables/graph/useNodeCustomization.ts @@ -95,8 +95,9 @@ export function useNodeCustomization() { if (!currentColorName) return null return ( - colorOptions.value.find((option) => option.name === currentColorName) ?? - NO_COLOR_OPTION.value + colorOptions.value.find( + (option: NodeColorOption) => option.name === currentColorName + ) ?? NO_COLOR_OPTION.value ) } diff --git a/src/composables/graph/useNodeMenuOptions.ts b/src/composables/graph/useNodeMenuOptions.ts index 0f160f9d6..d8fe0e715 100644 --- a/src/composables/graph/useNodeMenuOptions.ts +++ b/src/composables/graph/useNodeMenuOptions.ts @@ -1,6 +1,7 @@ import { computed } from 'vue' import { useI18n } from 'vue-i18n' +import type { NodeColorOption } from './useNodeColorOptions' import type { MenuOption } from './useMoreOptionsMenu' import { useNodeCustomization } from './useNodeCustomization' import { useSelectedNodeActions } from './useSelectedNodeActions' @@ -29,7 +30,7 @@ export function useNodeMenuOptions() { ) const colorSubmenu = computed(() => { - return colorOptions.value.map((colorOption) => ({ + return colorOptions.value.map((colorOption: NodeColorOption) => ({ label: typeof colorOption.localizedName === 'function' ? colorOption.localizedName()