let source = null window.onmessage = ev => { const { data } = ev source = ev.source console.log(data,"wjx") if (data.rem !== undefined) { document.documentElement.style = `font-size: ${data.rem}` } // document.querySelector(".content").style = `height: ${data.height}` if (data.styleSet === "night") { document.querySelector(".content").classList.add(data.styleSet) } // if (data.btnShow === true) { // document.querySelector(".warningBtn").style.display = "flex" // } // 横全屏 padding-right 84px // 竖全屏 padding-right 42px // 横分屏 padding-right 31px let paddingDirection = data.currentLanguage === "ar" ? "paddingLeft" : "paddingRight" if (data.screenDirection === "HORIZONTAL" && data.screenMode === "FULL") { for (let i of document.querySelectorAll(".content-paragraph")) { i.style[paddingDirection] = "0.44rem" } } // 竖屏 if (data.screenDirection === "VERTICAL" && data.screenMode === "FULL") { for (let i of document.querySelectorAll(".content-paragraph")) { i.style[paddingDirection] = "0.42rem" } } if (data.screenDirection === "HORIZONTAL" && data.screenMode === "SPLIT") { for (let i of document.querySelectorAll(".content-paragraph")) { i.style[paddingDirection] = "0.31rem" } } if (data.screenDirection === "VERTICAL" && data.screenMode === "SPLIT") { for (let i of document.querySelectorAll(".content-paragraph")) { i.style[paddingDirection] = "0.31rem" } } if (data.type === 'getHeight') { postMessage({ type: 'updateHeight', payload: document.documentElement.offsetHeight }) } } const searchParams = new URLSearchParams(location.search) const mode = searchParams.get('mode') if (mode === "night") { document.querySelector(".content").classList.add(mode) } // document.querySelector('.agreeBtn').onclick = () => { // if (source) source.postMessage({ type: 'agree' }, '*') // } // document.querySelector('.exitBtn').onclick = () => { // if (source) source.postMessage({ type: 'disagree' }, '*') // } function postMessage(action) { const { type, payload } = action source !== null && source.postMessage({ type, payload }, '*') }