Skip to content

Commit 77c2d61

Browse files
committed
version checking fallback
1 parent ba751ed commit 77c2d61

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

app/src/ts/main/ipc.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { ipcMain, SaveDialogOptions, dialog, app, RelaunchOptions, OpenDialogOptions } from 'electron'
2+
import { getProxyAgent } from 'mishiro-core/util/proxy'
3+
import got from 'got'
24
// import onManifestQuery from './on-manifest-query'
35
// import onManifestSearch from './on-manifest-search'
46
// import onGame from './on-game'
@@ -98,7 +100,25 @@ export default function ipc (): void {
98100
})
99101

100102
ipcMain.handle('checkResourceVersion', async () => {
101-
const res = await client.check()
103+
let res: number
104+
try {
105+
res = await client.check()
106+
} catch (err1: any) {
107+
interface InfoFromKirara {
108+
api_major: number
109+
api_revision: number
110+
truth_version: string
111+
}
112+
try {
113+
const response = await got.get<InfoFromKirara>('https://starlight.kirara.ca/api/v1/info', {
114+
responseType: 'json',
115+
agent: getProxyAgent(configurer.get('proxy'))
116+
})
117+
res = Number(response.body.truth_version)
118+
} catch (err2: any) {
119+
throw new Error([err1, err2].map(e => e.message).join('\n'))
120+
}
121+
}
102122
if (res !== 0) {
103123
const latestResVer = configurer.get('latestResVer')
104124
if (!latestResVer || (res > latestResVer)) {

app/src/ts/renderer/vue-global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const path = window.node.path
99
const { iconDir } = getPath
1010

1111
// const gameHostBase = 'http://storage.game.starlight-stage.jp/dl/resources'
12-
const imgHostBase = 'https://truecolor.kirara.ca'
12+
const imgHostBase = 'https://hidamarirhodonite.kirara.ca'
1313
// const getBgmUrl = (hash: string) => `${gameHostBase}/High/Sound/Common/b/${hash}`
1414
// const getLiveUrl = (hash: string) => `${gameHostBase}/High/Sound/Common/l/${hash}`
1515
// const getVoiceUrl = (hash: string) => `${gameHostBase}/High/Sound/Common/v/${hash}`

app/src/ts/typings/global.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ declare interface IBatchError {
55
}
66

77
declare const MISHIRO_DEV_SERVER_PORT: number
8+
9+
declare module 'mishiro-core/util/proxy' {
10+
export function getProxyAgent (proxy?: string): {
11+
http?: import('http').Agent
12+
https?: import('https').Agent
13+
} | false
14+
}

0 commit comments

Comments
 (0)