From f7f040f6117dd4536e6d18005721d04b9ef6b9d9 Mon Sep 17 00:00:00 2001 From: ocean-gao Date: Tue, 10 May 2022 15:03:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20watermark=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-watermark/src/runtime/core.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/fes-plugin-watermark/src/runtime/core.js b/packages/fes-plugin-watermark/src/runtime/core.js index 10797509..f76c51e9 100644 --- a/packages/fes-plugin-watermark/src/runtime/core.js +++ b/packages/fes-plugin-watermark/src/runtime/core.js @@ -41,7 +41,7 @@ function _close(param) { // 监听器关闭 _wmMo && _wmMo.disconnect(); _wmMo = null; - _wmTimer && clearTimeout(_wmTimer); + _wmTimer && window.clearTimeout(_wmTimer); _wmTimer = null; // 删除水印元素 @@ -79,6 +79,9 @@ export function createWatermark({ if (WATERMARK_DISABLED) { return; } + if (!_wmEnable) { + return; + } const param = { container, width, @@ -93,9 +96,6 @@ export function createWatermark({ zIndex, timestamp }; - if (!_wmEnable) { - return; - } const canvas = document.createElement('canvas'); canvas.setAttribute('width', `${width}px`); canvas.setAttribute('height', `${height}px`); @@ -168,7 +168,7 @@ export function createWatermark({ timeout = 1000 * 60 * 60; } - _wmTimer = setTimeout(() => { + _wmTimer = window.setTimeout(() => { // 触发MutationObserver watermarkDiv.style.bottom = '0'; }, timeout);