Commit d643e4618d

d643e4618d9007f85adfb66ab1236891bef74b42

parent: 899aa16d38

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-10-13 10:13 UTC

Update ExtensionRepos.vue

Layout: unified · split

docs/.vitepress/theme/components/extrepo/ExtensionRepos.vue +34 −1
@@ -1,6 +1,6 @@
1<script setup lang="ts"> 1<script setup lang="ts">
2import { refDebounced } from '@vueuse/core' 2import { refDebounced } from '@vueuse/core'
3import { computed, onUnmounted, ref } from 'vue' 3import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
4import { SEARCH_DEBOUNCE_MS, STATUS_TICK_MS } from './constants' 4import { SEARCH_DEBOUNCE_MS, STATUS_TICK_MS } from './constants'
5import { escapeHtml, stripHtml } from './helpers' 5import { escapeHtml, stripHtml } from './helpers'
6import { mangayomiCopyValue } from './install' 6import { mangayomiCopyValue } from './install'
@@ -40,6 +40,39 @@ onUnmounted(() => {
40 if (tickTimer) clearTimeout(tickTimer) 40 if (tickTimer) clearTimeout(tickTimer)
41}) 41})
42 42
43let lastCorrectedHash: string | null = null
44
45function correctAnchorScroll() {
46 if (typeof window === 'undefined') return
47 const hash = window.location.hash
48 if (!hash || hash.length < 2 || hash === lastCorrectedHash) return
49 const raw = hash.slice(1)
50 let id = raw
51 try {
52 id = decodeURIComponent(raw)
53 } catch {
54 }
55 const target = document.getElementById(id) ?? document.getElementById(raw)
56 if (!target) return
57 lastCorrectedHash = hash
58 void nextTick(() => {
59 requestAnimationFrame(() => {
60 requestAnimationFrame(() => {
61 const navBar = document.querySelector<HTMLElement>('.VPNavBar')
62 const navOffset = navBar ? navBar.offsetHeight : 0
63 window.scrollTo({
64 top: target.getBoundingClientRect().top + window.scrollY - navOffset,
65 behavior: 'auto'
66 })
67 })
68 })
69 })
70}
71
72watch(loading, (value, oldValue) => {
73 if (oldValue && !value) correctAnchorScroll()
74})
75
43async function onStatusClick() { 76async function onStatusClick() {
44 if (loading.value || refreshing.value) return 77 if (loading.value || refreshing.value) return
45 if (loadFailed.value) { 78 if (loadFailed.value) {