From 51a9fd085e270cba7eaec162aa00b288f2da3789 Mon Sep 17 00:00:00 2001 From: Huangzhe Date: Sun, 18 May 2025 11:40:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增历史记录API模块,支持获取和添加搜索历史 2. 优化搜索组件交互体验 3. 更新搜索推荐功能,支持历史记录展示 4. 修复搜索框焦点控制问题 5. 优化搜索状态管理逻辑 --- src/api/history/index.ts | 38 ++++++++++++ src/components/Search/Index.vue | 5 ++ src/utils/directives/useVFocus.ts | 7 ++- src/views/HomeSearch/Hooks/useSurveySearch.ts | 17 +++--- src/views/HomeSearch/Index.vue | 20 +++++- .../HomeSearch/components/Recommend/Index.vue | 18 +++++- .../Recommend/hooks/useRecommend.ts | 61 +++++++++++-------- 7 files changed, 128 insertions(+), 38 deletions(-) create mode 100644 src/api/history/index.ts diff --git a/src/api/history/index.ts b/src/api/history/index.ts new file mode 100644 index 0000000..504d7cb --- /dev/null +++ b/src/api/history/index.ts @@ -0,0 +1,38 @@ +import request from '@/utils/request'; + +/** + * 获取历史记录 + * @returns + */ +export function fetchHistory() { + return request({ + url: `/console/hot_search_history/list`, + method: 'get' + }); +} + +/** + * 增加历史记录 + * @param keyword {string} + * @returns + */ +export function addHistory(keyword: string) { + return request({ + url: `/console/hot_search_history/add`, + method: 'post', + data: { + keyword: keyword + } + }); +} + +/** + * 删除所有的历史记录 + * @returns + */ +export function clearHistory() { + return request({ + url: `/console/hot_search_history/clear`, + method: 'post' + }); +} diff --git a/src/components/Search/Index.vue b/src/components/Search/Index.vue index 090fb8c..071ba51 100644 --- a/src/components/Search/Index.vue +++ b/src/components/Search/Index.vue @@ -1,6 +1,7 @@