Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Font size and Latex problem, resolve CherryHQ#1034 CherryHQ#1596 #1723

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/renderer/src/pages/home/Messages/MessageThought.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Message } from '@renderer/types'
import { Collapse } from 'antd'
import { FC, useEffect, useState } from 'react'
import { FC, useEffect, useState, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import ReactMarkdown from 'react-markdown'
import BarLoader from 'react-spinners/BarLoader'
import styled from 'styled-components'
import Markdown from '../Markdown/Markdown'
import { useSettings } from '@renderer/hooks/useSettings'

interface Props {
message: Message
Expand All @@ -14,6 +15,12 @@ const MessageThought: FC<Props> = ({ message }) => {
const [activeKey, setActiveKey] = useState<'thought' | ''>('thought')
const isThinking = !message.content
const { t } = useTranslation()
const { messageFont, fontSize } = useSettings()
const fontFamily = useMemo(() => {
return messageFont === 'serif'
? 'serif'
: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans","Helvetica Neue", sans-serif'
}, [messageFont])

useEffect(() => {
if (!isThinking) setActiveKey('')
Expand Down Expand Up @@ -42,7 +49,11 @@ const MessageThought: FC<Props> = ({ message }) => {
{isThinking && <BarLoader color="#9254de" />}
</MessageTitleLabel>
),
children: <ReactMarkdown className="markdown">{message.reasoning_content}</ReactMarkdown>
children: (
<div style={{ fontFamily, fontSize }}>
<Markdown message={{ ...message, content: message.reasoning_content }} />
</div>
)
}
]}
/>
Expand Down