Fix: Font size and Latex problem, resolve CherryHQ#1034 CherryHQ#1596 (#1723)
This commit is contained in:
parent
2c5fe01fbf
commit
1473cb3123
@ -1,10 +1,11 @@
|
|||||||
import { Message } from '@renderer/types'
|
import { Message } from '@renderer/types'
|
||||||
import { Collapse } from 'antd'
|
import { Collapse } from 'antd'
|
||||||
import { FC, useEffect, useState } from 'react'
|
import { FC, useEffect, useState, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import ReactMarkdown from 'react-markdown'
|
|
||||||
import BarLoader from 'react-spinners/BarLoader'
|
import BarLoader from 'react-spinners/BarLoader'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
import Markdown from '../Markdown/Markdown'
|
||||||
|
import { useSettings } from '@renderer/hooks/useSettings'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
message: Message
|
message: Message
|
||||||
@ -14,6 +15,12 @@ const MessageThought: FC<Props> = ({ message }) => {
|
|||||||
const [activeKey, setActiveKey] = useState<'thought' | ''>('thought')
|
const [activeKey, setActiveKey] = useState<'thought' | ''>('thought')
|
||||||
const isThinking = !message.content
|
const isThinking = !message.content
|
||||||
const { t } = useTranslation()
|
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(() => {
|
useEffect(() => {
|
||||||
if (!isThinking) setActiveKey('')
|
if (!isThinking) setActiveKey('')
|
||||||
@ -42,7 +49,11 @@ const MessageThought: FC<Props> = ({ message }) => {
|
|||||||
{isThinking && <BarLoader color="#9254de" />}
|
{isThinking && <BarLoader color="#9254de" />}
|
||||||
</MessageTitleLabel>
|
</MessageTitleLabel>
|
||||||
),
|
),
|
||||||
children: <ReactMarkdown className="markdown">{message.reasoning_content}</ReactMarkdown>
|
children: (
|
||||||
|
<div style={{ fontFamily, fontSize }}>
|
||||||
|
<Markdown message={{ ...message, content: message.reasoning_content }} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user