feat: 添加导出图层功能,支持将图层转换为位图图像并下载

This commit is contained in:
bighuixiang
2025-06-23 15:56:01 +08:00
parent 1fde475806
commit 5d0511e405
10 changed files with 405 additions and 68 deletions

View File

@@ -665,7 +665,19 @@ function buildContextMenuItems(layer) {
hideContextMenu();
},
},
// 栅格化图层
{
label: "导出图层",
icon: "CExport",
disabled:
layer.isBackground ||
layer.isFixed ||
!layerManager?.canRasterizeLayer?.(layer.id),
action: () => {
exportLayerToImage(layer.id);
hideContextMenu();
},
},
{ type: "divider" },
// 分组操作 - 带子菜单
{
@@ -1107,6 +1119,25 @@ async function rasterizeLayer(layerId) {
}
}
// 导出图层
async function exportLayerToImage(layerId) {
if (!layerManager?.rasterizeLayer) {
console.warn("导出图层功能不可用");
return;
}
try {
const success = await layerManager.exportLayerToImage(layerId);
if (success) {
console.log(`✅ 成功导出图层: ${layerId}`);
} else {
console.warn("导出图层失败");
}
} catch (error) {
console.error("导出图层时发生错误:", error);
}
}
// 合并组图层
async function mergeGroupLayer(groupId) {
if (!layerManager?.mergeGroupLayers) {