Commit 3042c9c660
3042c9c66047a89af23027833a56ab7807ac2795
parent: a11db1db8e
Unsigned
Duck <57977673+woducku@users.noreply.github.com> · 2026-07-12 11:18 UTC
broken
Layout: unified · split
docs/.vitepress/theme/components/extrepo/BrokenFilter.vue
added
+35
| @@ -0,0 +1,35 @@ |
| 1 | <script setup lang="ts"> |
| 2 | import { NuInputHorizontalRadioGroup } from '@nolebase/ui' |
| 3 | import { computed } from 'vue' |
| 4 | import MenuTitle from './MenuTitle.vue' |
| 5 | |
| 6 | const props = defineProps<{ |
| 7 | modelValue: boolean |
| 8 | }>() |
| 9 | |
| 10 | const emit = defineEmits<{ |
| 11 | 'update:modelValue': [value: boolean] |
| 12 | }>() |
| 13 | |
| 14 | const options = [ |
| 15 | { value: 'on', title: 'On', ariaLabel: 'On', text: 'ON', name: 'ShowBroken' }, |
| 16 | { value: 'off', title: 'Off', ariaLabel: 'Off', text: 'OFF', name: 'ShowBroken' } |
| 17 | ] |
| 18 | |
| 19 | const showBroken = computed({ |
| 20 | get: () => props.modelValue ? 'on' : 'off', |
| 21 | set: (value: string) => emit('update:modelValue', value === 'on') |
| 22 | }) |
| 23 | </script> |
| 24 | |
| 25 | <template> |
| 26 | <div class="ext-broken" role="radiogroup"> |
| 27 | <MenuTitle icon="i-lucide:unlink" title="Show broken urls" /> |
| 28 | <NuInputHorizontalRadioGroup |
| 29 | v-model="showBroken" |
| 30 | bg="$vp-nolebase-enhanced-readabilities-menu-background-color" |
| 31 | text="sm $vp-nolebase-enhanced-readabilities-menu-text-color" |
| 32 | :options="options" |
| 33 | /> |
| 34 | </div> |
| 35 | </template> |
docs/.vitepress/theme/components/extrepo/ExtensionRepos.vue
+6 −1
| @@ -17,6 +17,7 @@ const query = ref('') |
| 17 | 17 | const langFilter = ref('') |
| 18 | 18 | const ratingFilter = ref<RatingFilter>('all') |
| 19 | 19 | const excludedContentTypes = ref<Set<string>>(new Set()) |
| 20 | const showBroken = ref(false) |
| 20 | 21 | |
| 21 | 22 | const allSites = computed<MatchedSite[]>(() => { |
| 22 | 23 | const sites: MatchedSite[] = [] |
| @@ -52,6 +53,7 @@ const hasContentTypes = computed(() => availableContentTypes.value.length > 0) |
| 52 | 53 | const hasRatings = computed(() => allSites.value.some(site => site.rating !== 'safe')) |
| 53 | 54 | const hasSuggestive = computed(() => allSites.value.some(site => site.rating === 'suggestive')) |
| 54 | 55 | const hasMultiLanguage = computed(() => allSites.value.some(site => site.lang.toLowerCase() === 'all')) |
| 56 | const hasBroken = computed(() => allSites.value.some(site => site.isBroken)) |
| 55 | 57 | |
| 56 | 58 | const availableLangs = computed(() => { |
| 57 | 59 | const codes = new Set(allSites.value.map(site => site.lang)) |
| @@ -66,6 +68,7 @@ const isFiltering = computed(() => { |
| 66 | 68 | const filteredSites = computed(() => { |
| 67 | 69 | const q = query.value.trim().toLowerCase() |
| 68 | 70 | return allSites.value.filter(site => { |
| 71 | if (site.isBroken && !showBroken.value) return false |
| 69 | 72 | if (q && !site.name.toLowerCase().includes(q) && !site.url.toLowerCase().includes(q)) return false |
| 70 | 73 | if (langFilter.value && site.lang !== langFilter.value) return false |
| 71 | 74 | if (ratingFilter.value !== 'all' && site.rating !== ratingFilter.value) return false |
| @@ -86,12 +89,14 @@ const filteredSites = computed(() => { |
| 86 | 89 | v-model:lang-filter="langFilter" |
| 87 | 90 | v-model:rating-filter="ratingFilter" |
| 88 | 91 | v-model:content-type-filter="excludedContentTypes" |
| 92 | v-model:show-broken="showBroken" |
| 89 | 93 | :available-langs="availableLangs" |
| 90 | 94 | :has-multi-language="hasMultiLanguage" |
| 91 | 95 | :has-ratings="hasRatings" |
| 92 | 96 | :has-suggestive="hasSuggestive" |
| 93 | 97 | :available-content-types="availableContentTypes" |
| 94 | 98 | :has-content-types="hasContentTypes" |
| 99 | :has-broken="hasBroken" |
| 95 | 100 | /> |
| 96 | 101 | </div> |
| 97 | 102 | |
| @@ -103,7 +108,7 @@ const filteredSites = computed(() => { |
| 103 | 108 | /> |
| 104 | 109 | |
| 105 | 110 | <div v-else> |
| 106 | | <RepoRow v-for="repo in repos" :key="repo.indexUrl" :repo="repo" :scheme="scheme" /> |
| 111 | <RepoRow v-for="repo in repos" :key="repo.indexUrl" :repo="repo" :scheme="scheme" :show-broken="showBroken" /> |
| 107 | 112 | </div> |
| 108 | 113 | </div> |
| 109 | 114 | </template> |
docs/.vitepress/theme/components/extrepo/RepoRow.vue
+7 −2
| @@ -9,6 +9,7 @@ import type { Repo, RepoVariant } from './types' |
| 9 | 9 | const props = defineProps<{ |
| 10 | 10 | repo: Repo |
| 11 | 11 | scheme: string |
| 12 | showBroken?: boolean |
| 12 | 13 | }>() |
| 13 | 14 | |
| 14 | 15 | const NOT_EXPANDABLE = new Set(['MegaRepo', 'Shotetsu Compatability']) |
| @@ -18,7 +19,10 @@ const copied = ref(false) |
| 18 | 19 | const copiedLabel = ref<string | null>(null) |
| 19 | 20 | const openVariants = ref<Set<string>>(new Set()) |
| 20 | 21 | |
| 21 | | const sites = computed(() => repoData[props.repo.indexUrl]?.sites ?? []) |
| 22 | const sites = computed(() => { |
| 23 | const all = repoData[props.repo.indexUrl]?.sites ?? [] |
| 24 | return props.showBroken ? all : all.filter(site => !site.isBroken) |
| 25 | }) |
| 22 | 26 | const isExpandable = computed(() => !NOT_EXPANDABLE.has(stripHtml(props.repo.name))) |
| 23 | 27 | const installUrl = computed(() => installHref(props.scheme, props.repo)) |
| 24 | 28 | // Browse-only schemes (e.g. Kotatsu forks) have no app to deep-link into, so install, |
| @@ -56,7 +60,8 @@ function toggleVariant(label: string) { |
| 56 | 60 | |
| 57 | 61 | function variantSites(variant: RepoVariant) { |
| 58 | 62 | const url = mangayomiCopyValue(variant) |
| 59 | | return url ? repoData[url]?.sites ?? [] : [] |
| 63 | const all = url ? repoData[url]?.sites ?? [] : [] |
| 64 | return props.showBroken ? all : all.filter(site => !site.isBroken) |
| 60 | 65 | } |
| 61 | 66 | </script> |
| 62 | 67 | |
docs/.vitepress/theme/components/extrepo/SettingsMenu.vue
+9
| @@ -1,5 +1,6 @@ |
| 1 | 1 | <script setup lang="ts"> |
| 2 | 2 | import { nextTick, onMounted, onUnmounted, ref } from 'vue' |
| 3 | import BrokenFilter from './BrokenFilter.vue' |
| 3 | 4 | import ContentTypeFilter from './ContentTypeFilter.vue' |
| 4 | 5 | import LangSelect from './LangSelect.vue' |
| 5 | 6 | import RatingFilter from './RatingFilter.vue' |
| @@ -15,12 +16,15 @@ defineProps<{ |
| 15 | 16 | contentTypeFilter: Set<string> |
| 16 | 17 | availableContentTypes: string[] |
| 17 | 18 | hasContentTypes: boolean |
| 19 | showBroken: boolean |
| 20 | hasBroken: boolean |
| 18 | 21 | }>() |
| 19 | 22 | |
| 20 | 23 | defineEmits<{ |
| 21 | 24 | 'update:langFilter': [value: string] |
| 22 | 25 | 'update:ratingFilter': [value: RatingFilterValue] |
| 23 | 26 | 'update:contentTypeFilter': [value: Set<string>] |
| 27 | 'update:showBroken': [value: boolean] |
| 24 | 28 | }>() |
| 25 | 29 | |
| 26 | 30 | const rootRef = ref<HTMLElement>() |
| @@ -115,6 +119,11 @@ onUnmounted(() => { |
| 115 | 119 | :available-types="availableContentTypes" |
| 116 | 120 | @update:model-value="$emit('update:contentTypeFilter', $event)" |
| 117 | 121 | /> |
| 122 | <BrokenFilter |
| 123 | v-if="hasBroken" |
| 124 | :model-value="showBroken" |
| 125 | @update:model-value="$emit('update:showBroken', $event)" |
| 126 | /> |
| 118 | 127 | </div> |
| 119 | 128 | </Teleport> |
| 120 | 129 | </div> |
docs/.vitepress/theme/components/extrepo/types.ts
+1
| @@ -25,6 +25,7 @@ export interface RepoSite { |
| 25 | 25 | rating: Rating |
| 26 | 26 | // Only for kotatsu |
| 27 | 27 | contentType?: string |
| 28 | isBroken?: boolean |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | export interface MatchedSite extends RepoSite { |
docs/ext/extensionRepos.data.ts
+2 −3
| @@ -13,6 +13,7 @@ export interface RepoSite { |
| 13 | 13 | url: string |
| 14 | 14 | rating: Rating |
| 15 | 15 | contentType?: string |
| 16 | isBroken?: boolean |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | 19 | export interface RepoData { |
| @@ -390,14 +391,12 @@ function toRepoDataKotatsu(index: KotatsuIndex): RepoSite[] { |
| 390 | 391 | const sites: RepoSite[] = [] |
| 391 | 392 | |
| 392 | 393 | for (const site of index.sites) { |
| 393 | | // Broken parsers aren't "available" sites -- skip rather than surface a dead link. |
| 394 | | if (site.isBroken) continue |
| 395 | 394 | const lang = normalizeLang(site.lang) |
| 396 | 395 | const key = `${site.name}::${lang}::${site.url}` |
| 397 | 396 | if (seen.has(key)) continue |
| 398 | 397 | seen.add(key) |
| 399 | 398 | const rating: Rating = site.contentType.includes('HENTAI') ? 'nsfw' : 'safe' |
| 400 | | sites.push({ name: site.name, lang, icon: site.icon, url: site.url, rating, contentType: site.contentType }) |
| 399 | sites.push({ name: site.name, lang, icon: site.icon, url: site.url, rating, contentType: site.contentType, isBroken: site.isBroken || undefined }) |
| 401 | 400 | } |
| 402 | 401 | |
| 403 | 402 | return sites |