kbar支持历史记录

This commit is contained in:
Allen
2024-06-03 10:16:01 +08:00
parent b5e9b14048
commit 43f36f556c
2 changed files with 39 additions and 0 deletions

View File

@@ -6,10 +6,15 @@ import api from '@/api'
import type { TransferHistory } from '@/api/types'
import ReorganizeDialog from '@/components/dialog/ReorganizeDialog.vue'
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import { useRoute } from 'vue-router'
import router from '@/router'
// 提示框
const $toast = useToast()
// 路由
const route = useRoute()
// 重新整理对话框
const redoDialog = ref(false)
@@ -70,6 +75,8 @@ const dataList = ref<TransferHistory[]>([])
// 搜索
const search = ref()
// 路由中有搜索参数时放到搜索框中
if (route.query.search) search.value = route.query.search
// 搜索提示词列表
const searchHintList = ref<string[]>([])
@@ -131,6 +138,8 @@ const totalPage = computed(() => {
watch(
[() => currentPage.value, () => itemsPerPage.value, () => search.value],
debounce(async () => {
// 清除路由参数
if (route.query.search) router.push("/history")
await fetchData()
}, 1000),
)

View File

@@ -166,6 +166,18 @@ function searchTorrent() {
emit('close')
}
// 跳转到历史记录页面
function searchHistory() {
if (!searchWord.value) return
router.push({
path: '/history',
query: {
search: searchWord.value
},
})
emit('close')
}
// 跳转插件页面
function showPlugin(pluginId: string) {
router.push({
@@ -290,6 +302,24 @@ onMounted(() => {
</VListItem>
</template>
</VHover>
<VHover>
<template #default="hover">
<VListItem
prepend-icon="mdi-history"
density="compact"
link
v-bind="hover.props"
@click="searchHistory"
>
<VListItemTitle>
搜索 <span class="font-bold">{{ searchWord }}</span> 相关的历史记录 ...
</VListItemTitle>
<template #append>
<VIcon v-if="hover.isHovering" icon="ri-corner-down-left-line" />
</template>
</VListItem>
</template>
</VHover>
<VListSubheader v-if="matchedSubscribeItems.length > 0"> 订阅 </VListSubheader>
<VHover
v-if="matchedSubscribeItems.length > 0"