From c98c6fc0250d2955c88e29ae3a3dc9f97d40e74c Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sat, 31 Oct 2026 14:31:33 +0800 Subject: [PATCH] Update deploy.mjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 发布后校验 /learn/ 的入口、数据和离线缓存脚本。 --- website/deploy/deploy.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/website/deploy/deploy.mjs b/website/deploy/deploy.mjs index 6eb6b282..370e4388 100644 --- a/website/deploy/deploy.mjs +++ b/website/deploy/deploy.mjs @@ -38,6 +38,13 @@ function verificationPaths(manifest) { for (const path of paths) { if (!records.has(path)) throw new Error(`构建缺少关键文件:${path}`); } + // 学习站(/learn/):入口、数据和离线缓存脚本都要是这次构建的版本 + if (records.has('learn/index.html')) { + for (const path of ['learn/index.html', 'learn/data.json', 'learn/app.js', 'learn/sw.js']) { + if (!records.has(path)) throw new Error(`构建缺少关键文件:${path}`); + paths.push(path); + } + } return [...new Set(paths)]; } @@ -62,6 +69,12 @@ export async function verifyPublished(manifestBytes, { fetcher = fetch, origin = if (sha256(remote) !== revision) throw new Error('正式域名的版本清单尚未与构建一致。'); const records = new Map(manifest.files.map(file => [file.path, file])); // Check actual bytes as well as the manifest; an SPA fallback can also return HTTP 200. + // 目录地址 /learn/ 要返回学习站的入口页,而不是网站首页或 404 + if (records.has('learn/index.html')) { + const entry = records.get('learn/index.html'); + const bytes = await download(origin, 'learn/', revision, fetcher); + if (sha256(bytes) !== entry.sha256) throw new Error('正式域名的 /learn/ 没有返回学习站入口页'); + } await Promise.all(paths.map(async path => { const record = records.get(path); const bytes = await download(origin, path, revision, fetcher);