Skip to content

Commit

Permalink
修复直营服无法导入装备方案的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanxven committed Sep 27, 2024
1 parent 393ea76 commit 7ae8cd8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

- 部分直营服无法查看对局中状态。

- 直营服无法导入装备方案。

# v1.2.6-fix.1 (2024-09-24)

对 v1.2.5 的修复版本。
Expand Down
7 changes: 7 additions & 0 deletions src/main/http-api/gameflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ export function dodge() {
}
})
}

export function reconnect() {
return lcm.lcuRequest({
url: '/lol-gameflow/v1/reconnect',
method: 'POST'
})
}
22 changes: 14 additions & 8 deletions src/main/modules/external-data-source/opgg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,35 @@ export class OpggEds {
method: 'GET'
})

const path = join(installDir, '..', 'Game', 'Config', 'Global', 'Recommended')
// 直营服和腾讯服的路径不同
let targetPath: string
if (existsSync(join(installDir, 'Config'))) {
targetPath = join(installDir, 'Config', 'Global', 'Recommended')
} else {
targetPath = join(installDir, '..', 'Game', 'Config', 'Global', 'Recommended')
}

if (existsSync(path)) {
if (!statSync(path).isDirectory()) {
throw new Error(`The path ${path} is not a directory`)
if (existsSync(targetPath)) {
if (!statSync(targetPath).isDirectory()) {
throw new Error(`The path ${targetPath} is not a directory`)
}
} else {
mkdirSync(path, { recursive: true })
mkdirSync(targetPath, { recursive: true })
}

// 清空之前的文件, 这些文件以 `akari1` 开头
if (clearPrevious) {
const files = readdirSync(path)
const files = readdirSync(targetPath)
const akariFiles = files.filter((file) => file.startsWith(OpggEds.FIXED_ITEM_SET_PREFIX))

for (const file of akariFiles) {
unlinkSync(join(path, file))
unlinkSync(join(targetPath, file))
}
}

for (const itemSet of itemSets) {
const fileName = `${itemSet.uid}.json`
const filePath = join(path, fileName)
const filePath = join(targetPath, fileName)

this._edsm.logger.info(`写入物品集到文件 ${filePath}`)

Expand Down
5 changes: 5 additions & 0 deletions src/main/modules/lcu-state-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,11 @@ export class LcuSyncModule extends MobxBasedBasicModule {
const data = (await getLolLeagueSessionToken()).data
this.lolLeagueSession.setToken(data)
} catch (error) {
if (isAxiosError(error) && error.response?.status === 404) {
this.lolLeagueSession.setToken(null)
return
}

this._logger.warn(`获取 LOL League Session 失败 ${formatError(error)}`)
}
} else {
Expand Down
11 changes: 10 additions & 1 deletion src/shared/utils/ranked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ export interface ParsedRole {
// assignmentReason: PRIMARY, SECONDARY, FILL_SECONDARY, FILL_PRIMARY, AUTOFILL
// NONE, UNSELECTED
// TOP, MIDDLE, JUNGLE, BOTTOM, UTILITY
export function parseSelectedRole(role: string): ParsedRole {
export function parseSelectedRole(role: string | null): ParsedRole {
if (!role) {
return {
current: 'NONE',
assignmentReason: 'NONE',
primary: 'NONE',
secondary: 'NONE'
}
}

const segments = role.split('.')
if (segments.length !== 4) {
return {
Expand Down

0 comments on commit 7ae8cd8

Please sign in to comment.