保存画布排除特殊图层

This commit is contained in:
李志鹏
2026-01-06 15:09:02 +08:00
parent 466d278b29
commit 59541a9d3d
2 changed files with 45 additions and 29 deletions

View File

@@ -155,15 +155,19 @@ export function validateLayerAssociations(layers, canvasObjects) {
/**
* 简化layers对象属性只保留必要的属性
* @param {Array} layers 图层数组
* @param {Array} excludedLayers 排除的图层ID数组
* @returns {Array} 简化后的图层数组
*/
export function simplifyLayers(layers) {
export function simplifyLayers(layers, excludedLayers = []) {
if (!layers || !isArray(layers)) {
console.warn("simplifyLayers 请传入有效的图层数组:", layers);
return [];
}
return layers.map((layer) => {
// 检查是否在排除列表中
if (excludedLayers && excludedLayers.includes(layer.id)) return null;
const simplifiedLayer = {
id: layer.id,
name: layer.name,
@@ -215,7 +219,7 @@ export function simplifyLayers(layers) {
};
return simplifiedLayer;
});
}).filter((layer) => !!layer);
}
/**