window.addEventListener('load', function () {
console.log('屏幕方向:', window.orientation);
showOrHide()
});
let dom = document.createElement('div');
window.addEventListener("orientationchange", function () {
showOrHide()
}, false);
function showOrHide() {
if (Math.abs(window.orientation) != 90) {
dom.style.width = '100%'
dom.style.height = '100%'
dom.style.background = '#fff'
dom.style.position = 'fixed'
dom.style.zIndex = 10000000000
dom.innerText = '请使用横屏进行游戏'
dom.style.textAlign = 'center'
dom.style.paddingTop = '45vh'
dom.style.color = '#000'
document.body.appendChild(dom);
setTimeout(() => {
document.body.style.visibility = 'visible'
}, 500)
} else {
console.log('横屏')
if (document.body.contains(dom)) {
document.body.removeChild(dom);
}
document.body.style.visibility = 'visible'
}
}