修复特定动作下有概率导致缩放元素遮挡的问题 #59

Merged
hnu202326010204 merged 2 commits from yangyixuan_branch into develop 2 days ago

@ -14,7 +14,7 @@ const emit = defineEmits(['navigate', 'logout', 'toggle'])
const isDarkMode = ref(true)
const savedState = localStorage.getItem('kt_nav_expanded')
const isExpanded = ref(savedState === 'true' && savedState !== null ? true : false)
const isExpanded = ref(savedState === 'true' && typeof window !== 'undefined' && window.innerWidth > 900)
// DOM Refs
const navButtonRefs = ref([]) // DOM
@ -83,6 +83,19 @@ watch(() => props.currentSection, () => {
// ResizeObserver: window.resize
let resizeObserver = null
// === ===
const handleWindowResize = () => {
// 1. ()
updateHighlightPosition()
// 2. (<=900px)
if (window.innerWidth <= 900 && isExpanded.value) {
isExpanded.value = false
}
}
onMounted(() => {
const savedTheme = localStorage.getItem('theme')
if (savedTheme === 'light') {
@ -105,13 +118,13 @@ onMounted(() => {
resizeObserver.observe(navContainerRef.value)
}
// window resize
window.addEventListener('resize', updateHighlightPosition)
window.addEventListener('resize', handleWindowResize)
})
})
onUnmounted(() => {
if (resizeObserver) resizeObserver.disconnect()
window.removeEventListener('resize', updateHighlightPosition)
window.removeEventListener('resize', handleWindowResize)
})
const handleNavClick = (id) => { emit('navigate', id) }

@ -309,8 +309,9 @@ onMounted(() => {
//
document.addEventListener('visibilitychange', handleVisibilityChange)
const savedNavState = localStorage.getItem('kt_nav_expanded')
if (savedNavState === 'true') {
if (savedNavState === 'true' && window.innerWidth > 900) {
setTimeout(() => {
handleNavToggle(true)
}, 200)

@ -135,7 +135,7 @@
</button>
<button
v-if="['pending','waiting','processing','running'].includes(task.status)"
v-if="['pending','waiting'].includes(task.status)"
class="kt-action-btn kt-action-btn--danger"
title="取消任务"
@click="handleCancel(task)"

Loading…
Cancel
Save