提交 d6da0899 编写于 作者: View Design's avatar View Design

搜索主题

上级 23c4bb66
......@@ -25,9 +25,11 @@
<div class="flex">
<IActionCollect :id="collectId" v-if="collect" />
</div>
<div class="flex">
<div class="flex" v-if="!collect">
<UInput
name="queryInput"
v-model="searchQuery"
:loading="searchLoading"
icon="i-heroicons-magnifying-glass-20-solid"
placeholder="搜索你的主题..."
size="md"
......@@ -59,5 +61,18 @@ defineProps({
default: ''
}
})
const emit = defineEmits(['search'])
const searchQuery = ref('')
const searchLoading = ref(false)
defineShortcuts({
enter: {
usingInput: 'queryInput',
handler: async () => {
searchLoading.value = true
const { data } = await useRequest(`/v1/chat/completion/list?keyword=${searchQuery.value}`)
searchLoading.value = false
emit('search', data.value.data)
}
}
})
</script>
<template>
<div class="w-full items-center flex flex-col">
<ILibraryHeader />
<ILibraryHeader @search="handleSearch" />
<div class="container max-w-screen-lg flex flex-col p-6">
<div class="flex gap-10">
<div class="flex flex-col flex-grow">
......@@ -57,4 +57,7 @@ function handleDeletedThread (c_id) {
const findIndex = threads.value.findIndex(i => i.c_id === c_id)
if (findIndex >= 0) threads.value.splice(findIndex, 1)
}
function handleSearch (data) {
threads.value = data
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册