|
3 | 3 | <n-card v-if="isShow" class="search-default" content-style="padding: 0"> |
4 | 4 | <n-scrollbar class="scrollbar"> |
5 | 5 | <!-- 搜索历史 --> |
6 | | - <div |
7 | | - v-if="settingStore.showSearchHistory && dataStore.searchHistory.length > 0" |
8 | | - class="history" |
9 | | - > |
| 6 | + <div v-if="isShowSearchHistory" class="history"> |
10 | 7 | <div class="title"> |
11 | 8 | <SvgIcon name="History" /> |
12 | 9 | <n-text class="name">搜索历史 </n-text> |
|
25 | 22 | </n-flex> |
26 | 23 | </div> |
27 | 24 | <!-- 热搜榜 --> |
28 | | - <div v-if="searchHotData.length > 0" class="hot-list"> |
| 25 | + <div v-if="isShowHotSearch" class="hot-list"> |
29 | 26 | <div class="title"> |
30 | 27 | <SvgIcon name="Fire" /> |
31 | 28 | <n-text class="name">热搜榜 </n-text> |
@@ -86,18 +83,30 @@ const settingStore = useSettingStore(); |
86 | 83 |
|
87 | 84 | const searchHotData = ref<SearchHotItem[]>([]); |
88 | 85 |
|
89 | | -// 是否展示 |
| 86 | +// 是否展示 SearchDefault |
90 | 87 | const isShow = computed(() => { |
91 | 88 | return ( |
92 | 89 | !statusStore.searchInputValue && |
93 | 90 | statusStore.searchFocus && |
94 | | - (searchHotData.value.length > 0 || dataStore.searchHistory.length > 0) |
| 91 | + (isShowHotSearch.value || isShowSearchHistory.value) |
| 92 | + ); |
| 93 | +}); |
| 94 | +
|
| 95 | +// 是否展示搜索历史 |
| 96 | +const isShowSearchHistory = computed(() => { |
| 97 | + return settingStore.showSearchHistory && dataStore.searchHistory.length > 0; |
| 98 | +}); |
| 99 | +
|
| 100 | +// 是否展示热搜榜 |
| 101 | +const isShowHotSearch = computed(() => { |
| 102 | + return ( |
| 103 | + settingStore.useOnlineService && settingStore.showHotSearch && searchHotData.value.length > 0 |
95 | 104 | ); |
96 | 105 | }); |
97 | 106 |
|
98 | 107 | // 获取热搜数据 |
99 | 108 | const getSearchHotData = async () => { |
100 | | - if (!settingStore.useOnlineService) return; |
| 109 | + if (!settingStore.useOnlineService || !settingStore.showHotSearch) return; |
101 | 110 | const result = await getCacheData(searchHot, { |
102 | 111 | key: "searchHotData", |
103 | 112 | time: 10, |
|
0 commit comments