feat: enhanced search functionality with translation support

This commit is contained in:
kangfenmao 2024-10-29 00:40:44 +08:00
parent 057efbf98c
commit bf5617393b
5 changed files with 18 additions and 5 deletions

View File

@ -180,6 +180,7 @@
"search.placeholder": "Search topics or messages...",
"continue_chat": "Continue Chatting",
"search.topics.empty": "No topics found, press Enter to search all messages",
"search.messages": "Search All Messages",
"locate.message": "Locate the message"
},
"provider": {

View File

@ -179,6 +179,7 @@
"search.placeholder": "搜索话题或消息...",
"continue_chat": "继续聊天",
"search.topics.empty": "没有找到相关话题, 点击回车键搜索所有消息",
"search.messages": "搜索所有消息",
"locate.message": "定位到消息"
},
"provider": {

View File

@ -179,6 +179,7 @@
"search.placeholder": "搜尋話題或訊息...",
"continue_chat": "繼續聊天",
"search.topics.empty": "沒有找到相關話題, 點擊回車鍵搜尋所有訊息",
"search.messages": "搜尋所有訊息",
"locate.message": "定位到訊息"
},
"provider": {

View File

@ -82,7 +82,12 @@ const TopicsPage: FC = () => {
/>
</Header>
<Divider style={{ margin: 0 }} />
<TopicsHistory keywords={search} onClick={onTopicClick as any} style={{ display: isShow('topics') }} />
<TopicsHistory
keywords={search}
onClick={onTopicClick as any}
onSearch={onSearch}
style={{ display: isShow('topics') }}
/>
<TopicMessages topic={topic} style={{ display: isShow('topic') }} />
<SearchResults
keywords={isShow('search') ? search : ''}

View File

@ -1,8 +1,9 @@
import { VStack } from '@renderer/components/Layout'
import { useAssistants } from '@renderer/hooks/useAssistant'
import useScrollPosition from '@renderer/hooks/useScrollPosition'
import { getTopicById } from '@renderer/hooks/useTopic'
import { Topic } from '@renderer/types'
import { Divider, Empty } from 'antd'
import { Button, Divider, Empty } from 'antd'
import dayjs from 'dayjs'
import { groupBy, isEmpty, orderBy } from 'lodash'
import { useTranslation } from 'react-i18next'
@ -11,9 +12,10 @@ import styled from 'styled-components'
type Props = {
keywords: string
onClick: (topic: Topic) => void
onSearch: () => void
} & React.HTMLAttributes<HTMLDivElement>
const TopicsHistory: React.FC<Props> = ({ keywords, onClick, ...props }) => {
const TopicsHistory: React.FC<Props> = ({ keywords, onClick, onSearch, ...props }) => {
const { assistants } = useAssistants()
const { t } = useTranslation()
const { handleScroll, containerRef } = useScrollPosition('TopicsHistory')
@ -31,9 +33,12 @@ const TopicsHistory: React.FC<Props> = ({ keywords, onClick, ...props }) => {
if (isEmpty(filteredTopics)) {
return (
<ListContainer {...props}>
<ContainerWrapper>
<VStack alignItems="center">
<Empty description={t('history.search.topics.empty')} />
</ContainerWrapper>
<Button style={{ width: 200, marginTop: 20 }} type="primary" onClick={onSearch}>
{t('history.search.messages')}
</Button>
</VStack>
</ListContainer>
)
}