feat: 优化部分问题,完善选区功能

This commit is contained in:
bighuixiang
2025-07-04 03:16:18 +08:00
parent b6afd2764d
commit 0615ab31f9
12 changed files with 1892 additions and 1144 deletions

View File

@@ -31,7 +31,7 @@ import BrushControlPanel from "./components/BrushControlPanel.vue";
import TextEditorPanel from "./components/TextEditorPanel.vue"; // 引入文本编辑面板
import LiquifyPanel from "./components/LiquifyPanel.vue"; // 引入液化编辑面板
import SelectionPanel from "./components/SelectionPanel.vue"; // 引入选区面板
import { OperationType } from "./utils/layerHelper.js";
import { LayerType, OperationType } from "./utils/layerHelper.js";
import { ToolManager } from "./managers/toolManager.js";
import { fabric } from "fabric-with-all";
import {
@@ -521,7 +521,12 @@ function updateCanvasColor() {
}
async function addLayer() {
await layerManager.createLayer();
await layerManager.createLayer("空图层");
}
async function addTopLayer() {
await layerManager.createLayer("空图层", LayerType.EMPTY, {
insertTop: true,
});
}
function setActiveLayer(layerId) {
@@ -877,6 +882,24 @@ defineExpose({
if (!layerManager) return false;
return layerManager.batchReorderLayers(reorderOperations);
},
/**
* 切换图层可见性
* @param {string} layerId 图层ID
* @returns {boolean} 更新后的可见性状态
*/
toggleLayerVisibility(layerId) {
if (!layerManager) return false;
return layerManager.toggleLayerVisibility(layerId);
},
/**
* 获取图层可见性状态
* @param {string} layerId 图层ID
* @returns {boolean} 图层是否可见
*/
getLayerVisibility(layerId) {
if (!layerManager) return false;
return layerManager.getLayerVisibility(layerId);
},
});
</script>
@@ -1002,6 +1025,7 @@ defineExpose({
:thumbnailManager="canvasManager.thumbnailManager"
:showFixedLayer="showFixedLayer"
@add-layer="addLayer"
@add-top-layer="addTopLayer"
@set-active-layer="setActiveLayer"
@toggle-layer-visibility="toggleLayerVisibility"
@move-layer-up="moveLayerUp"