diff --git a/src/App.vue b/src/App.vue index aad89d0b..8a4d32d9 100755 --- a/src/App.vue +++ b/src/App.vue @@ -6,10 +6,12 @@ import hotkeys from 'hotkeys-js' import eventBus from './utils/eventBus' import Provider from './ui-provider/index.vue' import useSettingsStore from '@/store/modules/settings' +import useMenuStore from '@/store/modules/menu' const route = useRoute() const settingsStore = useSettingsStore() +const menuStore = useMenuStore() const { auth } = useAuth() const isAuth = computed(() => { @@ -33,6 +35,9 @@ 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.every(item => item.meta?.menu === false)) { + actualWidth = 0 + } return `${actualWidth}px` }) diff --git a/src/layouts/components/SubSidebar/index.vue b/src/layouts/components/SubSidebar/index.vue index 09657a91..281ba1d2 100755 --- a/src/layouts/components/SubSidebar/index.vue +++ b/src/layouts/components/SubSidebar/index.vue @@ -25,24 +25,42 @@ function onSidebarScroll() { showShadowBottom.value = Math.ceil(scrollTop + clientHeight) < scrollHeight } +const enableSidebar = computed(() => { + return settingsStore.mode === 'mobile' || ( + menuStore.sidebarMenus.length !== 0 + && !menuStore.sidebarMenus.every(item => item.meta?.menu === false) + ) +}) + +watch(enableSidebar, (val) => { + if (val) { + nextTick(() => { + onSidebarScroll() + }) + } +}, { + immediate: true, +}) + const menuRef = ref() onMounted(() => { - onSidebarScroll() - const { height } = useElementSize(menuRef) - watch(() => height.value, () => { - if (height.value > 0) { - onSidebarScroll() - } - }, { - immediate: true, - }) + if (enableSidebar.value) { + const { height } = useElementSize(menuRef) + watch(() => height.value, () => { + if (height.value > 0) { + onSidebarScroll() + } + }, { + immediate: true, + }) + } })