Skip to content

Commit

Permalink
fix(component): 修复蒙版组建和插件状态不同步问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu-Jun committed Jul 13, 2024
2 parents 29365c5 + 4806fd7 commit bde526f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,22 @@ pnpm dev
<sub><b>makeng</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/momo2019">
<img src="https://avatars.githubusercontent.com/u/26078793?v=4" width="80;" alt="momo2019"/>
<br />
<sub><b>momo2019</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/z09176141">
<img src="https://avatars.githubusercontent.com/u/49260613?v=4" width="80;" alt="z09176141"/>
<br />
<sub><b>z09176141</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/a847244052">
<img src="https://avatars.githubusercontent.com/u/28621500?v=4" width="80;" alt="a847244052"/>
Expand Down Expand Up @@ -312,21 +319,14 @@ pnpm dev
<sub><b>pengzhijian</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/JiangShuQ">
<img src="https://avatars.githubusercontent.com/u/95730895?v=4" width="80;" alt="JiangShuQ"/>
<br />
<sub><b>JiangShuQ</b></sub>
</a>
</td>
</tr>
<tr>
<td align="center">
<a href="https://github.com/momo2019">
<img src="https://avatars.githubusercontent.com/u/26078793?v=4" width="80;" alt="momo2019"/>
<br />
<sub><b>momo2019</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/hudenghui">
Expand Down
9 changes: 8 additions & 1 deletion packages/core/plugin/MaskPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type IEditor = Editor;

class MaskPlugin implements IPluginTempl {
static pluginName = 'MaskPlugin';
static apis = ['setCoverMask', 'workspaceMaskToggle'];
static apis = ['setCoverMask', 'workspaceMaskToggle', 'getworkspaceMaskStatus'];
coverMask: null | fabric.Rect = null;
workspace: null | fabric.Rect = null;
workspaceEl!: HTMLElement;
Expand Down Expand Up @@ -42,11 +42,18 @@ class MaskPlugin implements IPluginTempl {
workspaceMask && this.canvas.remove(workspaceMask);
this.workspace?.clone((cloned: fabric.Rect) => {
this.canvas.clipPath = cloned;
this.coverMask = null;
this.canvas.requestRenderAll();
});
this.editor.off('loadJson', this.initMask);
}
}
/**
* @desc 获取蒙版开关
*/
getworkspaceMaskStatus() {
return this.coverMask !== null;
}

/**
* @desc 获取蒙版
Expand Down
4 changes: 4 additions & 0 deletions src/components/workspaceMask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const openMask = ref(false);
const onMaskChange = () => {
canvasEditor?.workspaceMaskToggle();
};
onMounted(() => {
openMask.value = canvasEditor?.getworkspaceMaskStatus();
});
</script>

<style lang="less" scoped>
Expand Down

0 comments on commit bde526f

Please sign in to comment.