Skip to content

Commit

Permalink
fix: 修复导入水印json无法清除问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu-Jun committed May 23, 2024
1 parent efb89c6 commit 197e1b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/core/ServersPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: 秦少卫
* @Date: 2023-06-20 12:52:09
* @LastEditors: 秦少卫
* @LastEditTime: 2024-05-11 14:19:33
* @LastEditors: June [email protected]
* @LastEditTime: 2024-05-23 17:56:15
* @Description: 内部插件
*/
import { v4 as uuid } from 'uuid';
Expand Down Expand Up @@ -108,6 +108,8 @@ class ServersPlugin {
this.canvas.renderAll();
// 加载后钩子
this.editor.hooksEntity.hookImportAfter.callAsync(jsonFile, () => {
// 修复导入带水印的json无法清除问题 #359
this.editor?.updateDrawStatus(!!temp['overlayImage']);
this.canvas.renderAll();
callback && callback();
this.editor.emit('loadJson');
Expand Down
11 changes: 8 additions & 3 deletions packages/core/plugin/WaterMarkPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @Author: June
* @Description: 水印插件
* @Date: 2024-04-21 08:30:48
* @LastEditors: June
* @LastEditTime: 2024-04-21 11:07:07
* @LastEditors: June [email protected]
* @LastEditTime: 2024-05-23 17:56:45
*/
import { cloneDeep } from 'lodash-es';
import { fabric } from 'fabric';
Expand Down Expand Up @@ -41,7 +41,7 @@ class WaterMarkPlugin {
public canvas: fabric.Canvas;
public editor: IEditor;
static pluginName = 'WaterMarkPlugin';
static apis = ['drawWaterMark', 'clearWaterMMatk'];
static apis = ['drawWaterMark', 'clearWaterMMatk', 'updateDrawStatus'];
private hadDraw = false;
private drawOps: IDrawOps = defaultOptions;
constructor(canvas: fabric.Canvas, editor: IEditor) {
Expand Down Expand Up @@ -171,6 +171,11 @@ class WaterMarkPlugin {
});
}

// 更新handDrow 导入json时无法知道是否绘制
updateDrawStatus(status: boolean) {
this.hadDraw = status;
}

clearWaterMMatk() {
if (!this.hadDraw) return;
this.canvas.overlayImage = undefined;
Expand Down

0 comments on commit 197e1b0

Please sign in to comment.