修复次导航的显隐逻辑

This commit is contained in:
Hooray Hu 2023-11-29 14:07:10 +08:00
parent 9e3797c05c
commit 73bd98e0f4
3 changed files with 2 additions and 39 deletions

View File

@ -5,10 +5,8 @@ import hotkeys from 'hotkeys-js'
import elementPlusLocaleZhCN from 'element-plus/es/locale/lang/zh-cn.mjs'
import eventBus from './utils/eventBus'
import useSettingsStore from '@/store/modules/settings'
import useMenuStore from '@/store/modules/menu'
const settingsStore = useSettingsStore()
const menuStore = useMenuStore()
const { auth } = useAuth()
//
@ -26,15 +24,6 @@ const subSidebarActualWidth = computed(() => {
if (settingsStore.settings.menu.subMenuCollapse && settingsStore.mode !== 'mobile') {
actualWidth = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--g-sub-sidebar-collapse-width'))
}
if (
menuStore.sidebarMenus.length === 1
&& (
!menuStore.sidebarMenus[0].children
|| menuStore.sidebarMenus[0]?.children.every(item => item.meta?.sidebar === false)
)
) {
actualWidth = 0
}
return `${actualWidth}px`
})

View File

@ -18,25 +18,11 @@ const sidebarScrollTop = ref(0)
function onSidebarScroll(e: Event) {
sidebarScrollTop.value = (e.target as HTMLElement).scrollTop
}
const enableSidebar = computed(() => {
return settingsStore.mode === 'mobile' || (
['side', 'head', 'single'].includes(settingsStore.settings.menu.menuMode)
&& menuStore.sidebarMenus.length !== 0
&& !(
menuStore.sidebarMenus.length === 1
&& (
!menuStore.sidebarMenus[0].children
|| menuStore.sidebarMenus[0]?.children.every(item => item.meta?.sidebar === false)
)
)
)
})
</script>
<template>
<div
v-if="enableSidebar" class="sub-sidebar-container" :class="{
class="sub-sidebar-container" :class="{
'is-collapse': settingsStore.mode === 'pc' && settingsStore.settings.menu.subMenuCollapse,
}"
>

View File

@ -4,7 +4,6 @@ import Breadcrumb from '../../Breadcrumb/index.vue'
import BreadcrumbItem from '../../Breadcrumb/item.vue'
import Tools from '../../Tools/index.vue'
import useSettingsStore from '@/store/modules/settings'
import useMenuStore from '@/store/modules/menu'
defineOptions({
name: 'Toolbar',
@ -13,20 +12,9 @@ defineOptions({
const route = useRoute()
const settingsStore = useSettingsStore()
const menuStore = useMenuStore()
const enableSubMenuCollapseButton = computed(() => {
return settingsStore.mode === 'mobile' || (
['side', 'head', 'single'].includes(settingsStore.settings.menu.menuMode)
&& settingsStore.settings.menu.enableSubMenuCollapseButton
&& !(
menuStore.sidebarMenus.length === 1
&& (
!menuStore.sidebarMenus[0].children
|| menuStore.sidebarMenus[0]?.children.every(item => item.meta?.sidebar === false)
)
)
)
return settingsStore.mode === 'mobile' || settingsStore.settings.menu.enableSubMenuCollapseButton
})
const breadcrumbList = computed(() => {