Discuz! X3.5手机自适应网页代码

在后台统计放入如下代码:


<script>
const mobileWidth = 768
document.head.appendChild(Object.assign(document.createElement('meta'),
{ name: 'viewport', content: 'width=device-width, initial-scale=1, user-scalable=0, viewport-fit=cover' }))
const styleMobile = Object.assign(document.createElement('style'), { id:'mobile-style', innerText: `
.m_c .tedt, #subjecthide, .m_c .quote, .rfm {width:100%!important}
#frt, .fl_i, .fl_by, .num, #boardlogo, .category_l3, .pls, .pi strong, tr td:nth-last-child(3).by {display: none !important}
#scbar_txt, .ct2_a .mn {width: auto !important}
#wp, #ft, .hdc.cl {padding: 0 10px !important; box-sizing: border-box;}
` })
document.head.appendChild(Object.assign(document.createElement('style'), {innerText: `
body, #toptb {min-width: 0 !important}
.wp {width: 1200px !important; max-width: 100% !important}
img.zoom, #e_image_menu {max-width: 100% !important}
.btn_s_open, .btn_s_close {display: none !important}
`}))
let isMobile = false
if (window.innerWidth<mobileWidth) {
isMobile = true
if (!document.cookie.includes('close_leftinfo=1')) {
setcookie('close_leftinfo', 1)
location.reload()
}
document.head.appendChild(styleMobile)
} else {
if (document.cookie.includes('close_leftinfo=1')) {
setcookie('close_leftinfo', 2)
location.reload()
}
}
window.addEventListener('resize', ()=>{
if (window.innerWidth<mobileWidth) {
if (isMobile) return
isMobile = true
if(!document.querySelector('#mobile-style')) document.head.appendChild(styleMobile)
} else {
if (!isMobile) return
isMobile = false
document.head.removeChild(styleMobile)
}
})
</script>

站点宽窄风格改成窄屏(固定宽度),允许用户自由切换改成否
3. 作者用户名显示位置改成显示在帖子内部
4. 快速发帖右侧显示推荐表情改成否
5. 仅适用于Discuz! X3.5默认主题,不适用3.4
6. 左侧信息栏允许用户控制 改为 是

滚动至顶部