diff --git a/src/layouts/components/SubSidebar/index.vue b/src/layouts/components/SubSidebar/index.vue index a6c70997..db84f88b 100755 --- a/src/layouts/components/SubSidebar/index.vue +++ b/src/layouts/components/SubSidebar/index.vue @@ -13,11 +13,20 @@ const route = useRoute() const settingsStore = useSettingsStore() const menuStore = useMenuStore() -const sidebarScrollTop = ref(0) - -function onSidebarScroll(e: Event) { - sidebarScrollTop.value = (e.target as HTMLElement).scrollTop +const subSidebarRef = ref() +const showShadowTop = ref(false) +const showShadowBottom = ref(false) +function onSidebarScroll() { + const scrollTop = subSidebarRef.value.scrollTop + showShadowTop.value = scrollTop > 0 + const clientHeight = subSidebarRef.value.clientHeight + const scrollHeight = subSidebarRef.value.scrollHeight + showShadowBottom.value = Math.ceil(scrollTop + clientHeight) < scrollHeight } + +onMounted(() => { + onSidebarScroll() +}) @@ -32,8 +41,9 @@ function onSidebarScroll(e: Event) { }" /> @@ -44,6 +54,11 @@ function onSidebarScroll(e: Event) { + + + + + @@ -98,8 +113,16 @@ function onSidebarScroll(e: Event) { display: none; } - &.shadow { - box-shadow: inset 0 10px 10px -10px var(--g-box-shadow-color); + &.shadow-top { + box-shadow: inset 0 10px 10px -10px var(--g-box-shadow-color), inset 0 0 0 transparent; + } + + &.shadow-bottom { + box-shadow: inset 0 0 0 transparent, inset 0 -10px 10px -10px var(--g-box-shadow-color); + } + + &.shadow-top.shadow-bottom { + box-shadow: inset 0 10px 10px -10px var(--g-box-shadow-color), inset 0 -10px 10px -10px var(--g-box-shadow-color); } } diff --git a/src/layouts/components/Topbar/Toolbar/leftSide.vue b/src/layouts/components/Topbar/Toolbar/leftSide.vue index 2a3b6348..3659255f 100644 --- a/src/layouts/components/Topbar/Toolbar/leftSide.vue +++ b/src/layouts/components/Topbar/Toolbar/leftSide.vue @@ -7,15 +7,11 @@ defineOptions({ }) const settingsStore = useSettingsStore() - -const enableSubMenuCollapseButton = computed(() => { - return settingsStore.mode === 'mobile' || settingsStore.settings.menu.enableSubMenuCollapseButton -}) - + diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts index 0f3cc0b8..2adfb759 100755 --- a/src/store/modules/settings.ts +++ b/src/store/modules/settings.ts @@ -70,16 +70,17 @@ const useSettingsStore = defineStore( } } - // 次导航是否收起(用于记录 pc 模式下最后的状态) - const subMenuCollapseLastStatus = ref(settingsDefault.menu.subMenuCollapse) // 切换侧边栏导航展开/收起 function toggleSidebarCollapse() { settings.value.menu.subMenuCollapse = !settings.value.menu.subMenuCollapse - if (mode.value === 'pc') { - subMenuCollapseLastStatus.value = !subMenuCollapseLastStatus.value - } } - + // 次导航是否收起(用于记录 pc 模式下最后的状态) + const subMenuCollapseLastStatus = ref(settingsDefault.menu.subMenuCollapse) + watch(() => settings.value.menu.subMenuCollapse, (val) => { + if (mode.value === 'pc') { + subMenuCollapseLastStatus.value = val + } + }) watch(mode, (val) => { switch (val) { case 'pc':