diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 4743183..e575dfc 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -4,7 +4,7 @@ import MainContent from '@/layout/MainContent.vue' import GlobalSettings from '@/views/components/global/GlobalSettings.vue' import { useGlobalConfigStore } from '@/stores/GlobalConfigStore' import { GlobalLayoutMode } from '@/consts/GlobalConstants' -import { computed, ref } from 'vue' +import { computed, ref, watch, onUnmounted } from 'vue' import { useMenuConfigStore } from '@/stores/MenuConfigStore' import { useTabModeScrollSaver } from '@/route/RouteUtils' @@ -14,6 +14,31 @@ const showLeftMenu = computed(() => { }) const leftMenuAsideRef = ref(null) +// 控制 split 是否启用:收起时立即禁用 split;展开时先执行 CSS 展开动画,300ms 动画完成后再启用 split +const isSplitDisabled = ref(globalConfigStore.isCollapseLeft) +let expandTimer = null + +watch(() => globalConfigStore.isCollapseLeft, (collapsed) => { + if (expandTimer) { + clearTimeout(expandTimer) + expandTimer = null + } + if (collapsed) { + isSplitDisabled.value = true + } else { + isSplitDisabled.value = true + expandTimer = setTimeout(() => { + isSplitDisabled.value = false + }, 300) + } +}, { immediate: true }) + +onUnmounted(() => { + if (expandTimer) { + clearTimeout(expandTimer) + } +}) + const handleDragEnd = () => { if (leftMenuAsideRef.value) { const width = leftMenuAsideRef.value.$el.offsetWidth @@ -31,7 +56,7 @@ useMenuConfigStore().loadBusinessMenus()