mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 13:59:28 +08:00
refactor: simplify font family handling and improve layout styles in MessageTools and ThinkingBlock components
This commit is contained in:
parent
35eaef1395
commit
9ff336c2b0
@ -8,13 +8,6 @@
|
|||||||
@import '../fonts/icon-fonts/iconfont.css';
|
@import '../fonts/icon-fonts/iconfont.css';
|
||||||
@import '../fonts/ubuntu/ubuntu.css';
|
@import '../fonts/ubuntu/ubuntu.css';
|
||||||
|
|
||||||
body {
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
*,
|
*,
|
||||||
*::before,
|
*::before,
|
||||||
*::after {
|
*::after {
|
||||||
@ -31,8 +24,18 @@ body {
|
|||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
html,
|
||||||
list-style: none;
|
body,
|
||||||
|
#root {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#root {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@ -44,9 +47,15 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-family: var(--font-family);
|
font-family: var(--font-family);
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
|
transition: background-color 0.3s linear;
|
||||||
|
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
transition: background-color 0.3s linear;
|
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
input,
|
input,
|
||||||
@ -67,20 +76,8 @@ a {
|
|||||||
-webkit-user-drag: none;
|
-webkit-user-drag: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
html,
|
ul {
|
||||||
body,
|
list-style: none;
|
||||||
#root {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#root {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
flex: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loader {
|
.loader {
|
||||||
|
|||||||
@ -23,12 +23,6 @@ const ThinkingBlock: React.FC<Props> = ({ block }) => {
|
|||||||
|
|
||||||
const isThinking = useMemo(() => block.status === MessageBlockStatus.STREAMING, [block.status])
|
const isThinking = useMemo(() => block.status === MessageBlockStatus.STREAMING, [block.status])
|
||||||
|
|
||||||
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 && thoughtAutoCollapse) {
|
if (!isThinking && thoughtAutoCollapse) {
|
||||||
setActiveKey('')
|
setActiveKey('')
|
||||||
@ -98,7 +92,11 @@ const ThinkingBlock: React.FC<Props> = ({ block }) => {
|
|||||||
),
|
),
|
||||||
children: (
|
children: (
|
||||||
// FIXME: 临时兼容
|
// FIXME: 临时兼容
|
||||||
<div style={{ fontFamily, fontSize }}>
|
<div
|
||||||
|
style={{
|
||||||
|
fontFamily: messageFont === 'serif' ? 'var(--font-family-serif)' : 'var(--font-family)',
|
||||||
|
fontSize
|
||||||
|
}}>
|
||||||
<Markdown block={block} />
|
<Markdown block={block} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -17,11 +17,6 @@ const MessageTools: FC<Props> = ({ blocks }) => {
|
|||||||
const [expandedResponse, setExpandedResponse] = useState<{ content: string; title: string } | null>(null)
|
const [expandedResponse, setExpandedResponse] = useState<{ content: string; title: string } | null>(null)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { messageFont, fontSize } = useSettings()
|
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])
|
|
||||||
|
|
||||||
const toolResponse = blocks.metadata?.rawMcpToolResponse
|
const toolResponse = blocks.metadata?.rawMcpToolResponse
|
||||||
|
|
||||||
@ -122,7 +117,11 @@ const MessageTools: FC<Props> = ({ blocks }) => {
|
|||||||
</MessageTitleLabel>
|
</MessageTitleLabel>
|
||||||
),
|
),
|
||||||
children: isDone && result && (
|
children: isDone && result && (
|
||||||
<ToolResponseContainer style={{ fontFamily, fontSize: '12px' }}>
|
<ToolResponseContainer
|
||||||
|
style={{
|
||||||
|
fontFamily: messageFont === 'serif' ? 'var(--font-family-serif)' : 'var(--font-family)',
|
||||||
|
fontSize: '12px'
|
||||||
|
}}>
|
||||||
<div className="markdown" dangerouslySetInnerHTML={{ __html: styledResult }} />
|
<div className="markdown" dangerouslySetInnerHTML={{ __html: styledResult }} />
|
||||||
</ToolResponseContainer>
|
</ToolResponseContainer>
|
||||||
)
|
)
|
||||||
@ -173,7 +172,11 @@ const MessageTools: FC<Props> = ({ blocks }) => {
|
|||||||
transitionName="animation-move-down"
|
transitionName="animation-move-down"
|
||||||
styles={{ body: { maxHeight: '80vh', overflow: 'auto' } }}>
|
styles={{ body: { maxHeight: '80vh', overflow: 'auto' } }}>
|
||||||
{expandedResponse && (
|
{expandedResponse && (
|
||||||
<ExpandedResponseContainer style={{ fontFamily, fontSize }}>
|
<ExpandedResponseContainer
|
||||||
|
style={{
|
||||||
|
fontFamily: messageFont === 'serif' ? 'var(--font-family-serif)' : 'var(--font-family)',
|
||||||
|
fontSize
|
||||||
|
}}>
|
||||||
{/* mode swtich tabs */}
|
{/* mode swtich tabs */}
|
||||||
<Tabs
|
<Tabs
|
||||||
tabBarExtraContent={
|
tabBarExtraContent={
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user