Skip to content

Commit c85046e

Browse files
committed
🎈 perf: 添加下载成功提示
1 parent b7bd529 commit c85046e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/components/Header/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Layout, Typography, Button } from 'antd';
3-
import { StepBackwardFilled, StepForwardFilled, DownloadOutlined } from '@ant-design/icons';
3+
import { StepBackwardFilled, StepForwardFilled, ShareAltOutlined } from '@ant-design/icons';
44
import Input from '../Input';
55
import { downloadPreviewImage } from '../../utils/download';
66

@@ -82,7 +82,7 @@ const Header: React.FC<HeaderProps> = ({ isDarkMode, onSubmit, leftSiderCollapse
8282
<div style={{ marginLeft: 'auto', display: 'flex', alignItems: 'center', gap: '16px' }}>
8383
<Button
8484
type="default"
85-
icon={<DownloadOutlined style={{ color: isDarkMode ? '#ffffff' : '#000000' }} />}
85+
icon={<ShareAltOutlined style={{ color: isDarkMode ? '#ffffff' : '#000000' }} />}
8686
onClick={() => downloadPreviewImage()}
8787
style={{
8888
padding: 0,

src/utils/download.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import domtoimage from 'dom-to-image';
3+
import { message } from 'antd';
34

45
interface DownloadOptions {
56
scale?: number;
@@ -30,8 +31,10 @@ export const downloadPreviewImage = async (options: DownloadOptions = {}) => {
3031
link.download = `${repoName}.png`;
3132
link.href = dataUrl;
3233
link.click();
34+
message.success('图片已成功保存!');
3335
} catch (error) {
3436
console.error('下载图片时出错:', error);
37+
message.error('保存图片失败,请稍后重试');
3538
throw error;
3639
}
3740
};

0 commit comments

Comments
 (0)