feat: add agent favorite functionality with UI and API implementation

- Add `addFavorite` and `removeFavorite` API functions in agent.js
- Implement favorite button UI in Agents.vue with star icons
- Add login check before favorite operations using token manager
- Sort agents with favorites appearing at the top of the list
- Include success/error messages for user feedback
- Add backend API endpoints for creating/deleting agent favorites
- Update agent list response to include favorite status
- Style favorite button with hover and active states
This commit is contained in:
2026-02-26 20:15:24 +08:00
parent 120a4529a5
commit d429dc887a
8 changed files with 315 additions and 11 deletions

View File

@@ -116,3 +116,27 @@ export function getMessages(params) {
params
})
}
/**
* 添加智能体收藏
* @param {number} agentId - 智能体ID
*/
export function addFavorite(agentId) {
return request({
url: `${BASE_URL}/agent/favorite/create`,
method: 'post',
params: { agentId }
})
}
/**
* 取消智能体收藏
* @param {number} agentId - 智能体ID
*/
export function removeFavorite(agentId) {
return request({
url: `${BASE_URL}/agent/favorite/delete`,
method: 'delete',
params: { agentId }
})
}