优化移动端侧边栏
自动部署 / deploy (push) Successful in 3m45s

This commit is contained in:
2026-04-25 13:46:21 +08:00
Unverified
parent fb14ba2be4
commit b7458f490c
6 changed files with 118 additions and 20 deletions
+29
View File
@@ -38,6 +38,26 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
const syncAsideToSidebar = () => {
const asideContent = document.getElementById('aside-content')
const desktopAsideContainer = document.getElementById('content-inner')
const mobileAsideContainer = document.getElementById('sidebar-aside-wrapper')
if (!(asideContent && desktopAsideContainer && mobileAsideContainer)) {
document.documentElement.classList.remove('mobile-aside-in-sidebar')
return
}
const shouldMoveAside = window.innerWidth <= 900
const targetContainer = shouldMoveAside ? mobileAsideContainer : desktopAsideContainer
if (asideContent.parentNode !== targetContainer) {
targetContainer.appendChild(asideContent)
}
document.documentElement.classList.toggle('mobile-aside-in-sidebar', shouldMoveAside)
}
/**
* 首頁top_img底下的箭頭
*/
@@ -921,12 +941,20 @@ document.addEventListener('DOMContentLoaded', () => {
const unRefreshFn = () => {
window.addEventListener('resize', () => {
adjustMenu(false)
syncAsideToSidebar()
mobileSidebarOpen && btf.isHidden(document.getElementById('toggle-menu')) && sidebarFn.close()
})
const menuMask = document.getElementById('menu-mask')
menuMask && menuMask.addEventListener('click', () => { sidebarFn.close() })
const sidebarMenus = document.getElementById('sidebar-menus')
sidebarMenus && sidebarMenus.addEventListener('click', e => {
const clickedLink = e.target.closest('a')
if (!clickedLink) return
sidebarFn.close()
})
clickFnOfSubMenu()
GLOBAL_CONFIG.islazyloadPlugin && lazyloadImg()
GLOBAL_CONFIG.copyright !== undefined && addCopyright()
@@ -952,6 +980,7 @@ document.addEventListener('DOMContentLoaded', () => {
const refreshFn = () => {
initAdjust()
syncAsideToSidebar()
justifiedIndexPostUI()
if (GLOBAL_CONFIG_SITE.pageType === 'post') {