feat(chat-sdk/chatitem): 消息支持导出图表图片 (#1937)

This commit is contained in:
pisces
2024-12-23 09:05:56 +08:00
committed by GitHub
parent 5de5b0a5e2
commit 642d6a02e1
9 changed files with 274 additions and 124 deletions

View File

@@ -1,16 +1,25 @@
import { isMobile } from '../../utils/utils';
import { DislikeOutlined, LikeOutlined, DownloadOutlined, RedoOutlined } from '@ant-design/icons';
import {
DislikeOutlined,
LikeOutlined,
DownloadOutlined,
RedoOutlined,
FileJpgOutlined,
} from '@ant-design/icons';
import { Button } from 'antd';
import { CLS_PREFIX } from '../../common/constants';
import { useState } from 'react';
import { useContext, useState } from 'react';
import classNames from 'classnames';
import { updateQAFeedback } from '../../service';
import { useMethodRegister } from '../../hooks';
import { ChartItemContext } from '../ChatItem';
type Props = {
queryId: number;
scoreValue?: number;
isLastMessage?: boolean;
isParserError?: boolean;
isSimpleMode?: boolean;
onExportData?: () => void;
onReExecute?: (queryId: number) => void;
};
@@ -20,6 +29,7 @@ const Tools: React.FC<Props> = ({
scoreValue,
isLastMessage,
isParserError = false,
isSimpleMode = false,
onExportData,
onReExecute,
}) => {
@@ -44,6 +54,8 @@ const Tools: React.FC<Props> = ({
[`${prefixCls}-feedback-active`]: score === 1,
});
const { call } = useContext(ChartItemContext);
return (
<div className={prefixCls}>
{!isMobile && (
@@ -68,6 +80,18 @@ const Tools: React.FC<Props> = ({
<DownloadOutlined />
<span className={`${prefixCls}-font-style`}></span>
</Button>
{!isSimpleMode && (
<Button
size="small"
onClick={() => {
call('downloadChartAsImage');
}}
type="text"
>
<FileJpgOutlined />
<span className={`${prefixCls}-font-style`}></span>
</Button>
)}
{isLastMessage && (
<Button
size="small"