🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"
TypeScript
feat(release): 国内分发迁移腾讯 COS + 更新器双源容灾
Connord5426f6e7632
diff --git a/README.ja.md b/README.ja.mdindex 7152a09..c4f42f5 100644--- a/README.ja.md+++ b/README.ja.md@@ -283,13 +283,15 @@ cd backend && npx tsx scripts/import-mysql-to-sqlite.ts### 🖥️ デスクトップアプリ(推奨)-**⬇️ ビルド済みインストーラー: [GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest)**+**⬇️ ビルド済みインストーラー: [GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest) · [中国向けミラー(Tencent COS)](https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama/v4.0.0/)**| プラットフォーム | ダウンロードファイル ||---|---|-| macOS(Apple Silicon、M シリーズ) | `HuobaoDrama-<バージョン>-arm64.dmg` |-| macOS(Intel) | `HuobaoDrama-<バージョン>.dmg` |-| Windows | `HuobaoDrama Setup <バージョン>.exe` |+| macOS(Apple Silicon、M シリーズ) | `HuobaoDrama-4.0.0-arm64.dmg` |+| macOS(Intel) | `HuobaoDrama-4.0.0.dmg` |+| Windows | `HuobaoDrama.Setup.4.0.0.exe` |++> 中国本土では GitHub が不安定なため、Tencent COS ミラーをご利用ください。アプリ内アップデーターも COS を優先し、GitHub にフォールバックします。ビルド不要 —— dmg/exe をダウンロードしてそのままインストールできます。インストール済みクライアントは内蔵アップデーターで自動更新されます。(ソースから自分でパッケージングする場合は以下のコマンドを参照。)diff --git a/README.ko.md b/README.ko.mdindex 84dc78d..8f8b080 100644--- a/README.ko.md+++ b/README.ko.md@@ -283,13 +283,15 @@ cd backend && npx tsx scripts/import-mysql-to-sqlite.ts### 🖥️ 데스크톱 앱(권장)-**⬇️ 빌드된 설치 파일: [GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest)**+**⬇️ 빌드된 설치 파일: [GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest) · [중국용 미러(Tencent COS)](https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama/v4.0.0/)**| 플랫폼 | 다운로드 파일 ||---|---|-| macOS(Apple Silicon, M 시리즈) | `HuobaoDrama-<버전>-arm64.dmg` |-| macOS(Intel) | `HuobaoDrama-<버전>.dmg` |-| Windows | `HuobaoDrama Setup <버전>.exe` |+| macOS(Apple Silicon, M 시리즈) | `HuobaoDrama-4.0.0-arm64.dmg` |+| macOS(Intel) | `HuobaoDrama-4.0.0.dmg` |+| Windows | `HuobaoDrama.Setup.4.0.0.exe` |++> 중국 본토에서는 GitHub이 불안정하므로 Tencent COS 미러를 이용하세요. 앱 내 업데이터도 COS를 우선하고 GitHub으로 폴백합니다.빌드 불필요 — dmg/exe를 다운로드해 바로 설치하면 됩니다. 설치된 클라이언트는 내장 업데이터로 자동 업데이트됩니다. (소스에서 직접 패키징하려면 아래 명령을 참조하세요.)diff --git a/README.md b/README.mdindex ef7ec35..6185a26 100644--- a/README.md+++ b/README.md@@ -283,13 +283,15 @@ The episode list shows the production status of every episode — click "Enter S### 🖥️ Desktop App (recommended)-**⬇️ Prebuilt installers: [GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest)**+**⬇️ Prebuilt installers: [GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest) · [Mirror for China (Tencent COS)](https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama/v4.0.0/)**| Platform | File to download ||---|---|-| macOS (Apple Silicon, M-series) | `HuobaoDrama-<version>-arm64.dmg` |-| macOS (Intel) | `HuobaoDrama-<version>.dmg` |-| Windows | `HuobaoDrama Setup <version>.exe` |+| macOS (Apple Silicon, M-series) | `HuobaoDrama-4.0.0-arm64.dmg` |+| macOS (Intel) | `HuobaoDrama-4.0.0.dmg` |+| Windows | `HuobaoDrama.Setup.4.0.0.exe` |++> China users: use the COS mirror above (GitHub is slow/unreachable in mainland China). The in-app updater also checks the COS mirror first, then falls back to GitHub.No build required — download the dmg/exe and install. Installed clients auto-update via the built-in updater. (To package from source instead, see the commands below.)diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 0d5904e..1f8349a 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -284,13 +284,15 @@ cd backend && npx tsx scripts/import-mysql-to-sqlite.ts### 🖥️ 桌面应用(推荐)-**⬇️ 预编译安装包下载:[GitHub Releases](https://github.com/chatfire-AI/huobao-drama/releases/latest)**+**⬇️ 预编译安装包下载:[国内镜像(腾讯云,推荐)](https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama/v4.0.0/) · [GitHub Releases(海外)](https://github.com/chatfire-AI/huobao-drama/releases/latest)**| 平台 | 下载文件 ||---|---|-| macOS(Apple Silicon,M 系列) | `HuobaoDrama-<版本号>-arm64.dmg` |-| macOS(Intel) | `HuobaoDrama-<版本号>.dmg` |-| Windows | `HuobaoDrama Setup <版本号>.exe` |+| macOS(Apple Silicon,M 系列) | `HuobaoDrama-4.0.0-arm64.dmg` |+| macOS(Intel) | `HuobaoDrama-4.0.0.dmg` |+| Windows | `HuobaoDrama.Setup.4.0.0.exe` |++> 国内用户请用腾讯云镜像直链下载(GitHub 在国内访问不稳定)。应用内更新器同样国内源优先、GitHub 兜底。无需构建 —— 下载 dmg/exe 直接安装即可,已安装客户端会通过内置更新器自动升级。(如需从源码自行打包,见下方命令。)diff --git a/backend/src/services/server-update.ts b/backend/src/services/server-update.tsindex acf94cd..094b50f 100644--- a/backend/src/services/server-update.ts+++ b/backend/src/services/server-update.ts@@ -11,8 +11,13 @@ import { readFileSync } from 'fs'import path from 'path'import { fileURLToPath } from 'url'-const FEED_URL = process.env.HUOBAO_UPDATE_FEED- || 'https://github.com/chatfire-AI/huobao-drama/releases/latest/download/latest.json'+// 双源:COS(国内直连)优先,GitHub(海外)兜底;HUOBAO_UPDATE_FEED 可整体覆盖+const FEED_URLS = process.env.HUOBAO_UPDATE_FEED+ ? [process.env.HUOBAO_UPDATE_FEED]+ : [+ 'https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama/latest.json',+ 'https://github.com/chatfire-AI/huobao-drama/releases/latest/download/latest.json',+ ]const WATCHTOWER_URL = process.env.HUOBAO_WATCHTOWER_URL?.replace(/\/+$/, '')const WATCHTOWER_TOKEN = process.env.HUOBAO_WATCHTOWER_TOKEN || ''@@ -66,13 +71,23 @@ export function getServerUpdateState(): ServerUpdateState {}}-/** POST /check — 拉取发布清单比较版本 */+/** POST /check — 拉取发布清单比较版本(双源依次尝试) */export async function checkServerUpdate(): Promise<ServerUpdateState> {try {- const res = await fetch(FEED_URL, { signal: AbortSignal.timeout(15_000) })- if (!res.ok) throw new Error(`版本清单请求失败(HTTP ${res.status})`)- const feed = await res.json()- if (!feed?.version) throw new Error('版本清单格式不正确')+ let feed: any+ let lastError: unknown+ for (const url of FEED_URLS) {+ try {+ const res = await fetch(url, { signal: AbortSignal.timeout(15_000) })+ if (!res.ok) throw new Error(`HTTP ${res.status}`)+ feed = await res.json()+ if (!feed?.version) throw new Error('版本清单格式不正确')+ break+ } catch (err) {+ lastError = err+ }+ }+ if (!feed) throw new Error(`版本清单请求失败(已尝试 ${FEED_URLS.length} 个源):${(lastError as Error)?.message ?? ''}`)const latestVersion = String(feed.version).replace(/^v/, '')lastState = {status: compareVersions(latestVersion, currentVersion()) > 0 ? 'available' : 'up-to-date',diff --git a/desktop/package.json b/desktop/package.jsonindex 0e37af9..1ee7d08 100644--- a/desktop/package.json+++ b/desktop/package.json@@ -14,7 +14,8 @@"dev": "npm run build:backend && npm run build:main && electron .","dist": "npm run build:backend && npm run build:main && node scripts/prepare-resources.mjs && electron-builder --mac","dist:win": "npm run build:backend && npm run build:main && node scripts/prepare-resources.mjs && electron-builder --win",- "feed": "node scripts/make-update-feed.mjs"+ "feed": "node scripts/make-update-feed.mjs",+ "publish": "node scripts/publish-release.mjs"},"dependencies": {"better-sqlite3": "^12.4.1",diff --git a/desktop/scripts/cos-upload.mjs b/desktop/scripts/cos-upload.mjsnew file mode 100644index 0000000..75b7abb--- /dev/null+++ b/desktop/scripts/cos-upload.mjs@@ -0,0 +1,132 @@+/**+ * 腾讯 COS(轻量对象存储)XML API 极简上传客户端 — 零外部依赖+ *+ * 用法:+ * node scripts/cos-upload.mjs --check 连通性检查(HeadBucket)+ * node scripts/cos-upload.mjs <本地文件> <桶内Key> [--cache-control "no-cache"]+ *+ * 密钥来源(按优先级): 命令行环境变量 > desktop/.env.local+ * TENCENT_SECRET_ID / TENCENT_SECRET_KEY+ * 桶与地域(可用环境变量覆盖):+ * COS_BUCKET(默认 drama-1304922933)/ COS_REGION(默认 ap-shanghai)+ *+ * 签名: q-sign-algorithm=sha1(腾讯云 COS XML API 鉴权规范),+ * 只签 host 头,其余头(Cache-Control 等)透传不参与签名。+ */+import fs from 'fs'+import path from 'path'+import crypto from 'crypto'+import { fileURLToPath } from 'url'++const __dirname = path.dirname(fileURLToPath(import.meta.url))+const DESKTOP = path.resolve(__dirname, '..')++// 读取 desktop/.env.local(KEY=VALUE 行),不覆盖已有环境变量+function loadEnvLocal() {+ const envFile = path.join(DESKTOP, '.env.local')+ if (!fs.existsSync(envFile)) return+ for (const line of fs.readFileSync(envFile, 'utf8').split('\n')) {+ const m = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.+?)\s*$/)+ if (m && !process.env[m[1]]) process.env[m[1]] = m[2]+ }+}+loadEnvLocal()++const SECRET_ID = process.env.TENCENT_SECRET_ID+const SECRET_KEY = process.env.TENCENT_SECRET_KEY+const BUCKET = process.env.COS_BUCKET || 'drama-1304922933'+const REGION = process.env.COS_REGION || 'ap-shanghai'+const HOST = `${BUCKET}.cos.${REGION}.myqcloud.com`++function sha1Hex(input) {+ return crypto.createHash('sha1').update(input).digest('hex')+}+function hmacSha1Hex(key, input) {+ return crypto.createHmac('sha1', key).update(input).digest('hex')+}++/** COS q-signature(仅签 host 头、无 url 参数) */+function authorization(method, uriPathname) {+ const now = Math.floor(Date.now() / 1000)+ const keyTime = `${now - 60};${now + 3600}`+ const signKey = hmacSha1Hex(SECRET_KEY, keyTime)+ const httpString = `${method.toLowerCase()}\n${uriPathname}\n\nhost=${encodeURIComponent(HOST)}\n`+ const stringToSign = `sha1\n${keyTime}\n${sha1Hex(httpString)}\n`+ const signature = hmacSha1Hex(signKey, stringToSign)+ return `q-sign-algorithm=sha1&q-ak=${SECRET_ID}&q-sign-time=${keyTime}&q-key-time=${keyTime}`+ + `&q-header-list=host&q-url-param-list=&q-signature=${signature}`+}++export async function cosPut(localFile, key, { cacheControl } = {}) {+ const body = fs.readFileSync(localFile)+ const uriPathname = `/${key.split('/').map(encodeURIComponent).join('/')}`+ const headers = {+ 'Host': HOST,+ 'Authorization': authorization('PUT', uriPathname),+ 'Content-Length': String(body.length),+ 'Content-MD5': crypto.createHash('md5').update(body).digest('base64'),+ }+ if (cacheControl) headers['Cache-Control'] = cacheControl++ const res = await fetch(`https://${HOST}${uriPathname}`, {+ method: 'PUT',+ headers,+ body,+ signal: AbortSignal.timeout(600_000),+ })+ if (!res.ok) {+ const text = await res.text()+ throw new Error(`COS PUT ${key} 失败 HTTP ${res.status}: ${text.slice(0, 300)}`)+ }+ return `https://${HOST}${uriPathname}`+}++export async function cosHeadBucket() {+ const res = await fetch(`https://${HOST}/`, {+ method: 'HEAD',+ headers: { 'Host': HOST, 'Authorization': authorization('HEAD', '/') },+ signal: AbortSignal.timeout(15_000),+ })+ return res.status+}++export async function cosDelete(key) {+ const uriPathname = `/${key.split('/').map(encodeURIComponent).join('/')}`+ const res = await fetch(`https://${HOST}${uriPathname}`, {+ method: 'DELETE',+ headers: { 'Host': HOST, 'Authorization': authorization('DELETE', uriPathname) },+ signal: AbortSignal.timeout(15_000),+ })+ if (!res.ok && res.status !== 404) throw new Error(`COS DELETE ${key} 失败 HTTP ${res.status}`)+}++// ---- CLI ----+const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)+if (isMain) {+ if (!SECRET_ID || !SECRET_KEY) {+ console.error('缺少 TENCENT_SECRET_ID / TENCENT_SECRET_KEY(写入 desktop/.env.local 或环境变量)')+ process.exit(1)+ }+ const args = process.argv.slice(2)+ if (args[0] === '--check') {+ const status = await cosHeadBucket()+ console.log(status === 200 ? `连通正常 ✓ (${HOST})` : `HeadBucket 返回 ${status}(401=密钥错,403=无权限,404=桶名错)`)+ process.exit(status === 200 ? 0 : 1)+ }+ if (args[0] === '--rm') {+ await cosDelete(args[1])+ console.log(`✓ 已删除 ${args[1]}`)+ process.exit(0)+ }+ const [localFile, key] = args+ const ccIdx = args.indexOf('--cache-control')+ const cacheControl = ccIdx >= 0 ? args[ccIdx + 1] : undefined+ if (!localFile || !key || !fs.existsSync(localFile)) {+ console.error('用法: node scripts/cos-upload.mjs <本地文件> <桶内Key> [--cache-control "..."]')+ process.exit(1)+ }+ const start = Date.now()+ const url = await cosPut(localFile, key, { cacheControl })+ const mb = (fs.statSync(localFile).size / 1048576).toFixed(1)+ console.log(`✓ ${path.basename(localFile)} (${mb}MB, ${((Date.now() - start) / 1000).toFixed(0)}s)\n ${url}`)+}diff --git a/desktop/scripts/publish-release.mjs b/desktop/scripts/publish-release.mjsnew file mode 100644index 0000000..3c7ec3a--- /dev/null+++ b/desktop/scripts/publish-release.mjs@@ -0,0 +1,115 @@+/**+ * 一键发布 — GitHub Releases(海外) + 腾讯 COS(国内) 双通道+ *+ * 用法(在 desktop/ 下执行):+ * npm run publish [-- --notes "更新说明"] [-- --skip-gh]+ *+ * 前置:+ * - desktop/release/ 已有本版本产物(npm run dist / dist:win 之后)+ * - gh 已登录(上传 GitHub);desktop/.env.local 已配 TENCENT_SECRET_ID/KEY(上传 COS)+ *+ * 产物布局:+ * GitHub: vX.Y.Z Release(空格文件名自动规范化为点号,见 make-update-feed)+ * COS: huobao-drama/vX.Y.Z/<点号文件名> + huobao-drama/latest.json(指向 COS 直链)+ *+ * 国内下载基址(COS_BASE_URL)与更新器兜底源保持一致,将来绑自定义域名/加 CDN 只改这一处。+ */+import fs from 'fs'+import path from 'path'+import crypto from 'crypto'+import { execFileSync } from 'child_process'+import { fileURLToPath } from 'url'+import { cosPut } from './cos-upload.mjs'++const __dirname = path.dirname(fileURLToPath(import.meta.url))+const DESKTOP = path.resolve(__dirname, '..')+const RELEASE = path.join(DESKTOP, 'release')++/** 国内下载基址:默认桶默认域名,可被 COS_BASE_URL 覆盖(如 https://dl.chatfire.site/huobao-drama) */+const COS_BASE_URL = process.env.COS_BASE_URL || 'https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama'+const COS_KEY_PREFIX = 'huobao-drama'++const pkg = JSON.parse(fs.readFileSync(path.join(DESKTOP, 'package.json'), 'utf8'))+const version = pkg.version+const tag = `v${version}`++const argv = process.argv.slice(2)+function argOf(flag) { const i = argv.indexOf(flag); return i >= 0 ? argv[i + 1] : undefined }+const notes = argOf('--notes') || ''+const skipGh = argv.includes('--skip-gh')++// 与 make-update-feed 相同的产物清单(GitHub 服务端会把空格转点号,统一用点号名)+const assets = [+ `HuobaoDrama-${version}-arm64.dmg`,+ `HuobaoDrama-${version}.dmg`,+ `HuobaoDrama-${version}-arm64-mac.zip`,+ `HuobaoDrama-${version}-mac.zip`,+ `HuobaoDrama.Setup.${version}.exe`,+]+const existing = assets.filter(f => fs.existsSync(path.join(RELEASE, f)))+if (!existing.length) {+ console.error(`release/ 下没有版本 ${version} 的产物,请先 npm run dist / dist:win`)+ process.exit(1)+}++// ---- 1. GitHub(海外通道) ----+if (!skipGh) {+ console.log(`[1/3] GitHub Release ${tag} …`)+ const ghArgs = ['release', 'upload', tag, ...existing.map(f => path.join(RELEASE, f)), '--clobber']+ execFileSync('gh', ghArgs, { stdio: 'inherit' })+ console.log(` ✓ 已上传 ${existing.length} 个资产(Release 不存在时会自动创建草稿,需 gh release edit 发布)`)+}++// ---- 2. latest.json(双通道各一份:GitHub 版指向 GitHub,COS 版指向 COS) ----+console.log('[2/3] 生成更新清单 latest.json …')+async function sha256(file) {+ return new Promise((resolve, reject) => {+ const hash = crypto.createHash('sha256')+ fs.createReadStream(file).on('data', c => hash.update(c)).on('end', () => resolve(hash.digest('hex'))).on('error', reject)+ })+}+const buildFeed = async (baseUrl) => {+ const platforms = {}+ for (const f of existing) {+ const key = f.includes('Setup') ? 'win32-x64'+ : f.includes('-arm64') ? 'darwin-arm64'+ : 'darwin-x64'+ // 同一平台 dmg/zip 都存在时只取 zip(更新器用),dmg 是给手动安装的+ if (key !== 'win32-x64' && !f.endsWith('.zip')) continue+ platforms[key] = {+ url: `${baseUrl}/${encodeURIComponent(f)}`,+ sha256: await sha256(path.join(RELEASE, f)),+ size: fs.statSync(path.join(RELEASE, f)).size,+ }+ }+ return { version, notes, platforms }+}++// GitHub 版(沿用 make-update-feed 的 base-url 约定)+const ghFeed = await buildFeed(`https://github.com/chatfire-AI/huobao-drama/releases/download/${tag}`)+fs.writeFileSync(path.join(RELEASE, 'latest.json'), JSON.stringify(ghFeed, null, 2))+if (!skipGh) execFileSync('gh', ['release', 'upload', tag, path.join(RELEASE, 'latest.json'), '--clobber'], { stdio: 'inherit' })++// COS 版(桶内固定路径 latest.json,更新器国内源入口)+const cosFeed = await buildFeed(`${COS_BASE_URL}/v${version}`)+fs.writeFileSync(path.join(RELEASE, 'latest.cos.json'), JSON.stringify(cosFeed, null, 2))+console.log(` ✓ latest.json(GitHub) / latest.cos.json(COS) 平台: ${Object.keys(cosFeed.platforms).join(', ')}`)++// ---- 3. COS(国内通道) ----+console.log('[3/3] 上传腾讯 COS …')+for (const f of existing) {+ await cosPut(path.join(RELEASE, f), `${COS_KEY_PREFIX}/v${version}/${f}`, {+ cacheControl: 'public, max-age=2592000', // 安装包按版本命名内容不变,缓存 30 天+ })+ console.log(` ✓ v${version}/${f}`)+}+await cosPut(path.join(RELEASE, 'latest.cos.json'), `${COS_KEY_PREFIX}/latest.json`, {+ cacheControl: 'no-cache', // 更新发现入口,必须实时+})+console.log(` ✓ latest.json (no-cache)`)++console.log(`+发布完成:+ 海外 https://github.com/chatfire-AI/huobao-drama/releases/${tag}+ 国内 ${COS_BASE_URL}/latest.json+`)diff --git a/desktop/src/updater.ts b/desktop/src/updater.tsindex 441b24b..75bda33 100644--- a/desktop/src/updater.ts+++ b/desktop/src/updater.ts@@ -1,7 +1,8 @@/*** 应用内更新器(无 Apple 签名方案,同 Tauri updater 思路)*- * - 清单:HUOBAO_UPDATE_FEED(默认 GitHub Releases 的 releases/latest/download/latest.json)+ * - 清单:HUOBAO_UPDATE_FEED;未设置时双源 —— 国内 COS 优先,GitHub Releases 兜底+ * (两个源返回同一份清单结构,仅下载 URL 域名不同,见 desktop/scripts/publish-release.mjs)* - macOS:下载 zip(.app 归档)→ sha256 校验 → 解压 → 旧包改名 .old 备胎 → 新包就位* → `open` 拉起新应用 → 当前实例退出;下次启动清理 .old* - Windows:下载 Setup.exe → sha256 校验 → detached 静默安装(/S)→ 当前实例退出@@ -15,8 +16,13 @@ import * as path from 'path'import crypto from 'crypto'import { spawn, execFile } from 'child_process'-const FEED_URL = process.env.HUOBAO_UPDATE_FEED- || 'https://github.com/chatfire-AI/huobao-drama/releases/latest/download/latest.json'+// 双源:COS(国内直连)优先,GitHub(海外)兜底;HUOBAO_UPDATE_FEED 可整体覆盖+const FEED_URLS = process.env.HUOBAO_UPDATE_FEED+ ? [process.env.HUOBAO_UPDATE_FEED]+ : [+ 'https://drama-1304922933.cos.ap-shanghai.myqcloud.com/huobao-drama/latest.json',+ 'https://github.com/chatfire-AI/huobao-drama/releases/latest/download/latest.json',+ ]export interface UpdateState {status: 'idle' | 'checking' | 'up-to-date' | 'available' | 'downloading' | 'downloaded' | 'error'@@ -73,11 +79,19 @@ function installedAppBundle(): string {}async function fetchFeed(): Promise<{ version: string, notes?: string, platforms: Record<string, { url: string, sha256: string, size?: number }> }> {- const res = await fetch(FEED_URL, { signal: AbortSignal.timeout(15_000) })- if (!res.ok) throw new Error(`版本清单请求失败(HTTP ${res.status})`)- const feed = await res.json()- if (!feed?.version || !feed?.platforms) throw new Error('版本清单格式不正确')- return feed+ let lastError: unknown+ for (const url of FEED_URLS) {+ try {+ const res = await fetch(url, { signal: AbortSignal.timeout(15_000) })+ if (!res.ok) throw new Error(`HTTP ${res.status}`)+ const feed = await res.json()+ if (!feed?.version || !feed?.platforms) throw new Error('版本清单格式不正确')+ return feed+ } catch (err) {+ lastError = err+ }+ }+ throw new Error(`版本清单请求失败(已尝试 ${FEED_URLS.length} 个源):${(lastError as Error)?.message ?? ''}`)}// ---- 检查 ----