fix: 修复历史记录错误
- 修复点击删除图标之后页面历史依旧存在的问题
This commit is contained in:
@@ -6,7 +6,7 @@ import { getSearchInfo } from '@/api/home/search';
|
|||||||
// 问卷
|
// 问卷
|
||||||
const surveys = ref([]);
|
const surveys = ref([]);
|
||||||
// 搜索关键词
|
// 搜索关键词
|
||||||
const keyword = ref<string>();
|
const keyword = ref<string>('');
|
||||||
// 搜索页面索引, 默认第一页
|
// 搜索页面索引, 默认第一页
|
||||||
const index = ref<number>(1);
|
const index = ref<number>(1);
|
||||||
// 是否到达最后的列表
|
// 是否到达最后的列表
|
||||||
@@ -104,7 +104,7 @@ watch(index, async () => {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
keyword,
|
keyword,
|
||||||
updateKeyword as handleSearch,
|
updateKeyword,
|
||||||
lastIndex,
|
lastIndex,
|
||||||
loading,
|
loading,
|
||||||
surveys,
|
surveys,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import Search from '@/components/Search/Index.vue';
|
import Search from '@/components/Search/Index.vue';
|
||||||
import TemplateMarket from '@/views/HomeSearch/components/TemplateMarket/Index.vue';
|
import TemplateMarket from '@/views/HomeSearch/components/TemplateMarket/Index.vue';
|
||||||
import MineSurvey from '@/views/HomeSearch/components/MineSurvey/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 Layout from '@/components/Layout/CommonLayout.vue';
|
||||||
import { visible } from '@/views/HomeSearch/Hooks/useHomeSearch';
|
import { visible } from '@/views/HomeSearch/Hooks/useHomeSearch';
|
||||||
import RecommendTag from '@/views/HomeSearch/components/Recommend/Index.vue';
|
import RecommendTag from '@/views/HomeSearch/components/Recommend/Index.vue';
|
||||||
@@ -21,7 +21,7 @@ onMounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<section class="search-container">
|
<section class="search-container">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<search :focus="true" v-model:value="searchKeyword" :search="handleSearch" />
|
<search :focus="true" v-model:value="searchKeyword" :search="updateKeyword" />
|
||||||
</div>
|
</div>
|
||||||
<!-- 广告区域 -->
|
<!-- 广告区域 -->
|
||||||
<image-slider :banners="banners" v-if="banners?.length > 0 && keyword" />
|
<image-slider :banners="banners" v-if="banners?.length > 0 && keyword" />
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ import { fetchHistory } from '@/hooks/request/useSearch';
|
|||||||
import Layout from '@/components/Layout/CommonLayout.vue';
|
import Layout from '@/components/Layout/CommonLayout.vue';
|
||||||
import { list, useFetchRecommon, delHistory } from './hooks/useRecommend';
|
import { list, useFetchRecommon, delHistory } from './hooks/useRecommend';
|
||||||
import { Delete } from '@element-plus/icons-vue';
|
import { Delete } from '@element-plus/icons-vue';
|
||||||
import { handleSearch } from '../../Hooks/useSurveySearch';
|
import { updateKeyword } from '../../Hooks/useSurveySearch';
|
||||||
|
|
||||||
useFetchRecommon();
|
useFetchRecommon();
|
||||||
|
|
||||||
const { history } = fetchHistory();
|
const { history } = fetchHistory();
|
||||||
|
|
||||||
|
async function handleDelHistory() {
|
||||||
|
history.value = [];
|
||||||
|
delHistory();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -18,7 +23,7 @@ const { history } = fetchHistory();
|
|||||||
</template>
|
</template>
|
||||||
<el-space>
|
<el-space>
|
||||||
<el-tag
|
<el-tag
|
||||||
@click="handleSearch(tag.key_word)"
|
@click="updateKeyword(tag.key_word)"
|
||||||
style="color: black"
|
style="color: black"
|
||||||
color="white"
|
color="white"
|
||||||
:hit="false"
|
:hit="false"
|
||||||
@@ -35,7 +40,7 @@ const { history } = fetchHistory();
|
|||||||
<section class="history-title">
|
<section class="history-title">
|
||||||
<el-text class="title">搜索历史</el-text>
|
<el-text class="title">搜索历史</el-text>
|
||||||
<div>
|
<div>
|
||||||
<el-icon @click="delHistory"><Delete /></el-icon>
|
<el-icon @click="handleDelHistory"><Delete /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -45,7 +50,7 @@ const { history } = fetchHistory();
|
|||||||
color="white"
|
color="white"
|
||||||
:hit="false"
|
:hit="false"
|
||||||
round
|
round
|
||||||
@click="handleSearch(tag)"
|
@click="updateKeyword(tag)"
|
||||||
v-for="tag in history"
|
v-for="tag in history"
|
||||||
>{{ tag }}</el-tag
|
>{{ tag }}</el-tag
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user