diff --git a/docs/app/global.css b/docs/app/global.css index d703484104..4d328f987d 100644 --- a/docs/app/global.css +++ b/docs/app/global.css @@ -651,7 +651,7 @@ a { /* Install dropdown */ -.landing-install::after { +.landing-install-control::after { content: ""; position: absolute; top: 100%; @@ -1119,6 +1119,19 @@ a { } @media (max-width: 760px) { + .landing-install-menu { + position: static; + display: none; + width: min(380px, calc(100vw - 32px)); + margin-top: 12px; + translate: none; + transform: none; + } + + .landing-install[data-open="true"] .landing-install-menu { + display: grid; + } + .landing-nav-inner { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); diff --git a/docs/components/landing/InstallTabs.tsx b/docs/components/landing/InstallTabs.tsx index 99f0416cbd..e6a0163b46 100644 --- a/docs/components/landing/InstallTabs.tsx +++ b/docs/components/landing/InstallTabs.tsx @@ -10,6 +10,10 @@ type InstallTabsProps = { }; const downloadLabel = { en: "Download DBX", cn: "下载 DBX" }; +const offlineHint = { + en: "Offline network or Windows 7? Choose an offline installer", + cn: "无法联网或使用 Windows 7?选择专用离线安装包", +}; const platformIconPaths = { dark: { @@ -63,7 +67,10 @@ export function InstallTabs({ lang, version }: InstallTabsProps) { }, [open]); const primary = useMemo(() => options.find((o) => o.id === platformId) ?? options[0], [options, platformId]); - const menuOptions = useMemo(() => options.filter((o) => o.id !== platformId), [options, platformId]); + const menuOptions = useMemo( + () => options.filter((option) => option.id !== primary.id).sort((a, b) => Number(b.iconId === primary.iconId) - Number(a.iconId === primary.iconId)), + [options, primary], + ); return (
-
- - - - {downloadLabel[lang]} - {primary.label} - - +
+
+ + + + {downloadLabel[lang]} + {primary.label} + + + +
+ +
+ {platformId === "windows" && !open ? ( -
- + ) : null}
); } diff --git a/docs/lib/downloadLinks.test.ts b/docs/lib/downloadLinks.test.ts new file mode 100644 index 0000000000..f794ff90f1 --- /dev/null +++ b/docs/lib/downloadLinks.test.ts @@ -0,0 +1,35 @@ +import assert from "node:assert/strict"; +import { test } from "vitest"; + +import { createInstallOptions } from "./downloadLinks"; + +test("Windows downloads include standard, offline, and Windows 7 installers", () => { + const windowsOptions = createInstallOptions("cn", "0.5.82").filter((option) => option.iconId === "windows"); + + assert.deepEqual( + windowsOptions.map(({ id, label, description, badge, href }) => ({ id, label, description, badge, href })), + [ + { + id: "windows", + label: "Windows 10/11 (x64)", + description: "标准在线安装包", + badge: "推荐", + href: "https://dl.dbxio.com/releases/latest/DBX_0.5.82_x64-setup.exe?v=0.5.82", + }, + { + id: "windows-offline", + label: "Windows 10/11 离线安装包", + description: "内置 WebView2 · 适用于无网络环境", + badge: "离线", + href: "https://dl.dbxio.com/releases/latest/DBX_0.5.82_x64-webview2-offline-setup.exe?v=0.5.82", + }, + { + id: "windows-7-offline", + label: "Windows 7 离线安装包", + description: "内置 WebView2 109 · 仅支持 x64", + badge: "旧系统", + href: "https://dl.dbxio.com/releases/latest/DBX_0.5.82_x64-win7-webview2-109-offline-setup.exe?v=0.5.82", + }, + ], + ); +}); diff --git a/docs/lib/downloadLinks.ts b/docs/lib/downloadLinks.ts index fd43dffd38..110e43c701 100644 --- a/docs/lib/downloadLinks.ts +++ b/docs/lib/downloadLinks.ts @@ -2,13 +2,19 @@ export type InstallLang = "en" | "cn"; export type InstallOption = { id: string; + iconId: string; label: string; + description?: string; + badge?: string; href: string; }; type DownloadArtifact = { id: string; + iconId: string; labels: Record; + descriptions?: Record; + badges?: Record; suffix: string; }; @@ -17,26 +23,49 @@ const DOWNLOAD_BASE_URL = "https://dl.dbxio.com/releases/latest"; const downloadArtifacts: DownloadArtifact[] = [ { id: "macos-arm", + iconId: "macos-arm", labels: { en: "For macOS (Apple Silicon)", cn: "适用于 macOS (Apple Silicon)" }, suffix: "aarch64.dmg", }, { id: "macos-intel", + iconId: "macos-intel", labels: { en: "For macOS (Intel)", cn: "适用于 macOS (Intel)" }, suffix: "x64.dmg", }, { id: "windows", - labels: { en: "For Windows", cn: "适用于 Windows" }, + iconId: "windows", + labels: { en: "Windows 10/11 (x64)", cn: "Windows 10/11 (x64)" }, + descriptions: { en: "Standard online installer", cn: "标准在线安装包" }, + badges: { en: "Recommended", cn: "推荐" }, suffix: "x64-setup.exe", }, + { + id: "windows-offline", + iconId: "windows", + labels: { en: "Windows 10/11 offline installer", cn: "Windows 10/11 离线安装包" }, + descriptions: { en: "Includes WebView2 · For offline networks", cn: "内置 WebView2 · 适用于无网络环境" }, + badges: { en: "Offline", cn: "离线" }, + suffix: "x64-webview2-offline-setup.exe", + }, + { + id: "windows-7-offline", + iconId: "windows", + labels: { en: "Windows 7 offline installer", cn: "Windows 7 离线安装包" }, + descriptions: { en: "Includes WebView2 109 · x64 only", cn: "内置 WebView2 109 · 仅支持 x64" }, + badges: { en: "Legacy", cn: "旧系统" }, + suffix: "x64-win7-webview2-109-offline-setup.exe", + }, { id: "linux", + iconId: "linux", labels: { en: "For Linux x64", cn: "适用于 Linux x64" }, suffix: "amd64.AppImage", }, { id: "linux-arm", + iconId: "linux-arm", labels: { en: "For Linux ARM64", cn: "适用于 Linux ARM64" }, suffix: "aarch64.AppImage", }, @@ -45,7 +74,10 @@ const downloadArtifacts: DownloadArtifact[] = [ export function createInstallOptions(lang: InstallLang, version: string): InstallOption[] { return downloadArtifacts.map((artifact) => ({ id: artifact.id, + iconId: artifact.iconId, label: artifact.labels[lang], + description: artifact.descriptions?.[lang], + badge: artifact.badges?.[lang], href: `${DOWNLOAD_BASE_URL}/DBX_${version}_${artifact.suffix}?v=${version}`, })); }