修复页面布局导致的首页有时无法路由的bug

This commit is contained in:
2025-07-25 23:32:06 +08:00
parent 37113799a2
commit c84992cf87

View File

@@ -48,9 +48,15 @@ const toggleSidebar = () => {
}
// 监听路由变化,在移动端自动关闭侧边栏
watch(() => useRoute().path, () => {
const route = useRoute()
const stopWatch = watch(() => route.path, () => {
if (isSidebarOpen.value) {
isSidebarOpen.value = false
}
})
// 组件卸载时清理监听器
onUnmounted(() => {
stopWatch()
})
</script>