From 2d96e8ca4e8ca7d8ef2b4f6283306810617ed70a Mon Sep 17 00:00:00 2001 From: sion123 <450702724@qq.com> Date: Thu, 26 Feb 2026 20:17:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(agent):=20=E4=BC=98=E5=8C=96=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E5=8A=9F=E8=83=BD=E4=BB=A3=E7=A0=81=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 前端移除未使用的 ArrowRightOutlined 导入 - 优化智能体列表排序逻辑,避免修改原数组 - 后端使用 Stream API 简化收藏智能体 ID 获取逻辑 --- frontend/app/web-gold/src/api/agent.js | 1 - frontend/app/web-gold/src/views/agents/Agents.vue | 5 ++--- .../muye/aiagent/service/AiAgentFavoriteServiceImpl.java | 8 +++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/frontend/app/web-gold/src/api/agent.js b/frontend/app/web-gold/src/api/agent.js index 2ef42581a6..30919c6986 100644 --- a/frontend/app/web-gold/src/api/agent.js +++ b/frontend/app/web-gold/src/api/agent.js @@ -8,7 +8,6 @@ import { API_BASE } from '@gold/config/api' const BASE_URL = `${API_BASE.APP_TIK}` - /** * 获取启用的智能体列表 */ diff --git a/frontend/app/web-gold/src/views/agents/Agents.vue b/frontend/app/web-gold/src/views/agents/Agents.vue index 597a717439..7ab0df56a9 100644 --- a/frontend/app/web-gold/src/views/agents/Agents.vue +++ b/frontend/app/web-gold/src/views/agents/Agents.vue @@ -179,7 +179,6 @@ import { SearchOutlined, RobotOutlined, CloseOutlined, - ArrowRightOutlined, MessageOutlined, AppstoreOutlined, StarOutlined, @@ -246,8 +245,8 @@ const filteredAgentList = computed(() => { ) } - // 收藏的智能体置顶 - return list.sort((a, b) => { + // 收藏的智能体置顶(复制数组避免修改原数组) + return [...list].sort((a, b) => { if (a.isFavorite === b.isFavorite) return 0 return a.isFavorite ? -1 : 1 }) diff --git a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiagent/service/AiAgentFavoriteServiceImpl.java b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiagent/service/AiAgentFavoriteServiceImpl.java index 2beb87cc66..25653e3893 100644 --- a/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiagent/service/AiAgentFavoriteServiceImpl.java +++ b/yudao-module-tik/src/main/java/cn/iocoder/yudao/module/tik/muye/aiagent/service/AiAgentFavoriteServiceImpl.java @@ -55,11 +55,9 @@ public class AiAgentFavoriteServiceImpl implements AiAgentFavoriteService { @Override public Set getFavoriteAgentIds(Long userId) { List favorites = aiAgentFavoriteMapper.selectListByUserId(userId); - Set agentIds = new HashSet<>(); - for (AiAgentFavoriteDO favorite : favorites) { - agentIds.add(favorite.getAgentId()); - } - return agentIds; + return favorites.stream() + .map(AiAgentFavoriteDO::getAgentId) + .collect(java.util.stream.Collectors.toSet()); } @Override