Skip to content

Commit

Permalink
Merge pull request #210 from Retrospection/dev
Browse files Browse the repository at this point in the history
fix: 修复MaaX安装core模块失败问题
  • Loading branch information
ChingCdesu authored Feb 6, 2024
2 parents 0acdcd6 + f3bbfe5 commit 6a94871
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/main/componentManager/installers/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ export default class CoreInstaller extends InstallerBase {
name: 'GitHub',
urlReplacer: oldUrl => {
const urlMatches =
/^https:\/\/(.+)\/MaaAssistantArknights\/MaaAssistantArknights\/releases\/download\/(.+)\/(.+)$/.exec(
/^https:\/\/(.+)\/MaaAssistantArknights\/MaaRelease\/releases\/download\/(.+)\/(.+)$/.exec(
oldUrl
)
if (!urlMatches) {
throw new Error(`Invalid update url: ${oldUrl}`)
}
const [, host, version, filename] = urlMatches
return `https://github.com/MaaAssistantArknights/MaaAssistantArknights/releases/download/${version}/${filename}`
return `https://github.com/MaaAssistantArknights/MaaRelease/releases/download/${version}/${filename}`
},
},
{
name: '国内镜像',
urlReplacer: oldUrl => {
const urlMatches =
/^https:\/\/(.+)\/MaaAssistantArknights\/MaaAssistantArknights\/releases\/download\/(.+)\/(.+)$/.exec(
/^https:\/\/(.+)\/MaaAssistantArknights\/MaaRelease\/releases\/download\/(.+)\/(.+)$/.exec(
oldUrl
)
if (!urlMatches) {
throw new Error(`Invalid update url: ${oldUrl}`)
}
const [, host, version, filename] = urlMatches
return `https://s3.maa-org.net:25240/maa-release/MaaAssistantArknights/MaaAssistantArknights/releases/download/${version}/${filename}`
return `https://s3.maa-org.net:25240/maa-release/MaaAssistantArknights/MaaRelease/releases/download/${version}/${filename}`
},
},
// TODO: Maa R2 Bucket Replacer
Expand Down
12 changes: 9 additions & 3 deletions packages/main/componentManager/utils/release.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logger from '@main/utils/logger'
import type { ComponentType } from '@type/componentManager'
import axios from 'axios'
import axios, { type AxiosResponse } from 'axios'

import type { ReleaseObject } from '../types'
import { getProxy } from './proxy'
Expand Down Expand Up @@ -42,10 +42,16 @@ export function createGetRelease(urls: string[], component: ComponentType) {
}

for (const url of urls) {
const result = await tryRequest(url, component)
const result = await tryRequest(url, component) as AxiosResponse<ReleaseObject[] | null>
// 由于资源链接变更,需要 merge 资源链接里所有的 assets 数组来查找到可用的最新下载源
const assets = result?.data?.reduce((prev, curr) => prev.concat(curr?.assets ?? []), [] as ReleaseObject['assets'])
if (result) {
cache = {
data: result.data[0],
data: {
assets: assets!,
tag_name: result?.data?.[0].tag_name!,
published_at: result?.data?.[0].published_at!,
},
updated: Date.now(),
}
}
Expand Down

0 comments on commit 6a94871

Please sign in to comment.