From a1c40a13adcfc46b089795c2a49da8f090e770b1 Mon Sep 17 00:00:00 2001 From: imeepos Date: Fri, 25 Jul 2025 12:44:12 +0800 Subject: [PATCH] fix: resolve compilation errors in advanced filter integration - Fixed AdvancedFilterPanel import issues by removing unused DEFAULT_COLOR_FILTER - Fixed EnvironmentTagSelector type errors with proper Record typing - Fixed SimilaritySearchTool executeSearch call by providing required SimilaritySearchRequest parameter - Fixed intelligentSearchService mergeSearchConfigs by adding missing SearchConfig fields: * debug_mode, custom_filters, query_enhancement_enabled, color_thresholds - Made availableEnvironments optional in EnvironmentTagSelector props - Updated type definitions to support enhanced search configuration All compilation errors resolved, build now passes successfully. --- .../src/components/outfit/AdvancedFilterPanel.tsx | 13 ++++++------- .../components/outfit/EnvironmentTagSelector.tsx | 7 +++---- .../src/pages/tools/SimilaritySearchTool.tsx | 10 ++++++++-- .../src/services/intelligentSearchService.ts | 4 ++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/apps/desktop/src/components/outfit/AdvancedFilterPanel.tsx b/apps/desktop/src/components/outfit/AdvancedFilterPanel.tsx index 3e429a7..8b6b52b 100644 --- a/apps/desktop/src/components/outfit/AdvancedFilterPanel.tsx +++ b/apps/desktop/src/components/outfit/AdvancedFilterPanel.tsx @@ -1,11 +1,10 @@ import React, { useState, useCallback } from 'react'; -import { - SearchConfig, - ColorFilter, - COMMON_CATEGORIES, - COMMON_ENVIRONMENTS, - COMMON_DESIGN_STYLES, - DEFAULT_COLOR_FILTER +import { + SearchConfig, + ColorFilter, + COMMON_CATEGORIES, + COMMON_ENVIRONMENTS, + COMMON_DESIGN_STYLES } from '../../types/outfitSearch'; import { CategoryFilterSelector } from './CategoryFilterSelector'; import { EnvironmentTagSelector } from './EnvironmentTagSelector'; diff --git a/apps/desktop/src/components/outfit/EnvironmentTagSelector.tsx b/apps/desktop/src/components/outfit/EnvironmentTagSelector.tsx index dfd0510..5eba62d 100644 --- a/apps/desktop/src/components/outfit/EnvironmentTagSelector.tsx +++ b/apps/desktop/src/components/outfit/EnvironmentTagSelector.tsx @@ -8,7 +8,7 @@ import { MapPin, Plus, X, Search, Tag } from 'lucide-react'; interface EnvironmentTagSelectorProps { selectedEnvironments: string[]; - availableEnvironments: string[]; + availableEnvironments?: string[]; // 现在可选,因为我们使用内置的环境分组 onEnvironmentsChange: (environments: string[]) => void; maxSelections?: number; allowCustom?: boolean; @@ -17,7 +17,6 @@ interface EnvironmentTagSelectorProps { export const EnvironmentTagSelector: React.FC = ({ selectedEnvironments, - availableEnvironments, onEnvironmentsChange, maxSelections = 3, allowCustom = true, @@ -28,7 +27,7 @@ export const EnvironmentTagSelector: React.FC = ({ const [customEnvironment, setCustomEnvironment] = useState(''); // 环境标签分组 - const environmentGroups = { + const environmentGroups: Record = { '室内环境': ['Indoor', 'Office', 'Home', 'Restaurant', 'Shopping mall'], '室外环境': ['Outdoor', 'City street', 'Park', 'Beach', 'Mountain'], '建筑环境': ['Building facade', 'Modern architecture', 'Historic building'], @@ -41,7 +40,7 @@ export const EnvironmentTagSelector: React.FC = ({ return environmentGroups; } - const filtered: typeof environmentGroups = {}; + const filtered: Record = {}; Object.entries(environmentGroups).forEach(([group, environments]) => { const matchedEnvironments = environments.filter(env => env.toLowerCase().includes(searchQuery.toLowerCase()) && diff --git a/apps/desktop/src/pages/tools/SimilaritySearchTool.tsx b/apps/desktop/src/pages/tools/SimilaritySearchTool.tsx index fb79b8d..3a625a0 100644 --- a/apps/desktop/src/pages/tools/SimilaritySearchTool.tsx +++ b/apps/desktop/src/pages/tools/SimilaritySearchTool.tsx @@ -107,9 +107,15 @@ const SimilaritySearchTool: React.FC = () => { setSearchConfig(newConfig); // 如果有查询内容,自动重新搜索 if (query.trim()) { - executeSearch(); + const request: SimilaritySearchRequest = { + query: query.trim(), + relevance_threshold: selectedThreshold, + page_size: configState.config?.max_results_per_page || 12, + page_offset: 0, + }; + executeSearch(request); } - }, [query, executeSearch]); + }, [query, selectedThreshold, configState.config, executeSearch]); // 切换高级过滤器显示 const handleToggleAdvancedFilters = useCallback(() => { diff --git a/apps/desktop/src/services/intelligentSearchService.ts b/apps/desktop/src/services/intelligentSearchService.ts index 6f9ba5d..c3e8dee 100644 --- a/apps/desktop/src/services/intelligentSearchService.ts +++ b/apps/desktop/src/services/intelligentSearchService.ts @@ -322,6 +322,10 @@ export class IntelligentSearchService { ...config2.design_styles, }, max_keywords: Math.max(config1.max_keywords, config2.max_keywords), + debug_mode: config1.debug_mode || config2.debug_mode, + custom_filters: [...new Set([...config1.custom_filters, ...config2.custom_filters])], + query_enhancement_enabled: config1.query_enhancement_enabled && config2.query_enhancement_enabled, + color_thresholds: config1.color_thresholds, }; }