From 7ae8cd8e0491d260e47c1ef974d6f959682c343f Mon Sep 17 00:00:00 2001 From: Hanxven Date: Fri, 27 Sep 2024 20:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9B=B4=E8=90=A5=E6=9C=8D?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=AF=BC=E5=85=A5=E8=A3=85=E5=A4=87=E6=96=B9?= =?UTF-8?q?=E6=A1=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ src/main/http-api/gameflow.ts | 7 ++++++ src/main/modules/external-data-source/opgg.ts | 22 ++++++++++++------- src/main/modules/lcu-state-sync/index.ts | 5 +++++ src/shared/utils/ranked.ts | 11 +++++++++- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 621add07..128e8011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ - 部分直营服无法查看对局中状态。 +- 直营服无法导入装备方案。 + # v1.2.6-fix.1 (2024-09-24) 对 v1.2.5 的修复版本。 diff --git a/src/main/http-api/gameflow.ts b/src/main/http-api/gameflow.ts index 70ddc4fa..6d23837a 100644 --- a/src/main/http-api/gameflow.ts +++ b/src/main/http-api/gameflow.ts @@ -34,3 +34,10 @@ export function dodge() { } }) } + +export function reconnect() { + return lcm.lcuRequest({ + url: '/lol-gameflow/v1/reconnect', + method: 'POST' + }) +} diff --git a/src/main/modules/external-data-source/opgg.ts b/src/main/modules/external-data-source/opgg.ts index 886745e3..49564c2e 100644 --- a/src/main/modules/external-data-source/opgg.ts +++ b/src/main/modules/external-data-source/opgg.ts @@ -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}`) diff --git a/src/main/modules/lcu-state-sync/index.ts b/src/main/modules/lcu-state-sync/index.ts index ea4d7756..b49b6c58 100644 --- a/src/main/modules/lcu-state-sync/index.ts +++ b/src/main/modules/lcu-state-sync/index.ts @@ -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 { diff --git a/src/shared/utils/ranked.ts b/src/shared/utils/ranked.ts index 2118ad15..5f45041c 100644 --- a/src/shared/utils/ranked.ts +++ b/src/shared/utils/ranked.ts @@ -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 {