feat(theme): add sidebarScrollbar options, close #425 (#460)

This commit is contained in:
pengzhanbo 2025-02-09 00:42:36 +08:00 committed by GitHub
parent 861512d402
commit 8631727ec3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 2 deletions

View File

@ -657,6 +657,14 @@ interface SidebarItem {
}
```
### sidebarScrollbar
- 类型: `boolean`
- 默认值: `true`
- 详情: 是否显示侧边栏滚动条
设置为 `false` 时,仅隐藏滚动条,但不改变滚动行为。
### aside
- 类型: `boolean | 'left'`

View File

@ -4,13 +4,14 @@ import VPTransitionFadeSlideY from '@theme/VPTransitionFadeSlideY.vue'
import { useScrollLock } from '@vueuse/core'
import { onMounted, ref, watch } from 'vue'
import { useRoutePath } from 'vuepress/client'
import { useSidebar } from '../composables/index.js'
import { useData, useSidebar } from '../composables/index.js'
import { inBrowser } from '../utils/index.js'
const props = defineProps<{
open: boolean
}>()
const { theme } = useData()
const { sidebarGroups, hasSidebar, sidebarKey } = useSidebar()
const routePath = useRoutePath()
@ -52,7 +53,7 @@ onMounted(() => {
v-if="hasSidebar"
ref="navEl"
class="vp-sidebar"
:class="{ open }"
:class="{ open, 'hide-scrollbar': !(theme.sidebarScrollbar ?? true) }"
vp-sidebar
@click.stop
>
@ -114,6 +115,15 @@ onMounted(() => {
transform: translateX(0);
}
.vp-sidebar.hide-scrollbar {
scrollbar-width: none;
}
.vp-sidebar.hide-scrollbar::-webkit-scrollbar {
width: 0;
height: 0;
}
[data-theme="dark"] .vp-sidebar {
box-shadow: var(--vp-shadow-1);
}

View File

@ -77,6 +77,12 @@ export interface PlumeThemeLocaleData extends LocaleData {
*/
sidebar?: SidebarMulti
/**
*
* @default true
*/
sidebarScrollbar?: boolean
/**
*
*