refactor(admin): 用已安装的 file-saver/fast-deep-equal 替代手写下载与 JSON 比较

This commit is contained in:
2026-08-08 17:11:10 +08:00
parent 01cceea237
commit dab28f85e8
6 changed files with 16 additions and 43 deletions

View File

@@ -1,4 +1,5 @@
import React, { lazy, Suspense, useEffect, useMemo, useState } from 'react';
import { saveAs } from 'file-saver';
import { XCard, registerCatalog, type XAgentCommand_v0_9 } from '@ant-design/x-card';
import { Button, Spin, Tag, Tooltip, Typography } from 'antd';
import { DownloadOutlined } from '@ant-design/icons';
@@ -232,12 +233,7 @@ const ChartPreview: React.FC<ChartPreviewProps> = ({ chart }) => {
pixelRatio: 2,
backgroundColor: '#fff',
});
const link = document.createElement('a');
link.href = url;
link.download = `${chart.title || '图表'}.png`;
document.body.appendChild(link);
link.click();
link.remove();
saveAs(url, `${chart.title || '图表'}.png`);
};
return (