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<string, string[]> 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.
This commit is contained in:
parent
2b209e5ad2
commit
a1c40a13ad
|
|
@ -1,11 +1,10 @@
|
||||||
import React, { useState, useCallback } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import {
|
import {
|
||||||
SearchConfig,
|
SearchConfig,
|
||||||
ColorFilter,
|
ColorFilter,
|
||||||
COMMON_CATEGORIES,
|
COMMON_CATEGORIES,
|
||||||
COMMON_ENVIRONMENTS,
|
COMMON_ENVIRONMENTS,
|
||||||
COMMON_DESIGN_STYLES,
|
COMMON_DESIGN_STYLES
|
||||||
DEFAULT_COLOR_FILTER
|
|
||||||
} from '../../types/outfitSearch';
|
} from '../../types/outfitSearch';
|
||||||
import { CategoryFilterSelector } from './CategoryFilterSelector';
|
import { CategoryFilterSelector } from './CategoryFilterSelector';
|
||||||
import { EnvironmentTagSelector } from './EnvironmentTagSelector';
|
import { EnvironmentTagSelector } from './EnvironmentTagSelector';
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { MapPin, Plus, X, Search, Tag } from 'lucide-react';
|
||||||
|
|
||||||
interface EnvironmentTagSelectorProps {
|
interface EnvironmentTagSelectorProps {
|
||||||
selectedEnvironments: string[];
|
selectedEnvironments: string[];
|
||||||
availableEnvironments: string[];
|
availableEnvironments?: string[]; // 现在可选,因为我们使用内置的环境分组
|
||||||
onEnvironmentsChange: (environments: string[]) => void;
|
onEnvironmentsChange: (environments: string[]) => void;
|
||||||
maxSelections?: number;
|
maxSelections?: number;
|
||||||
allowCustom?: boolean;
|
allowCustom?: boolean;
|
||||||
|
|
@ -17,7 +17,6 @@ interface EnvironmentTagSelectorProps {
|
||||||
|
|
||||||
export const EnvironmentTagSelector: React.FC<EnvironmentTagSelectorProps> = ({
|
export const EnvironmentTagSelector: React.FC<EnvironmentTagSelectorProps> = ({
|
||||||
selectedEnvironments,
|
selectedEnvironments,
|
||||||
availableEnvironments,
|
|
||||||
onEnvironmentsChange,
|
onEnvironmentsChange,
|
||||||
maxSelections = 3,
|
maxSelections = 3,
|
||||||
allowCustom = true,
|
allowCustom = true,
|
||||||
|
|
@ -28,7 +27,7 @@ export const EnvironmentTagSelector: React.FC<EnvironmentTagSelectorProps> = ({
|
||||||
const [customEnvironment, setCustomEnvironment] = useState('');
|
const [customEnvironment, setCustomEnvironment] = useState('');
|
||||||
|
|
||||||
// 环境标签分组
|
// 环境标签分组
|
||||||
const environmentGroups = {
|
const environmentGroups: Record<string, string[]> = {
|
||||||
'室内环境': ['Indoor', 'Office', 'Home', 'Restaurant', 'Shopping mall'],
|
'室内环境': ['Indoor', 'Office', 'Home', 'Restaurant', 'Shopping mall'],
|
||||||
'室外环境': ['Outdoor', 'City street', 'Park', 'Beach', 'Mountain'],
|
'室外环境': ['Outdoor', 'City street', 'Park', 'Beach', 'Mountain'],
|
||||||
'建筑环境': ['Building facade', 'Modern architecture', 'Historic building'],
|
'建筑环境': ['Building facade', 'Modern architecture', 'Historic building'],
|
||||||
|
|
@ -41,7 +40,7 @@ export const EnvironmentTagSelector: React.FC<EnvironmentTagSelectorProps> = ({
|
||||||
return environmentGroups;
|
return environmentGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filtered: typeof environmentGroups = {};
|
const filtered: Record<string, string[]> = {};
|
||||||
Object.entries(environmentGroups).forEach(([group, environments]) => {
|
Object.entries(environmentGroups).forEach(([group, environments]) => {
|
||||||
const matchedEnvironments = environments.filter(env =>
|
const matchedEnvironments = environments.filter(env =>
|
||||||
env.toLowerCase().includes(searchQuery.toLowerCase()) &&
|
env.toLowerCase().includes(searchQuery.toLowerCase()) &&
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,15 @@ const SimilaritySearchTool: React.FC = () => {
|
||||||
setSearchConfig(newConfig);
|
setSearchConfig(newConfig);
|
||||||
// 如果有查询内容,自动重新搜索
|
// 如果有查询内容,自动重新搜索
|
||||||
if (query.trim()) {
|
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(() => {
|
const handleToggleAdvancedFilters = useCallback(() => {
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,10 @@ export class IntelligentSearchService {
|
||||||
...config2.design_styles,
|
...config2.design_styles,
|
||||||
},
|
},
|
||||||
max_keywords: Math.max(config1.max_keywords, config2.max_keywords),
|
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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue