未验证 提交 3b0077dc 编写于 作者: 予ヾ 提交者: GitHub

fix: 修复水印重复叠加问题 (#2622)

Co-authored-by: Nwhong <whif@foxmail.com>
上级 3de5b53b
......@@ -4,10 +4,15 @@ import { addResizeListener, removeResizeListener } from '/@/utils/event';
import { isDef } from '/@/utils/is';
const domSymbol = Symbol('watermark-dom');
const sourceMap = new WeakMap<HTMLElement, {}>();
export function useWatermark(
appendEl: Ref<HTMLElement | null> = ref(document.body) as Ref<HTMLElement>,
) {
const appendElRaw = unref(appendEl);
if (appendElRaw && sourceMap.has(appendElRaw)) {
return sourceMap.get(appendElRaw);
}
const func = useRafThrottle(function () {
const el = unref(appendEl);
if (!el) return;
......@@ -82,6 +87,7 @@ export function useWatermark(
const { clientHeight: height, clientWidth: width } = el;
updateWatermark({ str, width, height });
el.appendChild(div);
sourceMap.set(el, { setWatermark, clear });
return id;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册