This commit is contained in:
李志鹏
2026-01-06 16:53:18 +08:00
parent 6cb1e72798
commit e40b707501
3 changed files with 17 additions and 13 deletions

View File

@@ -58,6 +58,7 @@ const emit = defineEmits([
"changeCanvas", // 画布变更事件
"canvasInit", // 画布初始化事件
"trigger-library", // 触发打开Library选择图片事件
"before-unmount-export-extra-info", // 组件卸载前导出额外信息事件
]);
const props = defineProps({
@@ -544,12 +545,15 @@ watchEffect(() => {
}
});
onBeforeUnmount(() => {
onBeforeUnmount(async () => {
// if (import.meta.hot) {
// // 热更新
// console.log("onBeforeUnmount 开发环境热更新不卸载组件...");
// return; // 开发环境下不卸载组件
// }
const extraInfo = await canvasManager.exportExtraInfo();
emit("before-unmount-export-extra-info", extraInfo);
console.log("onBeforeUnmount 组件卸载,清理资源...");
canvasManager?.dispose?.();
commandManager?.dispose?.();
@@ -1053,8 +1057,8 @@ defineExpose({
* 导出所有信息
* @returns {Object} 包含所有图层信息的对象
*/
exportAllInfo: () => {
return canvasManager.exportAllInfo();
exportExtraInfo: () => {
return canvasManager.exportExtraInfo();
},
/**

View File

@@ -977,10 +977,10 @@ export class CanvasManager {
}
/**
* 导出所有信息
* @returns {Object} 包含所有图层信息的对象
* 导出印花元素颜色信息
* @returns {Object}
*/
async exportAllInfo() {
async exportExtraInfo() {
// 导出颜色图层信息
const color = await this.exportColorLayer().catch(() => (null));
// 导出印花和元素图层信息

View File

@@ -102,10 +102,10 @@ const exportColorLayer = async () => {
};
// 导出所有信息
const exportAllInfo = async () => {
const exportExtraInfo = async () => {
if (canvasEditor.value) {
const allInfo = await canvasEditor.value.exportAllInfo();
console.log("==========导出所有信息:", allInfo);
const extraInfo = await canvasEditor.value.exportExtraInfo();
console.log("==========导出信息:", extraInfo);
}
};
@@ -213,10 +213,10 @@ const customToolsList = ref([
class: "export-btn",
},
{
id: "exportAllInfo",
title: "导出所有信息",
action: exportAllInfo,
label: "导All",
id: "exportExtraInfo",
title: "导出印花颜色等信息",
action: exportExtraInfo,
label: "导E",
class: "export-btn",
},
{