Fix dashboard download imports and registry alias (#672)
This commit is contained in:
parent
d647d02992
commit
1cf14f3fd5
@ -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
|
||||
}
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
1
dashboard/src/products/registry.ts
Normal file
1
dashboard/src/products/registry.ts
Normal file
@ -0,0 +1 @@
|
||||
export { PRODUCT_LIST, PRODUCT_MAP, getAllSlugs, type ProductConfig } from '@modules/products/registry'
|
||||
Loading…
Reference in New Issue
Block a user