From 6a0b03cfe1b8b3eeddb28501e5516b7519df4360 Mon Sep 17 00:00:00 2001 From: alger Date: Wed, 12 Feb 2025 10:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E4=BC=98=E5=8C=96=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=A4=9A=E4=B8=AA=E4=BB=A3=E7=90=86=E6=BA=90=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/utils/update.ts | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/renderer/utils/update.ts b/src/renderer/utils/update.ts index 8b158cb..ab41b66 100644 --- a/src/renderer/utils/update.ts +++ b/src/renderer/utils/update.ts @@ -38,16 +38,28 @@ export const getLatestReleaseInfo = async (): Promise const token = import.meta.env.VITE_GITHUB_TOKEN; const headers = {}; + // GitHub API 代理地址列表 + const proxyHosts = [ + 'https://gh.lk.cc', + 'https://ghproxy.cn', + 'https://ghproxy.net', + 'https://gitproxy.click', + 'https://github.tbedu.top', + 'https://github.moeyy.xyz' + ]; + + // 构建 API URL 列表 const apiUrls = [ // 原始地址 'https://api.github.com/repos/algerkong/AlgerMusicPlayer/releases/latest', - // 使用 ghproxy.com 代理 - 'https://www.ghproxy.cn/https://raw.githubusercontent.com/algerkong/AlgerMusicPlayer/dev_electron/package.json' - - // 使用 gitee 镜像(如果有的话) - // 'https://gitee.com/api/v5/repos/[用户名]/AlgerMusicPlayer/releases/latest' + // 使用各种代理 + ...proxyHosts.map( + (host) => + `${host}/https://raw.githubusercontent.com/algerkong/AlgerMusicPlayer/dev_electron/package.json` + ) ]; + if (token) { headers['Authorization'] = `token ${token}`; } @@ -57,14 +69,13 @@ export const getLatestReleaseInfo = async (): Promise const response = await axios.get(url, { headers }); if (url.includes('package.json')) { - // 如果是 package.json,直接读取版本号 + // 如果是 package.json,获取对应的 CHANGELOG + const changelogUrl = url.replace('package.json', 'CHANGELOG.md'); + const changelogResponse = await axios.get(changelogUrl); + return { tag_name: response.data.version, - body: ( - await axios.get( - 'https://www.ghproxy.cn/https://raw.githubusercontent.com/algerkong/AlgerMusicPlayer/dev_electron/CHANGELOG.md' - ) - ).data, + body: changelogResponse.data, html_url: 'https://github.com/algerkong/AlgerMusicPlayer/releases/latest', assets: [] } as unknown as GithubReleaseInfo;