Browse Source

change ai chat search

master
godo 6 months ago
parent
commit
51c63bd7fe
  1. 25
      frontend/src/components/localchat/AiChatLeft.vue
  2. 5
      frontend/src/stores/aichat.ts

25
frontend/src/components/localchat/AiChatLeft.vue

@ -4,7 +4,21 @@ import { Search } from "@element-plus/icons-vue";
// import { t } from "@/i18n"; // import { t } from "@/i18n";
// import { notifyInfo,notifySuccess } from "@/util/msg.ts"; // import { notifyInfo,notifySuccess } from "@/util/msg.ts";
const chatStore = useAiChatStore(); const chatStore = useAiChatStore();
const handleSearch = async () => {
if (chatStore.searchInput != "") {
const list = await chatStore.getChatList()
const res = list.filter((item: any) => {
if (item.title.includes(chatStore.searchInput)) {
return item;
}
})
if(res.length > 0){
chatStore.chatList = res
}
}else{
await chatStore.getChatList()
}
};
</script> </script>
<template> <template>
@ -13,7 +27,8 @@ const chatStore = useAiChatStore();
</el-dialog> </el-dialog>
<el-scrollbar> <el-scrollbar>
<el-header class="search"> <el-header class="search">
<el-input placeholder="搜索" :prefix-icon="Search" class="search-input" v-model="chatStore.searchInput" /> <el-input placeholder="搜索" @keyup.enter="handleSearch" :prefix-icon="Search" class="search-input"
v-model="chatStore.searchInput" />
<button class="add-chat" @click="chatStore.showBox(false)"> <button class="add-chat" @click="chatStore.showBox(false)">
<el-icon> <el-icon>
<Plus /> <Plus />
@ -84,7 +99,8 @@ const chatStore = useAiChatStore();
background-color: #fff; background-color: #fff;
} }
.list-item:hover,.list-item.active { .list-item:hover,
.list-item.active {
background-color: #e8f3ff; background-color: #e8f3ff;
} }
@ -102,7 +118,8 @@ const chatStore = useAiChatStore();
align-items: center; align-items: center;
padding-right: 10px; padding-right: 10px;
} }
.iconlist .el-icon{
.iconlist .el-icon {
cursor: pointer; cursor: pointer;
} }
</style> </style>

5
frontend/src/stores/aichat.ts

@ -48,8 +48,9 @@ export const useAiChatStore = defineStore('aichat', () => {
return { chatInfo, messageList, chatList } return { chatInfo, messageList, chatList }
} }
const getChatList = async () => { const getChatList = async () => {
chatList.value = await db.getAll('aichatlist') const list = await db.getAll('aichatlist')
return chatList chatList.value = list
return list
} }
// 添加聊天 // 添加聊天
async function addChat(title: string, model: any, promptData: any, knowledgeId: string) { async function addChat(title: string, model: any, promptData: any, knowledgeId: string) {

Loading…
Cancel
Save