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

搜索主题

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