Skip to content

Commit fd1a4ca

Browse files
committed
🐛 将mac导出png图片的下载地址设置为Download文件夹
1 parent e396bd1 commit fd1a4ca

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/src/pages/_fixed_panel/_export_png_panel.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { cn } from "../../utils/cn";
1010
import { StageManager } from "../../core/stage/stageManager/StageManager";
1111
import { isMac } from "../../utils/platform";
1212
import { writeFileBase64 } from "../../utils/fs";
13+
import { downloadDir } from "@tauri-apps/api/path";
1314

1415
/**
1516
* 导出png的面板
@@ -44,7 +45,7 @@ export default function ExportPNGPanel() {
4445

4546
const [cameraScaleWhenExport, setCameraScaleWhenExport] = useState(0.5);
4647

47-
const downloadImage = () => {
48+
const downloadImage = async () => {
4849
const imageBox = document.getElementById("export-png-image-box") as HTMLDivElement;
4950
const image = imageBox.querySelector("img") as HTMLImageElement;
5051
if (!image) {
@@ -60,11 +61,12 @@ export default function ExportPNGPanel() {
6061
if (isMac) {
6162
try {
6263
const base64Data = image.src.split(",")[1];
63-
const filePath = `${fileName}.png`;
64-
writeFileBase64(filePath, base64Data);
64+
const downloadsDir = await downloadDir();
65+
const filePath = `${downloadsDir}/${fileName}.png`;
66+
await writeFileBase64(filePath, base64Data);
6567
Dialog.show({
6668
title: "导出成功",
67-
content: `图片已保存,名称为 ${filePath},用访达搜索该文件可以找到它`,
69+
content: `图片已保存到下载文件夹: ${filePath}`,
6870
});
6971
} catch (error) {
7072
Dialog.show({

0 commit comments

Comments
 (0)