fix: 修复历史记录错误

- 修复点击删除图标之后页面历史依旧存在的问题
This commit is contained in:
Huangzhe
2025-05-20 13:30:25 +08:00
parent 9ac1729109
commit 9ecbeec739
3 changed files with 13 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ import { getSearchInfo } from '@/api/home/search';
// 问卷
const surveys = ref([]);
// 搜索关键词
const keyword = ref<string>();
const keyword = ref<string>('');
// 搜索页面索引, 默认第一页
const index = ref<number>(1);
// 是否到达最后的列表
@@ -104,7 +104,7 @@ watch(index, async () => {
export {
keyword,
updateKeyword as handleSearch,
updateKeyword,
lastIndex,
loading,
surveys,

View File

@@ -2,7 +2,7 @@
import Search from '@/components/Search/Index.vue';
import TemplateMarket from '@/views/HomeSearch/components/TemplateMarket/Index.vue';
import MineSurvey from '@/views/HomeSearch/components/MineSurvey/Index.vue';
import { handleSearch, keyword, loading } from '@/views/HomeSearch/Hooks/useSurveySearch';
import { updateKeyword, keyword, loading } from '@/views/HomeSearch/Hooks/useSurveySearch';
import Layout from '@/components/Layout/CommonLayout.vue';
import { visible } from '@/views/HomeSearch/Hooks/useHomeSearch';
import RecommendTag from '@/views/HomeSearch/components/Recommend/Index.vue';
@@ -21,7 +21,7 @@ onMounted(() => {
<template>
<section class="search-container">
<div class="search">
<search :focus="true" v-model:value="searchKeyword" :search="handleSearch" />
<search :focus="true" v-model:value="searchKeyword" :search="updateKeyword" />
</div>
<!-- 广告区域 -->
<image-slider :banners="banners" v-if="banners?.length > 0 && keyword" />

View File

@@ -3,11 +3,16 @@ import { fetchHistory } from '@/hooks/request/useSearch';
import Layout from '@/components/Layout/CommonLayout.vue';
import { list, useFetchRecommon, delHistory } from './hooks/useRecommend';
import { Delete } from '@element-plus/icons-vue';
import { handleSearch } from '../../Hooks/useSurveySearch';
import { updateKeyword } from '../../Hooks/useSurveySearch';
useFetchRecommon();
const { history } = fetchHistory();
async function handleDelHistory() {
history.value = [];
delHistory();
}
</script>
<template>
@@ -18,7 +23,7 @@ const { history } = fetchHistory();
</template>
<el-space>
<el-tag
@click="handleSearch(tag.key_word)"
@click="updateKeyword(tag.key_word)"
style="color: black"
color="white"
:hit="false"
@@ -35,7 +40,7 @@ const { history } = fetchHistory();
<section class="history-title">
<el-text class="title">搜索历史</el-text>
<div>
<el-icon @click="delHistory"><Delete /></el-icon>
<el-icon @click="handleDelHistory"><Delete /></el-icon>
</div>
</section>
</template>
@@ -45,7 +50,7 @@ const { history } = fetchHistory();
color="white"
:hit="false"
round
@click="handleSearch(tag)"
@click="updateKeyword(tag)"
v-for="tag in history"
>{{ tag }}</el-tag
>