From 96f265507d797f0900f167161a6af6a683ccc2e6 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 30 Jun 2026 01:21:52 +0800 Subject: [PATCH] fix(docs): update offline driver downloads --- docs/app/[lang]/drivers/DriversClient.tsx | 222 ++++++++++++++-- docs/app/[lang]/drivers/page.tsx | 4 +- docs/app/global.css | 6 + docs/lib/agentRegistry.ts | 299 +++++++++++++++------- docs/lib/changelog.ts | 4 + docs/lib/latestRelease.ts | 4 + 6 files changed, 422 insertions(+), 117 deletions(-) diff --git a/docs/app/[lang]/drivers/DriversClient.tsx b/docs/app/[lang]/drivers/DriversClient.tsx index 1149aeb5e..61f31c0ad 100644 --- a/docs/app/[lang]/drivers/DriversClient.tsx +++ b/docs/app/[lang]/drivers/DriversClient.tsx @@ -3,15 +3,19 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import { useParams } from "next/navigation"; import { LandingNav } from "@/components/landing/LandingNav"; -import { buildDriverEntries, buildJreEntries, fetchAgentRegistry, formatSize, type AgentRegistry, type JreDisplayEntry } from "@/lib/agentRegistry"; -import { AlertTriangle, Cpu, Database, Download, Loader2, Search, X } from "lucide-react"; +import { fetchAgentDownloadCatalog, formatSize, type AgentDownloadCatalog, type JreDisplayEntry, type NativeAgentDisplayEntry, type OfflineBundleEntry } from "@/lib/agentRegistry"; +import { AlertTriangle, Archive, Cpu, Database, Download, Loader2, Search, Terminal, X } from "lucide-react"; const i18n = { en: { title: "Offline Driver Downloads", subtitle: "Download database drivers and JRE packages for offline use. Search for the exact resource your air-gapped environment needs.", + bundles: "Offline Bundles", + bundlesDesc: "Platform-specific ZIP packages that include the agent registry, database drivers, native agents, and the matching JRE.", drivers: "Database Drivers", driversDesc: "JDBC driver JAR files for each supported database type.", + nativeAgents: "Native Agents", + nativeAgentsDesc: "Go-based native agents for Oracle and XuguDB. Download the executable that matches the offline machine.", jre: "Java Runtime (JRE)", jreDesc: "JRE packages used by agent-based database drivers. Required for Oracle, SQL Server, and other agent-managed connections.", loading: "Loading driver catalog...", @@ -22,18 +26,23 @@ const i18n = { size: "Size", requiresJre: "Requires JRE", platform: "Platform", + filename: "File", search: "Search drivers, platforms, versions...", noResults: "No matching downloads.", showing: "Showing", of: "of", clearSearch: "Clear search", - downloadHint: "For air-gapped environments: download these files on an internet-connected machine, then transfer them to the offline machine and import them in DBX from Settings > Driver Manager.", + downloadHint: "For air-gapped environments: download the bundle for your platform on an internet-connected machine, then transfer it to the offline machine and import it in DBX from Settings > Driver Manager. Use the driver and JRE tabs only when you need individual artifacts.", }, cn: { title: "离线驱动下载", subtitle: "下载数据库驱动和 JRE 离线包。搜索内网环境需要的资源,在有网机器下载后传输。", + bundles: "整包下载", + bundlesDesc: "按平台提供的 ZIP 离线包,包含 Agent registry、数据库驱动、原生 Agent 和匹配的 JRE。", drivers: "数据库驱动", driversDesc: "每种支持的数据库类型对应的 JDBC 驱动 JAR 文件。", + nativeAgents: "原生 Agent", + nativeAgentsDesc: "Oracle 和虚谷使用 Go 原生 Agent,请下载与内网机器平台匹配的可执行文件。", jre: "Java 运行时 (JRE)", jreDesc: "Agent 驱动所需的 JRE 环境,Oracle、SQL Server 等数据库通过 Agent 连接时需要。", loading: "正在加载驱动列表...", @@ -44,21 +53,37 @@ const i18n = { size: "大小", requiresJre: "依赖 JRE", platform: "平台", + filename: "文件", search: "搜索驱动、平台、版本...", noResults: "没有匹配的下载项。", showing: "显示", of: "/", clearSearch: "清空搜索", - downloadHint: "内网环境使用说明:在有网的电脑上下载这些文件,然后传输到内网机器,在 DBX 的“设置 > 驱动管理”中导入。", + downloadHint: "内网环境使用说明:在有网的电脑上下载对应平台的整包,然后传输到内网机器,在 DBX 的“设置 > 驱动管理”中导入。只有需要单个产物时再使用驱动和 JRE 标签页。", }, }; -type ActiveTab = "drivers" | "jre"; +type ActiveTab = "bundles" | "drivers" | "native" | "jre"; function platformKey(j: JreDisplayEntry): string { return `${j.jreKey}-${j.platformKey}`; } +function bundleKey(bundle: OfflineBundleEntry): string { + return `${bundle.platformKey}-${bundle.filename}`; +} + +function nativeKey(agent: NativeAgentDisplayEntry): string { + return `${agent.key}-${agent.platformKey}`; +} + +type NativeAgentGroup = { + key: string; + label: string; + version: string; + options: NativeAgentDisplayEntry[]; +}; + function matchesSearch(values: Array, query: string): boolean { if (!query) return true; return values.filter(Boolean).join(" ").toLowerCase().includes(query); @@ -70,19 +95,20 @@ export function DriversClient() { const lang: "en" | "cn" = rawLang === "cn" ? "cn" : "en"; const t = i18n[lang]; - const [registry, setRegistry] = useState(null); + const [catalog, setCatalog] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); - const [activeTab, setActiveTab] = useState("drivers"); + const [activeTab, setActiveTab] = useState("bundles"); const [searchQuery, setSearchQuery] = useState(""); + const [selectedNativePlatforms, setSelectedNativePlatforms] = useState>({}); - const loadRegistry = useCallback(async () => { + const loadCatalog = useCallback(async () => { setLoading(true); setError(null); try { - const data = await fetchAgentRegistry(); + const data = await fetchAgentDownloadCatalog(); if (data) { - setRegistry(data); + setCatalog(data); } else { setError("Unable to load driver catalog"); } @@ -94,19 +120,68 @@ export function DriversClient() { }, []); useEffect(() => { - loadRegistry(); - }, [loadRegistry]); + loadCatalog(); + }, [loadCatalog]); - const drivers = useMemo(() => (registry ? buildDriverEntries(registry) : []), [registry]); - const jres = useMemo(() => (registry ? buildJreEntries(registry) : []), [registry]); + const bundles = catalog?.bundles ?? []; + const drivers = catalog?.drivers ?? []; + const nativeAgents = catalog?.nativeAgents ?? []; + const jres = catalog?.jres ?? []; const normalizedSearch = searchQuery.trim().toLowerCase(); + const filteredBundles = useMemo(() => bundles.filter((bundle) => matchesSearch([bundle.platformLabel, bundle.platformKey, bundle.filename, formatSize(bundle.size)], normalizedSearch)), [bundles, normalizedSearch]); + const filteredDrivers = useMemo(() => drivers.filter((d) => matchesSearch([d.label, d.key, d.version, d.jre, formatSize(d.jar.size)], normalizedSearch)), [drivers, normalizedSearch]); + const nativeGroups = useMemo(() => { + const groups = new Map(); + for (const agent of nativeAgents) { + const group = groups.get(agent.key); + if (group) { + group.options.push(agent); + } else { + groups.set(agent.key, { key: agent.key, label: agent.label, version: agent.version, options: [agent] }); + } + } + return Array.from(groups.values()); + }, [nativeAgents]); + + useEffect(() => { + if (nativeGroups.length === 0) return; + setSelectedNativePlatforms((current) => { + const next = { ...current }; + let changed = false; + for (const group of nativeGroups) { + if (group.options.length === 0) continue; + if (!next[group.key] || !group.options.some((option) => option.platformKey === next[group.key])) { + next[group.key] = group.options[0].platformKey; + changed = true; + } + } + return changed ? next : current; + }); + }, [nativeGroups]); + + const filteredNativeGroups = useMemo( + () => + nativeGroups.filter((group) => + matchesSearch( + [ + group.label, + group.key, + group.version, + ...group.options.flatMap((option) => [option.platformLabel, option.platformKey, option.filename, formatSize(option.info.size)]), + ], + normalizedSearch, + ), + ), + [nativeGroups, normalizedSearch], + ); + const filteredJres = useMemo(() => jres.filter((j) => matchesSearch([j.platformLabel, j.platformKey, j.jreVersion, j.jreKey, formatSize(j.info.size)], normalizedSearch)), [jres, normalizedSearch]); - const activeCount = activeTab === "drivers" ? filteredDrivers.length : filteredJres.length; - const activeTotal = activeTab === "drivers" ? drivers.length : jres.length; + const activeCount = activeTab === "bundles" ? filteredBundles.length : activeTab === "drivers" ? filteredDrivers.length : activeTab === "native" ? filteredNativeGroups.length : filteredJres.length; + const activeTotal = activeTab === "bundles" ? bundles.length : activeTab === "drivers" ? drivers.length : activeTab === "native" ? nativeGroups.length : jres.length; return (
@@ -132,26 +207,38 @@ export function DriversClient() {
{t.error} -
)} - {registry && !loading && ( + {catalog && !loading && ( <>
-
+
+ - + @@ -178,6 +265,43 @@ export function DriversClient() {
+ {activeTab === "bundles" && ( + <> +

{t.bundlesDesc}

+ + + + + + + + + + {filteredBundles.map((bundle) => ( + + + + + + + ))} + +
{t.platform}{t.filename}{t.size} +
+
+ {bundle.platformLabel} + ZIP +
+
{bundle.filename}{formatSize(bundle.size)} + + + {t.download} + +
+ {filteredBundles.length === 0 &&
{t.noResults}
} + + )} + {activeTab === "drivers" && ( <>

{t.driversDesc}

@@ -221,6 +345,62 @@ export function DriversClient() { )} + {activeTab === "native" && ( + <> +

{t.nativeAgentsDesc}

+ + + + + + + + + + + {filteredNativeGroups.map((group) => { + const selectedPlatform = selectedNativePlatforms[group.key] ?? group.options[0]?.platformKey; + const selectedAgent = group.options.find((option) => option.platformKey === selectedPlatform) ?? group.options[0]; + if (!selectedAgent) return null; + return ( + + + + + + + + ); + })} + +
Agent{t.platform}{t.version}{t.size} +
+
+ {group.label} + {selectedAgent.platformKey} +
+
+ + {group.version}{formatSize(selectedAgent.info.size)} + + + {t.download} + +
+ {filteredNativeGroups.length === 0 &&
{t.noResults}
} + + )} + {activeTab === "jre" && ( <>

{t.jreDesc}

diff --git a/docs/app/[lang]/drivers/page.tsx b/docs/app/[lang]/drivers/page.tsx index d1f24e8c4..5dc331d41 100644 --- a/docs/app/[lang]/drivers/page.tsx +++ b/docs/app/[lang]/drivers/page.tsx @@ -5,11 +5,11 @@ import type { Metadata } from "next"; const pageMeta = { en: { title: "Offline Driver Downloads", - description: "Download all database drivers and JRE packages for offline use. Supports 30+ database types across macOS, Linux, and Windows.", + description: "Download DBX offline driver bundles, database drivers, and JRE packages for air-gapped environments across macOS, Linux, and Windows.", }, cn: { title: "离线驱动下载", - description: "下载所有数据库驱动和 JRE 离线包,支持 30+ 种数据库类型,覆盖 macOS、Linux、Windows 平台。", + description: "下载 DBX 离线驱动整包、数据库驱动和 JRE 离线包,覆盖 macOS、Linux、Windows 平台。", }, }; diff --git a/docs/app/global.css b/docs/app/global.css index 9528e043f..20f25dec1 100644 --- a/docs/app/global.css +++ b/docs/app/global.css @@ -91,6 +91,12 @@ article { color: color-mix(in srgb, var(--color-fd-foreground) 92%, var(--color-fd-muted-foreground)); } +article, +article :where(h1, h2, h3, h4, h5, h6, p, li, blockquote, table, th, td, pre, code, span, strong, em) { + -webkit-user-select: text; + user-select: text; +} + article h1 { letter-spacing: 0; line-height: 1.08; diff --git a/docs/lib/agentRegistry.ts b/docs/lib/agentRegistry.ts index ceb205d6d..a0ea60e85 100644 --- a/docs/lib/agentRegistry.ts +++ b/docs/lib/agentRegistry.ts @@ -1,57 +1,26 @@ -const R2_CDN_BASE = "https://dl.dbxio.com"; - -function filenameFromUrl(url: string): string { - return url.split("/").pop() ?? url; -} - -function githubUrlToR2Url(url: string, category: "jre" | "driver"): string { - const filename = filenameFromUrl(url); - return `${R2_CDN_BASE}/agents/${category}/${filename}`; -} +import driverVersions from "../../agents/versions.json"; export interface ArtifactInfo { url: string; size: number; } -export interface JreInfo { - version: string; - platforms: Record; +export interface GitHubReleaseAsset { + name: string; + size: number; + browser_download_url: string; } -export interface DriverInfo { - version: string; - label: string; - min_app_version: string; - jar: ArtifactInfo; - jre: string; +interface GitHubRelease { + assets?: GitHubReleaseAsset[]; } -export interface AgentRegistry { - jre?: JreInfo; - jres?: Record; - drivers: Record; -} - -const AGENT_REGISTRY_R2_URL = "https://dl.dbxio.com/agents/agent-registry.json"; -const AGENT_REGISTRY_GITHUB_URL = "https://github.com/t8y2/dbx/releases/download/agents-latest/agent-registry.json"; - -export async function fetchAgentRegistry(): Promise { - const urls = [AGENT_REGISTRY_R2_URL, AGENT_REGISTRY_GITHUB_URL]; - for (const url of urls) { - try { - const res = await fetch(url, { - cache: "no-store", - headers: { Accept: "application/json" }, - }); - if (res.ok) { - return (await res.json()) as AgentRegistry; - } - } catch { - continue; - } - } - return null; +export interface OfflineBundleEntry { + platformKey: string; + platformLabel: string; + filename: string; + size: number; + url: string; } export interface JreDisplayEntry { @@ -60,7 +29,6 @@ export interface JreDisplayEntry { info: ArtifactInfo; jreVersion: string; jreKey: string; - r2Url: string; } export interface DriverDisplayEntry { @@ -70,60 +38,203 @@ export interface DriverDisplayEntry { minAppVersion: string; jar: ArtifactInfo; jre: string; - r2Url: string; } -export function buildJreEntries(registry: AgentRegistry): JreDisplayEntry[] { - const entries: JreDisplayEntry[] = []; - const platformLabels: Record = { - "macos-aarch64": "macOS (Apple Silicon)", - "macos-x64": "macOS (Intel)", - "linux-aarch64": "Linux (ARM64)", - "linux-x64": "Linux (x64)", - "windows-aarch64": "Windows (ARM64)", - "windows-x64": "Windows (x64)", +export interface NativeAgentDisplayEntry { + key: string; + label: string; + version: string; + platformKey: string; + platformLabel: string; + filename: string; + info: ArtifactInfo; +} + +export interface AgentDownloadCatalog { + bundles: OfflineBundleEntry[]; + drivers: DriverDisplayEntry[]; + jres: JreDisplayEntry[]; + nativeAgents: NativeAgentDisplayEntry[]; +} + +const AGENTS_LATEST_RELEASE_API_URL = "https://api.github.com/repos/t8y2/dbx/releases/tags/agents-latest"; +const MIN_APP_VERSION = "0.6.0"; +const driverVersionMap = driverVersions as Record; +const nativeDriverKeys = new Set(["oracle", "xugu"]); + +const platformLabels: Record = { + "macos-aarch64": "macOS (Apple Silicon)", + "macos-x64": "macOS (Intel)", + "linux-aarch64": "Linux (ARM64)", + "linux-x64": "Linux (x64)", + "windows-aarch64": "Windows (ARM64)", + "windows-x64": "Windows (x64)", +}; + +const driverLabels: Record = { + access: "Microsoft Access", + bigquery: "BigQuery", + cassandra: "Cassandra", + dameng: "Dameng", + databend: "Databend", + databricks: "Databricks", + db2: "DB2", + etcd: "etcd", + exasol: "Exasol", + firebird: "Firebird", + gbase8a: "GBase 8a", + gbase8s: "GBase 8s", + goldendb: "GoldenDB", + h2: "H2", + highgo: "HighGo", + hive: "Hive", + informix: "Informix", + iotdb: "Apache IoTDB", + iris: "InterSystems IRIS", + kingbase: "KingBase", + kylin: "Apache Kylin", + mongodb: "MongoDB (Legacy)", + neo4j: "Neo4j", + "oceanbase-oracle": "OceanBase Oracle Mode", + oracle: "Oracle", + saphana: "SAP HANA", + snowflake: "Snowflake", + sundb: "SunDB", + tdengine: "TDengine", + teradata: "Teradata", + trino: "Trino", + vastbase: "Vastbase", + vertica: "Vertica", + xugu: "虚谷 XuguDB", + yashandb: "YashanDB", + zookeeper: "ZooKeeper", +}; + +const currentDriverKeys = Object.keys(driverVersionMap).sort((a, b) => labelForDriver(a).localeCompare(labelForDriver(b))); +const currentJavaDriverKeys = currentDriverKeys.filter((key) => !nativeDriverKeys.has(key)); + +const jreVersions: Record = { + "21": "21", +}; + +function labelForDriver(key: string): string { + return driverLabels[key] ?? key.replace(/-/g, " "); +} + +function assetInfo(asset: GitHubReleaseAsset): ArtifactInfo { + return { + url: asset.browser_download_url, + size: asset.size, }; - - const jres = registry.jres ?? {}; - for (const [key, jreInfo] of Object.entries(jres)) { - for (const [platformKey, artifact] of Object.entries(jreInfo.platforms)) { - entries.push({ - platformKey, - platformLabel: platformLabels[platformKey] ?? platformKey, - info: artifact, - jreVersion: jreInfo.version, - jreKey: key, - r2Url: githubUrlToR2Url(artifact.url, "jre"), - }); - } - } - - if (entries.length === 0 && registry.jre) { - for (const [platformKey, artifact] of Object.entries(registry.jre.platforms)) { - entries.push({ - platformKey, - platformLabel: platformLabels[platformKey] ?? platformKey, - info: artifact, - jreVersion: registry.jre.version, - jreKey: "21", - r2Url: githubUrlToR2Url(artifact.url, "jre"), - }); - } - } - - return entries; } -export function buildDriverEntries(registry: AgentRegistry): DriverDisplayEntry[] { - return Object.entries(registry.drivers).map(([key, info]) => ({ - key, - label: info.label, - version: info.version, - minAppVersion: info.min_app_version, - jar: info.jar, - jre: info.jre, - r2Url: githubUrlToR2Url(info.jar.url, "driver"), - })); +function assetMap(assets: GitHubReleaseAsset[]): Map { + return new Map(assets.map((asset) => [asset.name, asset])); +} + +export async function fetchAgentDownloadCatalog(): Promise { + try { + const res = await fetch(AGENTS_LATEST_RELEASE_API_URL, { + cache: "no-store", + headers: { Accept: "application/vnd.github+json" }, + }); + if (!res.ok) return null; + + const release = (await res.json()) as GitHubRelease; + return buildAgentDownloadCatalog(release.assets ?? []); + } catch { + return null; + } +} + +export function buildAgentDownloadCatalog(assets: GitHubReleaseAsset[]): AgentDownloadCatalog { + return { + bundles: buildOfflineBundleEntries(assets), + drivers: buildDriverEntries(assets), + jres: buildJreEntries(assets), + nativeAgents: buildNativeAgentEntries(assets), + }; +} + +export function buildJreEntries(assets: GitHubReleaseAsset[]): JreDisplayEntry[] { + return assets + .map((asset) => { + const match = /^dbx-jre-(\d+)-(.+)\.tar\.gz$/.exec(asset.name); + if (!match) return null; + + const [, jreKey, platformKey] = match; + if (!jreVersions[jreKey]) return null; + + return { + platformKey, + platformLabel: platformLabels[platformKey] ?? platformKey, + info: assetInfo(asset), + jreVersion: jreVersions[jreKey], + jreKey, + }; + }) + .filter((entry): entry is JreDisplayEntry => entry !== null) + .sort((a, b) => a.platformLabel.localeCompare(b.platformLabel)); +} + +export function buildDriverEntries(assets: GitHubReleaseAsset[]): DriverDisplayEntry[] { + const byName = assetMap(assets); + + return currentJavaDriverKeys + .map((key) => { + const asset = byName.get(`dbx-agent-${key}.jar`); + if (!asset) return null; + + return { + key, + label: labelForDriver(key), + version: driverVersionMap[key] ?? "", + minAppVersion: MIN_APP_VERSION, + jar: assetInfo(asset), + jre: "21", + }; + }) + .filter((entry): entry is DriverDisplayEntry => entry !== null); +} + +export function buildNativeAgentEntries(assets: GitHubReleaseAsset[]): NativeAgentDisplayEntry[] { + const entries: NativeAgentDisplayEntry[] = []; + + for (const asset of assets) { + const match = /^dbx-agent-(oracle|xugu)-(.+?)(?:\.exe)?$/.exec(asset.name); + if (!match) continue; + + const [, key, platformKey] = match; + entries.push({ + key, + label: labelForDriver(key), + version: driverVersionMap[key] ?? "", + platformKey, + platformLabel: platformLabels[platformKey] ?? platformKey, + filename: asset.name, + info: assetInfo(asset), + }); + } + + return entries.sort((a, b) => a.label.localeCompare(b.label) || a.platformLabel.localeCompare(b.platformLabel)); +} + +export function buildOfflineBundleEntries(assets: GitHubReleaseAsset[]): OfflineBundleEntry[] { + return assets + .map((asset) => { + const match = /^dbx-agents-offline-(.+)\.zip$/.exec(asset.name); + if (!match) return null; + const platformKey = match[1]; + return { + platformKey, + platformLabel: platformLabels[platformKey] ?? platformKey, + filename: asset.name, + size: asset.size, + url: asset.browser_download_url, + }; + }) + .filter((entry): entry is OfflineBundleEntry => entry !== null) + .sort((a, b) => a.platformLabel.localeCompare(b.platformLabel)); } export function formatSize(bytes: number): string { diff --git a/docs/lib/changelog.ts b/docs/lib/changelog.ts index 700eecd26..ee74f2240 100644 --- a/docs/lib/changelog.ts +++ b/docs/lib/changelog.ts @@ -55,6 +55,10 @@ export function changelogUrl(lang: "en" | "cn") { } export async function fetchChangelog(lang: "en" | "cn"): Promise { + if (typeof window !== "undefined") { + return fetchGitHubChangelog(); + } + const url = changelogUrl(lang); try { diff --git a/docs/lib/latestRelease.ts b/docs/lib/latestRelease.ts index eba09dc0d..e0c1767ba 100644 --- a/docs/lib/latestRelease.ts +++ b/docs/lib/latestRelease.ts @@ -21,6 +21,10 @@ function normalizeVersion(version: string) { } export async function fetchLatestReleaseInfo(): Promise { + if (typeof window !== "undefined") { + return fetchGitHubLatestReleaseInfo(); + } + try { const release = await requestJson(createUncachedUrl(LATEST_RELEASE_URL, browserCacheBuster()), releaseMetadataRequestInit()); return release.version ? { ...release, version: normalizeVersion(release.version) } : null;