@@ -6,6 +6,8 @@ import { EventEmitter } from 'stream'
66import TypedEmitter from 'typed-emitter'
77import { generateUserArgent } from '../utils'
88import { logger } from '../logger'
9+ import { observe } from 'mobx'
10+ import { electronLocalshortcut } from '@hfelix/electron-localshortcut'
911
1012type GameWindowEvents = {
1113 close : ( event : Event ) => void
@@ -16,6 +18,7 @@ export class GameWindow extends (EventEmitter as new () => TypedEmitter<GameWind
1618 private readonly _teamWindow ?: GameTeamWindow
1719 private readonly _team ?: GameTeam
1820 private _isMuted = false
21+ private readonly _shortcutStoreDisposer : ( ) => void
1922
2023 get id ( ) {
2124 return this . _win . webContents . id !
@@ -102,6 +105,19 @@ export class GameWindow extends (EventEmitter as new () => TypedEmitter<GameWind
102105 }
103106 } )
104107
108+ this . _shortcutStoreDisposer = observe (
109+ this . _store . hotkeyStore . window . tabs ,
110+ ( ) => {
111+ electronLocalshortcut . unregisterAll ( this . _win )
112+ this . _store . hotkeyStore . window . tabs . forEach ( ( tab , index ) => {
113+ electronLocalshortcut . register ( this . _win , tab , ( ) => {
114+ this . _win . webContents . send ( IPCEvents . SELECT_TAB , index )
115+ } )
116+ } )
117+ } ,
118+ true
119+ )
120+
105121 if ( app . isPackaged ) {
106122 this . _win . loadFile ( join ( __dirname , '../renderer/index.html' ) )
107123 } else {
@@ -131,6 +147,8 @@ export class GameWindow extends (EventEmitter as new () => TypedEmitter<GameWind
131147
132148 private _close ( event : Event ) {
133149 this . _win . removeAllListeners ( )
150+ electronLocalshortcut . unregisterAll ( this . _win )
151+ this . _shortcutStoreDisposer ( )
134152 this . emit ( 'close' , event )
135153 }
136154
0 commit comments