Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/renderer/src/components/Preview/ImagePreviewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ImagePreviewLayoutProps {
loading?: boolean
error?: string | null
enableToolbar?: boolean
onExplainImage?: () => void
className?: string
}

Expand All @@ -26,6 +27,7 @@ const ImagePreviewLayout = ({
loading,
error,
enableToolbar,
onExplainImage,
className
}: ImagePreviewLayoutProps) => {
// 使用通用图像工具
Expand All @@ -51,7 +53,7 @@ const ImagePreviewLayout = ({
<PreviewContainer vertical className={`image-preview-layout ${className ?? ''}`}>
{error && <PreviewError>{error}</PreviewError>}
{children}
{!error && enableToolbar && <ImageToolbar pan={pan} zoom={zoom} dialog={dialog} />}
{!error && enableToolbar && <ImageToolbar pan={pan} zoom={zoom} dialog={dialog} onExplainImage={onExplainImage} />}
</PreviewContainer>
</Spin>
)
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/src/components/Preview/ImageToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ImageToolbarProps {
className?: string
}

const ImageToolbar = ({ pan, zoom, dialog, className }: ImageToolbarProps) => {
const ImageToolbar = ({ pan, zoom, dialog, onExplainImage, className }: ImageToolbarProps) => {
const { t } = useTranslation()

// 定义平移距离
Expand All @@ -38,6 +38,13 @@ const ImageToolbar = ({ pan, zoom, dialog, className }: ImageToolbarProps) => {
icon={<ChevronUp size={'1rem'} />}
onClick={() => pan(0, -panDistance)}
/>
{onExplainImage && (
<ImageToolButton
tooltip={t('preview.explain_image')}
icon={<Sparkles size={'1rem'} />}
onClick={onExplainImage}
/>
)}
<ImageToolButton tooltip={t('preview.dialog')} icon={<Scan size={'1rem'} />} onClick={dialog} />
</ActionButtonRow>

Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/i18n/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,7 @@
"image": "Copy as image"
},
"dialog": "Open Dialog",
"explain_image": "Explain Image",
"label": "Preview",
"pan": "Pan",
"pan_down": "Pan Down",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/i18n/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,7 @@
"image": "复制为图片"
},
"dialog": "打开预览窗口",
"explain_image": "解释图片",
"label": "预览",
"pan": "移动",
"pan_down": "下移",
Expand Down