From 00ddd48082c004aad54cf45a527c4ebea3d257b0 Mon Sep 17 00:00:00 2001 From: sladro Date: Thu, 28 Aug 2025 18:47:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E5=9E=8B=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=20-=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=86=97=E4=BD=99=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除不必要的字段以简化API响应: • 删除component_path字段,避免重复路径信息 • 删除display_name字段,model_name已足够 • 删除file_size和last_modified字段,减少响应体积 • 保留核心搜索功能,优化用户体验 JSON响应更简洁,只包含必要的搜索结果信息。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- ModelSearchEngine.cpp | 7 ------- ModelSearchEngine.h | 6 ------ ModelSearchHandler.cpp | 5 +---- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/ModelSearchEngine.cpp b/ModelSearchEngine.cpp index 37dbb76..ce9da9d 100644 --- a/ModelSearchEngine.cpp +++ b/ModelSearchEngine.cpp @@ -125,7 +125,6 @@ void ModelSearchEngine::SearchSessionModels(const ModelSearchRequest& request, s // Create search result item SearchResultItem item; item.model_name = model_name; - item.display_name = model_name; item.full_path = model_name; // 对于会话中的根模型,路径就是模型名 item.file_path = file_path; // 物理文件路径 item.model_type = model_type; @@ -202,7 +201,6 @@ void ModelSearchEngine::SearchFromRootAssemblies(const ModelSearchRequest& reque if (match_score >= request.similarity_threshold) { SearchResultItem item; item.model_name = root_name; - item.display_name = root_name; item.full_path = root_name; // Root assembly path item.file_path = GetModelFilePath(model); item.model_type = "ASSEMBLY"; @@ -275,7 +273,6 @@ void ModelSearchEngine::SearchCurrentModel(const ModelSearchRequest& request, st SearchResultItem item; item.model_name = model_name; - item.display_name = model_name; item.full_path = model_name; // 当前模型的路径就是模型名 item.file_path = file_path; // 物理文件路径 item.model_type = GetModelTypeString(current_model); @@ -385,11 +382,9 @@ void ModelSearchEngine::SearchAssemblyComponents(const ModelSearchRequest& reque if (match_score >= request.similarity_threshold) { SearchResultItem item; item.model_name = comp_name; - item.display_name = comp_name; item.full_path = tree_path; // Model tree hierarchy path item.file_path = comp_file; // Physical file path item.model_type = model_type; - item.component_path = BuildComponentPath(parent_path, comp_name); item.match_score = match_score; item.match_type = "component"; item.is_in_session = true; @@ -502,11 +497,9 @@ void ModelSearchEngine::SearchAssemblyComponentsWithDedup(const ModelSearchReque if (match_score >= request.similarity_threshold) { SearchResultItem item; item.model_name = comp_name; - item.display_name = comp_name; item.full_path = tree_path; // Model tree hierarchy path item.file_path = comp_file; // Physical file path item.model_type = model_type; - item.component_path = BuildComponentPath(parent_path, comp_name); item.match_score = match_score; item.match_type = "component"; item.is_in_session = true; diff --git a/ModelSearchEngine.h b/ModelSearchEngine.h index b366883..6ca8cc6 100644 --- a/ModelSearchEngine.h +++ b/ModelSearchEngine.h @@ -48,21 +48,15 @@ struct ModelSearchRequest { // 搜索结果项结构 struct SearchResultItem { std::string model_name; // 模型名称 - std::string display_name; // 显示名称 std::string full_path; // 模型树中的完整路径 std::string file_path; // 文件路径 (GetOrigin) std::string model_type; // 模型类型 ("PART", "ASSEMBLY", "DRAWING") - std::string component_path; // 组件路径(装配体中的位置) double match_score; // 匹配分数 (0.0-1.0) std::string match_reason; // 匹配原因说明 std::string match_type; // 匹配类型 ("name", "component", "feature") bool is_in_session; // 是否在当前会话中 bool is_assembly; // 是否是装配体 int component_count; // 组件数量(装配体) - - // 扩展信息 - std::string file_size; // 文件大小 - std::string last_modified; // 最后修改时间 std::vector matched_keywords; // 匹配的关键词 // 构造函数 diff --git a/ModelSearchHandler.cpp b/ModelSearchHandler.cpp index 573293a..d5eec61 100644 --- a/ModelSearchHandler.cpp +++ b/ModelSearchHandler.cpp @@ -123,18 +123,15 @@ HttpResponse ModelSearchHandler::FormatSuccessResponse(const ModelSearchResult& json << "{" << "\"model_name\": \"" << EscapeJsonString(item.model_name) << "\"," - << "\"display_name\": \"" << EscapeJsonString(item.display_name) << "\"," << "\"full_path\": \"" << EscapeJsonString(item.full_path) << "\"," + << "\"file_path\": \"" << EscapeJsonString(item.file_path) << "\"," << "\"model_type\": \"" << EscapeJsonString(item.model_type) << "\"," - << "\"component_path\": \"" << EscapeJsonString(item.component_path) << "\"," << "\"match_score\": " << item.match_score << "," << "\"match_reason\": \"" << EscapeJsonString(item.match_reason) << "\"," << "\"match_type\": \"" << EscapeJsonString(item.match_type) << "\"," << "\"is_in_session\": " << (item.is_in_session ? "true" : "false") << "," << "\"is_assembly\": " << (item.is_assembly ? "true" : "false") << "," << "\"component_count\": " << item.component_count << "," - << "\"file_size\": \"" << EscapeJsonString(item.file_size) << "\"," - << "\"last_modified\": \"" << EscapeJsonString(item.last_modified) << "\"," << "\"matched_keywords\": ["; // Build matched keywords list