Fix dashboard download imports and registry alias (#672)

This commit is contained in:
shenlan 2025-11-11 19:48:16 +08:00 committed by GitHub
parent d647d02992
commit 1cf14f3fd5
3 changed files with 4 additions and 47 deletions

View File

@ -1,47 +1,3 @@
// DEPRECATED: This file is a compatibility alias
// Use dl-index-data-artifacts.ts instead
// DEPRECATED: This file is a compatibility alias.
// Use dl-index-data-artifacts.ts instead.
export { getDownloadListings, clearDownloadListingsCache } from './dl-index-data-artifacts'
async function fetchListings(url: string): Promise<DirListing[]> {
try {
const response = await fetch(url, {
cache: 'no-cache',
})
if (!response.ok) {
throw new Error(`Failed to fetch: ${response.statusText}`)
}
const data = await response.json()
return Array.isArray(data) ? (data as DirListing[]) : []
} catch (error) {
console.error(`Error fetching from ${url}:`, error)
return []
}
}
async function loadDownloadListings(): Promise<DirListing[]> {
const manifestListings = await fetchListings(ARTIFACTS_MANIFEST_URL)
if (manifestListings.length > 0) {
return manifestListings
}
const fallbackListings = await fetchListings(FALLBACK_LISTINGS_URL)
return fallbackListings
}
let cachedListings: DirListing[] | null = null
export async function getDownloadListings(): Promise<DirListing[]> {
if (cachedListings) {
return cachedListings
}
cachedListings = await loadDownloadListings()
return cachedListings
}
export function clearDownloadListingsCache(): void {
cachedListings = null
}

View File

@ -1,5 +1,5 @@
import type { DirListing } from './types'
import { buildDownloadSections, countFiles, findListing, formatSegmentLabel, type DownloadSection } from './download-data'
import { buildDownloadSections, countFiles, findListing, formatSegmentLabel, type DownloadSection } from '../download-data'
const OFFLINE_PACKAGE_URL = 'https://dl.svc.plus/dl-index/offline-package.json'

View File

@ -0,0 +1 @@
export { PRODUCT_LIST, PRODUCT_MAP, getAllSlugs, type ProductConfig } from '@modules/products/registry'