Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kangfenmao committed Oct 5, 2024
1 parent 4cc140e commit cf98675
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
7 changes: 1 addition & 6 deletions src/renderer/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import './assets/styles/index.scss'
import './init'

import React from 'react'
import ReactDOM from 'react-dom/client'

import App from './App'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
)
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<App />)
2 changes: 1 addition & 1 deletion src/renderer/src/pages/files/FilesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const ContentContainer = styled.div`
justify-content: center;
height: 100%;
overflow-y: scroll;
padding: 20px;
padding: 15px;
`

const FileNameText = styled.div`
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/src/pages/history/components/SearchMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import { getTopicById } from '@renderer/hooks/useTopic'
import { default as MessageItem } from '@renderer/pages/home/Messages/Message'
import { getAssistantById } from '@renderer/services/assistant'
import { EVENT_NAMES, EventEmitter } from '@renderer/services/event'
import { Message } from '@renderer/types'
import { Button } from 'antd'
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import styled from 'styled-components'

interface Props extends React.HTMLAttributes<HTMLDivElement> {
message?: Message
}

const SearchMessage: FC<Props> = ({ message, ...props }) => {
const { t } = useTranslation()
const navigate = useNavigate()

if (!message) {
return null
}

const onContinueChat = async (message: Message) => {
const assistant = getAssistantById(message.assistantId)
const topic = await getTopicById(message.topicId)
navigate('/', { state: { assistant, topic } })
setTimeout(() => EventEmitter.emit(EVENT_NAMES.SHOW_TOPIC_SIDEBAR), 100)
}

return (
<MessagesContainer {...props}>
<ContainerWrapper style={{ paddingTop: 30, paddingBottom: 30 }}>
<MessageItem message={message} showMenu={false} />
<Button type="link" onClick={() => onContinueChat(message)}>
{t('history.continue_chat')}
</Button>
</ContainerWrapper>
</MessagesContainer>
)
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/src/pages/home/Assistants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const AssistantItem = styled.div`
justify-content: space-between;
padding: 7px 10px;
position: relative;
border-radius: 4px;
border-radius: 17px;
margin: 0 10px;
padding-right: 35px;
font-family: Ubuntu;
Expand All @@ -239,7 +239,6 @@ const AssistantItem = styled.div`
&.active {
background-color: var(--color-background-mute);
.name {
font-weight: 500;
}
.topics-count {
display: none;
Expand Down
14 changes: 2 additions & 12 deletions src/renderer/src/pages/home/Topics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
return (
<Dropdown menu={{ items: getTopicMenuItems(topic) }} trigger={['contextMenu']} key={topic.id}>
<TopicListItem className={isActive ? 'active' : ''} onClick={() => onSwitchTopic(topic)}>
<TopicName className="name">
<TopicHash>#</TopicHash>
{topic.name.replace('`', '')}
</TopicName>
<TopicName className="name">{topic.name.replace('`', '')}</TopicName>
{assistant.topics.length > 1 && isActive && (
<MenuButton
className="menu"
Expand Down Expand Up @@ -187,7 +184,7 @@ const Container = styled.div`
const TopicListItem = styled.div`
padding: 7px 10px;
margin: 0 10px;
border-radius: 4px;
border-radius: 17px;
font-family: Ubuntu;
font-size: 13px;
display: flex;
Expand All @@ -211,7 +208,6 @@ const TopicListItem = styled.div`
background-color: var(--color-background-mute);
.name {
opacity: 1;
font-weight: 500;
}
.menu {
opacity: 1;
Expand Down Expand Up @@ -247,10 +243,4 @@ const MenuButton = styled.div`
}
`

const TopicHash = styled.span`
font-size: 13px;
color: var(--color-text-3);
margin-right: 2px;
`

export default Topics

0 comments on commit cf98675

Please sign in to comment.