Commit f502b97e61
Unsigned
Layout: unified · split
docs/.vitepress/configs/constants.ts +5
| @@ -579,6 +579,11 @@ export const siteConfig = { | |||
| 579 | {}, | 579 | {}, |
| 580 | `(function(){try{if(localStorage.getItem('preference-effects')!=='on')document.documentElement.classList.add('effects-disabled')}catch(e){document.documentElement.classList.add('effects-disabled')}})()` | 580 | `(function(){try{if(localStorage.getItem('preference-effects')!=='on')document.documentElement.classList.add('effects-disabled')}catch(e){document.documentElement.classList.add('effects-disabled')}})()` |
| 581 | ], | 581 | ], |
| 582 | [ | ||
| 583 | 'script', | ||
| 584 | {}, | ||
| 585 | `(function(){try{var m={ayanami:'rei',asuka:'asuka',miku:'miku',inanis:'ina',amelia:'ame',baelz:'bae',irys:'irys',suisei:'suisei'};var a=localStorage.getItem('preference-accent-color')||'ayanami';var n;if(a==='fubuki'){var p=localStorage.getItem('vitepress-theme-appearance')||'auto';var d=p==='dark'||(p!=='light'&&window.matchMedia('(prefers-color-scheme: dark)').matches);n=d?'fubuki':'kuro'}else{n=m[a]||'rei'}document.documentElement.style.setProperty('--wk-sidebar-banner','url(/sidebar/'+n+'.avif)')}catch(e){}})()` | ||
| 586 | ], | ||
| 582 | ['meta', { name: 'theme-color', content: '#56b4fc' }], | 587 | ['meta', { name: 'theme-color', content: '#56b4fc' }], |
| 583 | ['meta', { name: 'og:type', content: 'website' }], | 588 | ['meta', { name: 'og:type', content: 'website' }], |
| 584 | ['meta', { name: 'og:locale', content: 'en' }], | 589 | ['meta', { name: 'og:locale', content: 'en' }], |
docs/.vitepress/theme/components/SidebarCard.vue +23 −11
| @@ -6,7 +6,7 @@ | |||
| 6 | All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder. | 6 | All rights reserved. This code and its associated files may not be copied, modified, distributed, sublicensed, or used in any form, in whole or in part, without prior written permission from the copyright holder. |
| 7 | --> | 7 | --> |
| 8 | <script setup lang="ts"> | 8 | <script setup lang="ts"> |
| 9 | import { computed } from 'vue' | 9 | import { computed, watch } from 'vue' |
| 10 | import { useData } from 'vitepress' | 10 | import { useData } from 'vitepress' |
| 11 | import { useStorage } from '@vueuse/core' | 11 | import { useStorage } from '@vueuse/core' |
| 12 | import { AccentColorStorageKey } from '../constants' | 12 | import { AccentColorStorageKey } from '../constants' |
| @@ -32,21 +32,33 @@ const sidebarImage = computed(() => { | |||
| 32 | const name = accentImageMap[accentColor.value] ?? 'rei' | 32 | const name = accentImageMap[accentColor.value] ?? 'rei' |
| 33 | return `/sidebar/${name}.avif` | 33 | return `/sidebar/${name}.avif` |
| 34 | }) | 34 | }) |
| 35 | |||
| 36 | if (typeof document !== 'undefined') { | ||
| 37 | watch( | ||
| 38 | sidebarImage, | ||
| 39 | (src) => { | ||
| 40 | document.documentElement.style.setProperty( | ||
| 41 | '--wk-sidebar-banner', | ||
| 42 | `url("${src}")` | ||
| 43 | ) | ||
| 44 | }, | ||
| 45 | { immediate: true } | ||
| 46 | ) | ||
| 47 | } | ||
| 35 | </script> | 48 | </script> |
| 36 | 49 | ||
| 37 | <template> | 50 | <template> |
| 38 | <div class="mt-2 overflow-hidden rounded-xl border-2 border-solid border-[#3d3d3d] relative z-0 max-md:border-2 max-md:border-[#3d3d3d]"> | 51 | <div |
| 39 | <img | 52 | class="sidebar-banner mt-2 overflow-hidden rounded-xl border-2 border-solid border-[#3d3d3d] relative z-0 max-md:border-2 max-md:border-[#3d3d3d]" |
| 40 | :src="sidebarImage" | 53 | /> |
| 41 | alt="" | ||
| 42 | class="w-full h-full object-cover block" | ||
| 43 | no-zoomable | ||
| 44 | /> | ||
| 45 | </div> | ||
| 46 | </template> | 54 | </template> |
| 47 | 55 | ||
| 48 | <style scoped> | 56 | <style scoped> |
| 49 | img { | 57 | .sidebar-banner { |
| 58 | aspect-ratio: 3 / 1; | ||
| 59 | background-image: var(--wk-sidebar-banner, url('/sidebar/rei.avif')); | ||
| 60 | background-size: cover; | ||
| 61 | background-position: center; | ||
| 50 | pointer-events: none; | 62 | pointer-events: none; |
| 51 | } | 63 | } |
| 52 | </style>\ No newline at end of file | 64 | </style> |