refactor: update AttachmentButton styling and integrate into Inputbar

- Adjusted the font size of the PaperClipOutlined icon in the AttachmentButton for better visibility.
- Integrated the AttachmentButton into the Inputbar component, replacing the TranslateButton in one instance for improved functionality.
This commit is contained in:
kangfenmao 2025-03-17 15:28:45 +08:00
parent 827d5c58d0
commit 6a187fd370
3 changed files with 11 additions and 42 deletions

View File

@ -4,10 +4,9 @@ import { useSettings } from '@renderer/hooks/useSettings'
import { fetchTranslate } from '@renderer/services/ApiService' import { fetchTranslate } from '@renderer/services/ApiService'
import { getDefaultTopic, getDefaultTranslateAssistant } from '@renderer/services/AssistantService' import { getDefaultTopic, getDefaultTranslateAssistant } from '@renderer/services/AssistantService'
import { getUserMessage } from '@renderer/services/MessagesService' import { getUserMessage } from '@renderer/services/MessagesService'
import { Button, Tooltip } from 'antd' import { Tooltip } from 'antd'
import { FC, useEffect, useState } from 'react' import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
interface Props { interface Props {
text?: string text?: string
@ -15,9 +14,10 @@ interface Props {
disabled?: boolean disabled?: boolean
style?: React.CSSProperties style?: React.CSSProperties
isLoading?: boolean isLoading?: boolean
ToolbarButton: any
} }
const TranslateButton: FC<Props> = ({ text, onTranslated, disabled, style, isLoading }) => { const TranslateButton: FC<Props> = ({ text, onTranslated, disabled, style, isLoading, ToolbarButton }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { translateModel } = useDefaultModel() const { translateModel } = useDefaultModel()
const [isTranslating, setIsTranslating] = useState(false) const [isTranslating, setIsTranslating] = useState(false)
@ -88,40 +88,4 @@ const TranslateButton: FC<Props> = ({ text, onTranslated, disabled, style, isLoa
) )
} }
const ToolbarButton = styled(Button)`
min-width: 30px;
height: 30px;
font-size: 16px;
border-radius: 50%;
transition: all 0.3s ease;
color: var(--color-icon);
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 0;
&.anticon,
&.iconfont {
transition: all 0.3s ease;
color: var(--color-icon);
}
&:hover {
background-color: var(--color-background-soft);
.anticon,
.iconfont {
color: var(--color-text-1);
}
}
&.active {
background-color: var(--color-primary) !important;
.anticon,
.iconfont {
color: var(--color-white-soft);
}
&:hover {
background-color: var(--color-primary);
}
}
`
export default TranslateButton export default TranslateButton

View File

@ -42,7 +42,7 @@ const AttachmentButton: FC<Props> = ({ model, files, setFiles, ToolbarButton, di
title={isVisionModel(model) ? t('chat.input.upload') : t('chat.input.upload.document')} title={isVisionModel(model) ? t('chat.input.upload') : t('chat.input.upload.document')}
arrow> arrow>
<ToolbarButton type="text" className={files.length ? 'active' : ''} onClick={onSelectFile} disabled={disabled}> <ToolbarButton type="text" className={files.length ? 'active' : ''} onClick={onSelectFile} disabled={disabled}>
<PaperClipOutlined style={{ rotate: '135deg' }} /> <PaperClipOutlined style={{ fontSize: 17 }} />
</ToolbarButton> </ToolbarButton>
</Tooltip> </Tooltip>
) )

View File

@ -707,6 +707,7 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
</DragHandle> </DragHandle>
<Toolbar> <Toolbar>
<ToolbarMenu> <ToolbarMenu>
<AttachmentButton model={model} files={files} setFiles={setFiles} ToolbarButton={ToolbarButton} />
<MentionModelsButton <MentionModelsButton
mentionModels={mentionModels} mentionModels={mentionModels}
onMentionModel={(model) => onMentionModel(model, mentionFromKeyboard)} onMentionModel={(model) => onMentionModel(model, mentionFromKeyboard)}
@ -734,7 +735,6 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
ToolbarButton={ToolbarButton} ToolbarButton={ToolbarButton}
/> />
)} )}
<TranslateButton text={text} onTranslated={onTranslated} isLoading={isTranslating} />
<Tooltip placement="top" title={t('chat.input.clear', { Command: cleanTopicShortcut })} arrow> <Tooltip placement="top" title={t('chat.input.clear', { Command: cleanTopicShortcut })} arrow>
<Popconfirm <Popconfirm
title={t('chat.input.clear.content')} title={t('chat.input.clear.content')}
@ -770,7 +770,12 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
/> />
</ToolbarMenu> </ToolbarMenu>
<ToolbarMenu> <ToolbarMenu>
<AttachmentButton model={model} files={files} setFiles={setFiles} ToolbarButton={ToolbarButton} /> <TranslateButton
text={text}
onTranslated={onTranslated}
isLoading={isTranslating}
ToolbarButton={ToolbarButton}
/>
{loading && ( {loading && (
<Tooltip placement="top" title={t('chat.input.pause')} arrow> <Tooltip placement="top" title={t('chat.input.pause')} arrow>
<ToolbarButton type="text" onClick={onPause} style={{ marginRight: -2, marginTop: 1 }}> <ToolbarButton type="text" onClick={onPause} style={{ marginRight: -2, marginTop: 1 }}>