From 1cf14f3fd5a725454cc68e00aad880f0f0eb6e0f Mon Sep 17 00:00:00 2001 From: shenlan Date: Tue, 11 Nov 2025 19:48:16 +0800 Subject: [PATCH] Fix dashboard download imports and registry alias (#672) --- .../src/lib/download/dl-index-data-docs.ts | 48 +------------------ .../download/dl-index-data-offline-package.ts | 2 +- dashboard/src/products/registry.ts | 1 + 3 files changed, 4 insertions(+), 47 deletions(-) create mode 100644 dashboard/src/products/registry.ts diff --git a/dashboard/src/lib/download/dl-index-data-docs.ts b/dashboard/src/lib/download/dl-index-data-docs.ts index 0989136..e7709a1 100644 --- a/dashboard/src/lib/download/dl-index-data-docs.ts +++ b/dashboard/src/lib/download/dl-index-data-docs.ts @@ -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 { - 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 { - 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 { - if (cachedListings) { - return cachedListings - } - - cachedListings = await loadDownloadListings() - return cachedListings -} - -export function clearDownloadListingsCache(): void { - cachedListings = null -} diff --git a/dashboard/src/lib/download/dl-index-data-offline-package.ts b/dashboard/src/lib/download/dl-index-data-offline-package.ts index a0101d7..a2ba0d8 100644 --- a/dashboard/src/lib/download/dl-index-data-offline-package.ts +++ b/dashboard/src/lib/download/dl-index-data-offline-package.ts @@ -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' diff --git a/dashboard/src/products/registry.ts b/dashboard/src/products/registry.ts new file mode 100644 index 0000000..a9f82e9 --- /dev/null +++ b/dashboard/src/products/registry.ts @@ -0,0 +1 @@ +export { PRODUCT_LIST, PRODUCT_MAP, getAllSlugs, type ProductConfig } from '@modules/products/registry'