Skip to content

Commit 4806fd7

Browse files
committed
fix(component): 修复蒙版组件切换时状态初始化为false的问题
1 parent 6141c23 commit 4806fd7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/core/plugin/MaskPlugin.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type IEditor = Editor;
1212

1313
class MaskPlugin implements IPluginTempl {
1414
static pluginName = 'MaskPlugin';
15-
static apis = ['setCoverMask', 'workspaceMaskToggle'];
15+
static apis = ['setCoverMask', 'workspaceMaskToggle', 'getworkspaceMaskStatus'];
1616
coverMask: null | fabric.Rect = null;
1717
workspace: null | fabric.Rect = null;
1818
workspaceEl!: HTMLElement;
@@ -42,11 +42,18 @@ class MaskPlugin implements IPluginTempl {
4242
workspaceMask && this.canvas.remove(workspaceMask);
4343
this.workspace?.clone((cloned: fabric.Rect) => {
4444
this.canvas.clipPath = cloned;
45+
this.coverMask = null;
4546
this.canvas.requestRenderAll();
4647
});
4748
this.editor.off('loadJson', this.initMask);
4849
}
4950
}
51+
/**
52+
* @desc 获取蒙版开关
53+
*/
54+
getworkspaceMaskStatus() {
55+
return this.coverMask !== null;
56+
}
5057

5158
/**
5259
* @desc 获取蒙版

src/components/workspaceMask.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const openMask = ref(false);
2222
const onMaskChange = () => {
2323
canvasEditor?.workspaceMaskToggle();
2424
};
25+
26+
onMounted(() => {
27+
openMask.value = canvasEditor?.getworkspaceMaskStatus();
28+
});
2529
</script>
2630

2731
<style lang="less" scoped>

0 commit comments

Comments
 (0)