印花图层禁用画笔等工具
This commit is contained in:
@@ -153,7 +153,7 @@ const canvasManagerLoaded = ref(false); // 画布是否加载完成
|
|||||||
// 红绿图模式状态
|
// 红绿图模式状态
|
||||||
const isRedGreenMode = ref(false);
|
const isRedGreenMode = ref(false);
|
||||||
|
|
||||||
const isShowLayerPanel = ref(true); // 是否显示图层面板
|
const isShowLayerPanel = ref(false); // 是否显示图层面板
|
||||||
|
|
||||||
provide("isShowLayerPanel", isShowLayerPanel); // 提供红绿图模式状态给子组件
|
provide("isShowLayerPanel", isShowLayerPanel); // 提供红绿图模式状态给子组件
|
||||||
|
|
||||||
@@ -546,13 +546,9 @@ watchEffect(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(async () => {
|
onBeforeUnmount(async () => {
|
||||||
// if (import.meta.hot) {
|
observer.unobserve(canvasContainerRef.value);
|
||||||
// // 热更新 ?
|
// const extraInfo = await canvasManager.exportExtraInfo();
|
||||||
// console.log("onBeforeUnmount 开发环境热更新不卸载组件...");
|
// emit("before-unmount-export-extra-info", extraInfo);
|
||||||
// return; // 开发环境下不卸载组件
|
|
||||||
// }
|
|
||||||
const extraInfo = await canvasManager.exportExtraInfo();
|
|
||||||
emit("before-unmount-export-extra-info", extraInfo);
|
|
||||||
|
|
||||||
console.log("onBeforeUnmount 组件卸载,清理资源...");
|
console.log("onBeforeUnmount 组件卸载,清理资源...");
|
||||||
canvasManager?.dispose?.();
|
canvasManager?.dispose?.();
|
||||||
@@ -576,7 +572,6 @@ onBeforeUnmount(async () => {
|
|||||||
|
|
||||||
// 移除window resize事件监听
|
// 移除window resize事件监听
|
||||||
// window.removeEventListener("resize", handleWindowResize);
|
// window.removeEventListener("resize", handleWindowResize);
|
||||||
observer.unobserve(canvasContainerRef.value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 窗口大小变化处理函数
|
// 窗口大小变化处理函数
|
||||||
@@ -584,6 +579,7 @@ function handleWindowResize() {
|
|||||||
console.log(132);
|
console.log(132);
|
||||||
// 使用requestAnimationFrame来防止频繁更新
|
// 使用requestAnimationFrame来防止频繁更新
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if(!canvasManager) return;
|
||||||
// 更新画布大小并自动居中所有元素
|
// 更新画布大小并自动居中所有元素
|
||||||
updateCanvasSize();
|
updateCanvasSize();
|
||||||
|
|
||||||
|
|||||||
@@ -458,11 +458,31 @@ export class ToolManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查当前工具是否禁止操作当前选中的对象
|
||||||
|
* @param {Boolean} isBrushTool 是否为画笔工具
|
||||||
|
* @returns {Boolean} 是否可以切换
|
||||||
|
*/
|
||||||
|
checkToolCanOperateSelectedObject(isBrushTool = false) {
|
||||||
|
const layer = this.layerManager?.getActiveLayer();
|
||||||
|
const isSpecialLayer = !!layer?.specialType;
|
||||||
|
if (isSpecialLayer) {
|
||||||
|
if(isBrushTool){
|
||||||
|
this._disableBrushIndicator();
|
||||||
|
}
|
||||||
|
this.canvas.defaultCursor = "not-allowed";
|
||||||
|
}
|
||||||
|
console.log("===========",isSpecialLayer, this.canvas.defaultCursor);
|
||||||
|
return isSpecialLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置画笔工具
|
* 设置画笔工具
|
||||||
*/
|
*/
|
||||||
setupBrushTool() {
|
setupBrushTool() {
|
||||||
if (!this.canvas) return;
|
if (!this.canvas) return;
|
||||||
|
if (this.checkToolCanOperateSelectedObject(true)) return;
|
||||||
|
|
||||||
this.canvas.isDrawingMode = true;
|
this.canvas.isDrawingMode = true;
|
||||||
this.canvas.selection = false;
|
this.canvas.selection = false;
|
||||||
@@ -506,6 +526,8 @@ export class ToolManager {
|
|||||||
*/
|
*/
|
||||||
setupEraserTool() {
|
setupEraserTool() {
|
||||||
if (!this.canvas) return;
|
if (!this.canvas) return;
|
||||||
|
if (this.checkToolCanOperateSelectedObject(true)) return;
|
||||||
|
|
||||||
this.canvas.isDrawingMode = true;
|
this.canvas.isDrawingMode = true;
|
||||||
this.canvas.selection = false;
|
this.canvas.selection = false;
|
||||||
|
|
||||||
@@ -654,6 +676,7 @@ export class ToolManager {
|
|||||||
*/
|
*/
|
||||||
setupLiquifyTool() {
|
setupLiquifyTool() {
|
||||||
if (!this.canvas || !this.layerManager) return;
|
if (!this.canvas || !this.layerManager) return;
|
||||||
|
if (this.checkToolCanOperateSelectedObject(true)) return;
|
||||||
|
|
||||||
this.canvas.isDrawingMode = false;
|
this.canvas.isDrawingMode = false;
|
||||||
this.canvas.selection = false;
|
this.canvas.selection = false;
|
||||||
|
|||||||
@@ -295,15 +295,15 @@ const otherData = {
|
|||||||
color: {rgba: {r:255,g:0,b:0,a:1}},
|
color: {rgba: {r:255,g:0,b:0,a:1}},
|
||||||
printObject: {
|
printObject: {
|
||||||
prints: [
|
prints: [
|
||||||
{
|
// {
|
||||||
ifSingle: false,
|
// ifSingle: false,
|
||||||
level2Type: "Pattern",
|
// level2Type: "Pattern",
|
||||||
designType: "Library",
|
// designType: "Library",
|
||||||
path: "/src/assets/images/canvas/yinhua1.jpg",
|
// path: "/src/assets/images/canvas/yinhua1.jpg",
|
||||||
location: [250, 780],
|
// location: [250, 780],
|
||||||
scale: [0.3, 0.4],
|
// scale: [0.3, 0.4],
|
||||||
angle: 0,
|
// angle: 0,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
ifSingle: true,
|
ifSingle: true,
|
||||||
level2Type: "Pattern",
|
level2Type: "Pattern",
|
||||||
|
|||||||
Reference in New Issue
Block a user