Commit f340b6279b
f340b6279b874b1867b183ea60dea9e4ae70fdd2
parent: fc0ad44f7a
Unsigned
Duck <57977673+woducku@users.noreply.github.com> · 2026-06-30 16:26 UTC
update
Layout: unified · split
docs/.vitepress/theme/components/HomeFeatures.vue
+11 −1
| @@ -1,5 +1,5 @@ |
| 1 | 1 | <script setup lang="ts"> |
| 2 | | import { computed, nextTick, onMounted, ref, watch } from 'vue' |
| 2 | import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue' |
| 3 | 3 | import type { HomeCard } from '../../configs/constants' |
| 4 | 4 | |
| 5 | 5 | const props = defineProps<{ cards: HomeCard[] }>() |
| @@ -123,6 +123,16 @@ watch(panelOpen, (open) => { |
| 123 | 123 | document.body.style.overflow = open ? 'hidden' : '' |
| 124 | 124 | }) |
| 125 | 125 | |
| 126 | function onKeydown(e: KeyboardEvent) { |
| 127 | if (e.key === 'Escape') { |
| 128 | panelOpen.value = false |
| 129 | cardTooltip.value = null |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | onMounted(() => document.addEventListener('keydown', onKeydown)) |
| 134 | onUnmounted(() => document.removeEventListener('keydown', onKeydown)) |
| 135 | |
| 126 | 136 | function loadPrefs() { |
| 127 | 137 | if (typeof window === 'undefined') return { columnMode: 'default' as const, viewMode: 'default' as const } |
| 128 | 138 | try { |
docs/.vitepress/theme/components/settings/Menu.vue
+4 −6
| @@ -2,7 +2,7 @@ |
| 2 | 2 | import { useMounted } from '@vueuse/core' |
| 3 | 3 | import { inject } from 'vue' |
| 4 | 4 | |
| 5 | | import { InjectionKey, VPFlyout } from '../../constants' |
| 5 | import { InjectionKey } from '../../constants' |
| 6 | 6 | import AccentColor from './AccentColor.vue' |
| 7 | 7 | import BlurEffects from './BlurEffects.vue' |
| 8 | 8 | import LayoutSwitch from './LayoutSwitch.vue' |
| @@ -10,6 +10,7 @@ import LayoutSwitchContentLayoutWidthInput from './LayoutSwitchContentLayoutMaxW |
| 10 | 10 | import LayoutSwitchPageLayoutWidthInput from './LayoutSwitchPageLayoutMaxWidthSlider.vue' |
| 11 | 11 | import Spotlight from './Spotlight.vue' |
| 12 | 12 | import SpotlightStyles from './SpotlightStyles.vue' |
| 13 | import SettingsFlyout from './SettingsFlyout.vue' |
| 13 | 14 | import Takodachi from './Takodachi.vue' |
| 14 | 15 | |
| 15 | 16 | const options = inject(InjectionKey, {}) |
| @@ -17,11 +18,8 @@ const mounted = useMounted() |
| 17 | 18 | </script> |
| 18 | 19 | |
| 19 | 20 | <template> |
| 20 | | <VPFlyout |
| 21 | | icon="i-lucide:settings" |
| 21 | <SettingsFlyout |
| 22 | 22 | class="VPNolebaseEnhancedReadabilitiesMenu VPNolebaseEnhancedReadabilitiesMenuFlyout" |
| 23 | | aria-label="Enhanced Readability" |
| 24 | | role="menuitem" |
| 25 | 23 | > |
| 26 | 24 | <div |
| 27 | 25 | v-if="mounted" |
| @@ -37,7 +35,7 @@ const mounted = useMounted() |
| 37 | 35 | <Takodachi /> |
| 38 | 36 | <AccentColor /> |
| 39 | 37 | </div> |
| 40 | | </VPFlyout> |
| 38 | </SettingsFlyout> |
| 41 | 39 | </template> |
| 42 | 40 | |
| 43 | 41 | <style> |
docs/.vitepress/theme/components/settings/SettingsFlyout.vue
added
+86
| @@ -0,0 +1,86 @@ |
| 1 | <script setup lang="ts"> |
| 2 | import { onMounted, onUnmounted, ref } from 'vue' |
| 3 | |
| 4 | const open = ref(false) |
| 5 | const el = ref<HTMLElement>() |
| 6 | |
| 7 | function toggle() { |
| 8 | open.value = !open.value |
| 9 | } |
| 10 | |
| 11 | function onDocClick(e: MouseEvent) { |
| 12 | if (el.value && !el.value.contains(e.target as Node)) { |
| 13 | open.value = false |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | onMounted(() => document.addEventListener('click', onDocClick, true)) |
| 18 | onUnmounted(() => document.removeEventListener('click', onDocClick, true)) |
| 19 | </script> |
| 20 | |
| 21 | <template> |
| 22 | <div ref="el" class="VPFlyout"> |
| 23 | <button |
| 24 | type="button" |
| 25 | class="button" |
| 26 | aria-haspopup="true" |
| 27 | :aria-expanded="open" |
| 28 | aria-label="Enhanced Readability" |
| 29 | @click="toggle" |
| 30 | > |
| 31 | <span class="text"> |
| 32 | <span class="i-lucide:settings option-icon" /> |
| 33 | </span> |
| 34 | </button> |
| 35 | |
| 36 | <div v-show="open" class="menu"> |
| 37 | <div class="VPMenu"> |
| 38 | <slot /> |
| 39 | </div> |
| 40 | </div> |
| 41 | </div> |
| 42 | </template> |
| 43 | |
| 44 | <style scoped> |
| 45 | .VPFlyout { |
| 46 | position: relative; |
| 47 | } |
| 48 | |
| 49 | .button { |
| 50 | display: flex; |
| 51 | align-items: center; |
| 52 | padding: 0 12px; |
| 53 | height: var(--vp-nav-height); |
| 54 | color: var(--vp-c-text-1); |
| 55 | transition: color 0.5s; |
| 56 | } |
| 57 | |
| 58 | .text { |
| 59 | display: flex; |
| 60 | align-items: center; |
| 61 | line-height: var(--vp-nav-height); |
| 62 | } |
| 63 | |
| 64 | .option-icon { |
| 65 | font-size: 16px; |
| 66 | } |
| 67 | |
| 68 | .menu { |
| 69 | position: absolute; |
| 70 | top: calc(var(--vp-nav-height) / 2 + 20px); |
| 71 | right: 0; |
| 72 | z-index: 100; |
| 73 | } |
| 74 | |
| 75 | .VPMenu { |
| 76 | border-radius: 12px; |
| 77 | padding: 12px; |
| 78 | min-width: 128px; |
| 79 | border: 1px solid var(--vp-c-divider); |
| 80 | background-color: var(--vp-c-bg-elv); |
| 81 | box-shadow: var(--vp-shadow-3); |
| 82 | transition: background-color 0.5s; |
| 83 | max-height: calc(100vh - var(--vp-nav-height)); |
| 84 | overflow-y: auto; |
| 85 | } |
| 86 | </style> |