🐛 Mirror source improvement

This commit is contained in:
刘嘉伟 2025-01-08 13:50:51 +08:00
parent a34a1886de
commit 9ad8773b4d

View File

@ -241,9 +241,15 @@ export const initGitHubApi = () => {
const conventMirrorUrl = (mirror: string) => { const conventMirrorUrl = (mirror: string) => {
switch (mirror) { switch (mirror) {
case "github": case "github":
return "https://api.github.com"; return {
api: "https://api.github.com",
asset: "https://github.com"
};
default: default:
return "https://api.github.com"; return {
api: "https://api.github.com",
asset: "https://github.com"
};
} }
}; };
@ -251,7 +257,8 @@ export const initGitHubApi = () => {
* github上的frp所有版本 * github上的frp所有版本
*/ */
ipcMain.on("github.getFrpVersions", async (event, mirror: string) => { ipcMain.on("github.getFrpVersions", async (event, mirror: string) => {
const mirrorUrl = conventMirrorUrl(mirror); const { api } = conventMirrorUrl(mirror);
const mirrorUrl = api;
log.info("Requesting mirror URL: ", mirrorUrl); log.info("Requesting mirror URL: ", mirrorUrl);
const request = net.request({ const request = net.request({
method: "get", method: "get",
@ -307,10 +314,14 @@ export const initGitHubApi = () => {
const asset = getAdaptiveAsset(versionId); const asset = getAdaptiveAsset(versionId);
const { browser_download_url } = asset; const { browser_download_url } = asset;
let url = browser_download_url; let url = browser_download_url.replace(
if (mirror === "ghproxy") { "https://github.com",
url = "https://mirror.ghproxy.com/" + url; conventMirrorUrl(mirror).asset
} );
// if (mirror === "ghproxy") {
// url = "https://mirror.ghproxy.com/" + url;
// }
logDebug( logDebug(
LogModule.GITHUB, LogModule.GITHUB,
@ -328,7 +339,9 @@ export const initGitHubApi = () => {
}); });
logDebug( logDebug(
LogModule.GITHUB, LogModule.GITHUB,
`Download progress for versionId: ${versionId} is ${progress}%` `Download progress for versionId: ${versionId} is ${
progress.percent * 100
}%`
); );
}, },
onCompleted: () => { onCompleted: () => {