diff --git a/sites/README.md b/sites/README.md index e159183e..9360d049 100644 --- a/sites/README.md +++ b/sites/README.md @@ -71,6 +71,10 @@ Windows、macOS 和 Linux 下载卡片分别提供处理器架构与安装包类 整组按钮会以 fail-closed 方式继续指向 GitHub 最新正式 Release,不会混用 部分 OSS 数据: +中文页面等待 OSS 索引时,三个正式下载入口保持禁用并显示加载状态,不会先 +短暂渲染或跳转到 GitHub。只有索引请求或完整校验明确失败后,正式下载入口 +才会显示 GitHub Release 回退;英文页面仍始终直接使用 GitHub Release。 + ```text https://github.com/mesalogo/goodbuddy/releases/latest ``` diff --git a/sites/app.js b/sites/app.js index 4cc44a08..ed8b18c3 100644 --- a/sites/app.js +++ b/sites/app.js @@ -28,6 +28,8 @@ ]; let verifiedRelease; let verifiedLoongArchPreview; + let releaseLoadState = "loading"; + let loongArchPreviewLoadState = "loading"; const interfaceCopy = isEnglish ? { themeDark: "Switch to dark theme", @@ -162,6 +164,17 @@ meta.textContent = "实验预览 · 仅 DEB · 索引尚未发布或校验失败。"; }; + const setDownloadPending = (link, meta, visibleText) => { + link.removeAttribute("href"); + link.removeAttribute("target"); + link.removeAttribute("rel"); + link.setAttribute("aria-disabled", "true"); + link.tabIndex = -1; + link.classList.add("is-disabled"); + setLinkText(link, visibleText); + meta.textContent = "正在从 OSS 获取最新版本。"; + }; + const setLoongArchFormat = (formatSelect, selected) => { for (const option of formatSelect.options) { const unavailable = selected && option.value !== "deb"; @@ -188,7 +201,11 @@ if (loongArchSelected) { if (!verifiedLoongArchPreview) { - setDownloadUnavailable(link, meta); + if (loongArchPreviewLoadState === "loading") { + setDownloadPending(link, meta, "正在获取龙芯预览版下载信息…"); + } else { + setDownloadUnavailable(link, meta); + } return; } setReleaseLink( @@ -205,12 +222,20 @@ } if (!verifiedRelease) { - setReleaseLink( - link, - releaseFallbackUrl, - `前往 GitHub 下载 ${platformNames[platform] ?? platform} →`, - ); - meta.textContent = "请在 GitHub Release 中选择对应的安装文件。"; + if (releaseLoadState === "loading") { + setDownloadPending( + link, + meta, + `正在获取 ${platformNames[platform] ?? platform} 下载信息…`, + ); + } else { + setReleaseLink( + link, + releaseFallbackUrl, + `前往 GitHub 下载 ${platformNames[platform] ?? platform} →`, + ); + meta.textContent = "请在 GitHub Release 中选择对应的安装文件。"; + } return; } @@ -247,11 +272,13 @@ const setFallbackDownloads = () => { verifiedRelease = undefined; + releaseLoadState = "fallback"; updateAllDownloadCards(); }; const setLoongArchPreviewUnavailable = () => { verifiedLoongArchPreview = undefined; + loongArchPreviewLoadState = "unavailable"; const linuxCard = downloadCards.find( (card) => card.dataset.downloadCard === "linux", ); @@ -266,6 +293,7 @@ } verifiedLoongArchPreview = releaseIndexApi.validateLoongArchPreviewIndex(payload); + loongArchPreviewLoadState = "ready"; const linuxCard = downloadCards.find( (card) => card.dataset.downloadCard === "linux", ); @@ -279,6 +307,7 @@ throw new Error("发布索引校验器不可用"); } verifiedRelease = releaseIndexApi.validateReleaseIndex(payload); + releaseLoadState = "ready"; updateAllDownloadCards(); }; diff --git a/sites/index.html b/sites/index.html index e0969929..263d4488 100644 --- a/sites/index.html +++ b/sites/index.html @@ -271,14 +271,13 @@ 下载 Windows 版 →(在新窗口打开) + aria-disabled="true" + tabindex="-1" + >正在获取 Windows 下载信息…(在新窗口打开)

- 正在获取最新版本,暂时可前往 GitHub 下载。 + 正在从 OSS 获取最新版本。

@@ -305,14 +304,13 @@ 下载 macOS 版 →(在新窗口打开) + aria-disabled="true" + tabindex="-1" + >正在获取 macOS 下载信息…(在新窗口打开)

- 正在获取最新版本,暂时可前往 GitHub 下载。 + 正在从 OSS 获取最新版本。

@@ -339,14 +337,13 @@ 下载 Linux 版 →(在新窗口打开) + aria-disabled="true" + tabindex="-1" + >正在获取 Linux 下载信息…(在新窗口打开)

- 正在获取最新版本,暂时可前往 GitHub 下载。 + 正在从 OSS 获取最新版本。

diff --git a/sites/scripts/app.test.mjs b/sites/scripts/app.test.mjs index dbd169b7..d4071019 100644 --- a/sites/scripts/app.test.mjs +++ b/sites/scripts/app.test.mjs @@ -282,6 +282,36 @@ test("enables only a validated LoongArch preview download", async () => { dom.window.close(); }); +test("keeps Chinese downloads disabled while the OSS indexes are loading", async () => { + const { dom, window } = renderLoongArchPreview({ + goodBuddyVersion: "0.11.5", + artifact: { + size: 186_853_872, + sha256: "a".repeat(64), + url: "https://goodbuddy.oss-cn-beijing.aliyuncs.com/releases/loongarch-preview/v0.11.5/GoodBuddy-0.11.5-linux-loong64-preview.deb", + }, + }); + const arch = window.document.querySelector("[data-download-arch]"); + const link = window.document.querySelector("[data-release-link]"); + const meta = window.document.querySelector("[data-download-meta]"); + + assert.equal(link.hasAttribute("href"), false); + assert.equal(link.getAttribute("aria-disabled"), "true"); + assert.equal(link.tabIndex, -1); + assert.equal(link.classList.contains("is-disabled"), true); + assert.equal(link.textContent, "正在获取 Linux 下载信息…(在新窗口打开)"); + assert.equal(meta.textContent, "正在从 OSS 获取最新版本。"); + + arch.value = "loong64"; + arch.dispatchEvent(new window.Event("change")); + assert.equal(link.hasAttribute("href"), false); + assert.equal(link.getAttribute("aria-disabled"), "true"); + assert.equal(link.textContent, "正在获取龙芯预览版下载信息…(在新窗口打开)"); + assert.equal(meta.textContent, "正在从 OSS 获取最新版本。"); + await new Promise((resolve) => window.setTimeout(resolve, 0)); + dom.window.close(); +}); + test("keeps the LoongArch preview disabled when its index is unavailable", async () => { const { dom, window } = renderLoongArchPreview(null); await new Promise((resolve) => window.setTimeout(resolve, 0)); diff --git a/sites/scripts/validate.mjs b/sites/scripts/validate.mjs index 1e294ff6..993e7015 100644 --- a/sites/scripts/validate.mjs +++ b/sites/scripts/validate.mjs @@ -311,11 +311,12 @@ const releaseLinks = [ report(releaseLinks.length >= 3, "缺少三个桌面系统的官方下载入口"); for (const link of releaseLinks) { report( - /href="https:\/\/github\.com\/mesalogo\/goodbuddy\/releases\/latest"/.test(link), - `下载入口必须指向官方最新 Release:${link}`, + !/\shref=/.test(link), + `中文下载入口加载期间不得预先指向 GitHub:${link}`, ); - report(/target="_blank"/.test(link), `下载入口必须在新窗口打开:${link}`); - report(/rel="[^"]*noreferrer[^"]*"/.test(link), `下载入口缺少 noreferrer:${link}`); + report(/aria-disabled="true"/.test(link), `中文下载入口加载期间必须禁用:${link}`); + report(/tabindex="-1"/.test(link), `禁用的中文下载入口不得进入 Tab 顺序:${link}`); + report(/\bis-disabled\b/.test(link), `中文下载入口缺少禁用样式:${link}`); } report( (html.match(/data-download-card="(?:windows|macos|linux)"/g) ?? []).length === 3,