Skip to content

Commit a1bacad

Browse files
authored
Merge pull request #102 from c-liang/main
extension update
2 parents 5124fea + fd93253 commit a1bacad

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

src/pages/background/background.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import "../main/utils/tray.ts"
2-
import {GameFlow} from "../main/utils/gameFlow";
1+
import '../main/utils/tray.ts'
2+
import { GameFlow } from '../main/utils/gameFlow'
33

44
cube.extensions.on('launch-triggered', (s) => {
55
cube.windows.obtainDeclaredWindow('main')
@@ -12,7 +12,7 @@ cube.games.launchers.events.on('update-info', async (classId, info) => {
1212
if (info.category === 'game_flow') {
1313
if (info.value === 'ChampSelect') {
1414
// 显示助手窗口
15-
gameFlow.showOrHideAssist(true,'query-other-summoner')
15+
gameFlow.showOrHideAssist(true, 'query-other-summoner')
1616
gameFlow.autoPickBanChamp()
1717
} else if (info.value === 'GameStart') {
1818
// 选择英雄结束后,发送消息给渲染进程, 让渲染进程获取到敌方召唤师信息
@@ -26,7 +26,7 @@ cube.games.launchers.events.on('update-info', async (classId, info) => {
2626
}
2727
}
2828
if (info.category === 'json_api_event' && info.key === 'raw_data') {
29-
const obj: { data: any, eventType: string, uri: string } = JSON.parse(
29+
const obj: { data: any; eventType: string; uri: string } = JSON.parse(
3030
info.value
3131
)
3232
if (obj.uri === '/lol-champ-select/v1/current-champion') {
@@ -35,3 +35,29 @@ cube.games.launchers.events.on('update-info', async (classId, info) => {
3535
}
3636
}
3737
})
38+
39+
let update = false
40+
cube.extensions.on('updated', () => {
41+
update = true
42+
cube.games.launchers.getRunningLaunchers().then(async (v) => {
43+
const lol = v.find((t) => t.classId == 10902)
44+
if (lol == undefined) {
45+
cube.extensions.relaunch()
46+
} else {
47+
const info = await cube.games.launchers.events.getInfo(10902)
48+
if (info.game_flow && info.game_flow.phase == 'None') {
49+
cube.extensions.relaunch()
50+
}
51+
}
52+
})
53+
})
54+
cube.games.on('stopped', (classId) => {
55+
if (classId === 5426 && update) {
56+
cube.extensions.relaunch()
57+
}
58+
})
59+
cube.games.launchers.on('stopped', (classId) => {
60+
if (classId === 10902 && update) {
61+
cube.extensions.relaunch()
62+
}
63+
})

0 commit comments

Comments
 (0)