Skip to content

Commit

Permalink
version checking fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Mar 4, 2024
1 parent ba751ed commit 77c2d61
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
22 changes: 21 additions & 1 deletion app/src/ts/main/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ipcMain, SaveDialogOptions, dialog, app, RelaunchOptions, OpenDialogOptions } from 'electron'
import { getProxyAgent } from 'mishiro-core/util/proxy'
import got from 'got'
// import onManifestQuery from './on-manifest-query'
// import onManifestSearch from './on-manifest-search'
// import onGame from './on-game'
Expand Down Expand Up @@ -98,7 +100,25 @@ export default function ipc (): void {
})

ipcMain.handle('checkResourceVersion', async () => {
const res = await client.check()
let res: number
try {
res = await client.check()
} catch (err1: any) {
interface InfoFromKirara {
api_major: number
api_revision: number
truth_version: string
}
try {
const response = await got.get<InfoFromKirara>('https://starlight.kirara.ca/api/v1/info', {
responseType: 'json',
agent: getProxyAgent(configurer.get('proxy'))
})
res = Number(response.body.truth_version)
} catch (err2: any) {
throw new Error([err1, err2].map(e => e.message).join('\n'))
}
}
if (res !== 0) {
const latestResVer = configurer.get('latestResVer')
if (!latestResVer || (res > latestResVer)) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/ts/renderer/vue-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const path = window.node.path
const { iconDir } = getPath

// const gameHostBase = 'http://storage.game.starlight-stage.jp/dl/resources'
const imgHostBase = 'https://truecolor.kirara.ca'
const imgHostBase = 'https://hidamarirhodonite.kirara.ca'
// const getBgmUrl = (hash: string) => `${gameHostBase}/High/Sound/Common/b/${hash}`
// const getLiveUrl = (hash: string) => `${gameHostBase}/High/Sound/Common/l/${hash}`
// const getVoiceUrl = (hash: string) => `${gameHostBase}/High/Sound/Common/v/${hash}`
Expand Down
7 changes: 7 additions & 0 deletions app/src/ts/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ declare interface IBatchError {
}

declare const MISHIRO_DEV_SERVER_PORT: number

declare module 'mishiro-core/util/proxy' {
export function getProxyAgent (proxy?: string): {
http?: import('http').Agent
https?: import('https').Agent
} | false
}

0 comments on commit 77c2d61

Please sign in to comment.