Skip to content

Commit 6fa879d

Browse files
committed
🚸 导出图片时以文件名为命名
1 parent bf9d49b commit 6fa879d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/src/pages/_fixed_panel/_export_png_panel.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { StageExportPng } from "../../core/service/dataGenerateService/stageExpo
77
import { Camera } from "../../core/stage/Camera";
88
import { Dialog } from "../../components/dialog";
99
import { Download, RefreshCcw } from "lucide-react";
10+
import { Stage } from "../../core/stage/Stage";
11+
import { PathString } from "../../utils/pathString";
1012

1113
/**
1214
* 导出png的面板
@@ -29,7 +31,14 @@ export default function ExportPNGPanel() {
2931
if (image) {
3032
const a = document.createElement("a");
3133
a.href = image.src;
32-
a.download = `${123456}.png`;
34+
35+
let fileName = "file";
36+
if (Stage.path.isDraft()) {
37+
fileName = "草稿";
38+
} else {
39+
fileName = PathString.getFileNameFromPath(Stage.path.getFilePath());
40+
}
41+
a.download = `${fileName}.png`;
3342
a.click();
3443
} else {
3544
Dialog.show({
@@ -49,7 +58,10 @@ export default function ExportPNGPanel() {
4958
)}
5059
>
5160
<h2>导出png图片</h2>
52-
<div className="bg-panel-bg flex h-96 w-full items-center justify-center rounded-md" id="export-png-image-box">
61+
<div
62+
className="bg-panel-bg flex h-96 w-full items-center justify-center overflow-auto rounded-md"
63+
id="export-png-image-box"
64+
>
5365
<span>暂时没有渲染结果,请先点击渲染图片</span>
5466
</div>
5567
<div className="flex w-full items-center">

0 commit comments

Comments
 (0)