mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-10-15 03:32:11 +08:00
refactor(plugin-watermark): 优化实现
This commit is contained in:
parent
23e0e104f2
commit
74d94fb001
@ -38,7 +38,7 @@ export function createWatermark({
|
|||||||
textAlign = 'center',
|
textAlign = 'center',
|
||||||
textBaseline = 'middle',
|
textBaseline = 'middle',
|
||||||
font = '16px Microsoft Yahei',
|
font = '16px Microsoft Yahei',
|
||||||
fillStyle = 'rgba(184, 184, 184, 0.15)',
|
fillStyle = 'rgba(184, 184, 184, 0.2)',
|
||||||
content = '请勿外传',
|
content = '请勿外传',
|
||||||
rotate = '45',
|
rotate = '45',
|
||||||
zIndex = 99999,
|
zIndex = 99999,
|
||||||
@ -77,12 +77,12 @@ export function createWatermark({
|
|||||||
let __wm = document.querySelector('.__wm');
|
let __wm = document.querySelector('.__wm');
|
||||||
const watermarkDiv = __wm || document.createElement('div');
|
const watermarkDiv = __wm || document.createElement('div');
|
||||||
const styleStr = `
|
const styleStr = `
|
||||||
position: absolute;
|
position: fixed;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100vw;
|
||||||
height: 100%;
|
height: 100vh;
|
||||||
z-index: ${zIndex};
|
z-index: ${zIndex};
|
||||||
pointer-events: none !important;
|
pointer-events: none !important;
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
@ -92,7 +92,6 @@ export function createWatermark({
|
|||||||
watermarkDiv.classList.add('__wm');
|
watermarkDiv.classList.add('__wm');
|
||||||
|
|
||||||
if (!__wm) {
|
if (!__wm) {
|
||||||
container.style.position = 'relative';
|
|
||||||
container.insertBefore(watermarkDiv, container.firstChild);
|
container.insertBefore(watermarkDiv, container.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,15 +116,14 @@ export function createWatermark({
|
|||||||
|
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
let timeout = 1000 * 60 * 60 * 24;
|
let timeout = 1000 * 60 * 60 * 24;
|
||||||
if (timestamp.includes('h') || timestamp.includes('H')) {
|
|
||||||
timeout = 1000 * 60 * 60;
|
|
||||||
}
|
|
||||||
if (timestamp.includes('m')) {
|
|
||||||
timeout = 1000 * 60;
|
|
||||||
}
|
|
||||||
if (timestamp.includes('s')) {
|
if (timestamp.includes('s')) {
|
||||||
timeout = 1000;
|
timeout = 1000;
|
||||||
|
} else if (timestamp.includes('m')) {
|
||||||
|
timeout = 1000 * 60;
|
||||||
|
} else if (timestamp.includes('h') || timestamp.includes('H')) {
|
||||||
|
timeout = 1000 * 60 * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 触发MutationObserver
|
// 触发MutationObserver
|
||||||
watermarkDiv.style.bottom = '0';
|
watermarkDiv.style.bottom = '0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user