feat: 添加异步导出功能,优化导出图片的下载流程

This commit is contained in:
bighuixiang
2025-07-22 20:39:10 +08:00
parent 3652e0a384
commit 46ef450dfb
4 changed files with 152 additions and 56 deletions

View File

@@ -64,12 +64,20 @@ const editorConfig = {
backgroundColor: "#ffffff", // 画布背景色
};
const exportImage = () => {
const exportImage = async () => {
if (canvasEditor.value) {
canvasEditor.value.exportImage({
const base64 = await canvasEditor.value.exportImage({
isContainFixed: true, // 是否导出底图
isContainBg: false, // 是否导出背景
});
// 模拟下载图片
const link = document.createElement("a");
link.href = base64;
link.download = "canvas_image.png"; // 设置下载文件名
document.body.appendChild(link);
link.click(); // 触发下载
document.body.removeChild(link); // 下载后移除链接元素
}
};