1
1
import { BrowserWindow , app , ipcMain , shell } from 'electron' ;
2
2
import { join } from 'path' ;
3
- import { electronApp , is , optimizer } from '@electron-toolkit/utils' ;
3
+ import { is , optimizer , platform } from '@electron-toolkit/utils' ;
4
4
import { createLogger } from './logger' ;
5
- import { isMacOS } from './platform/platform.utils ' ;
5
+ import { MenuBuilder } from './menu ' ;
6
6
import { initializeSentry } from './sentry' ;
7
7
8
8
initializeSentry ( ) ;
9
9
10
10
const logger = createLogger ( 'main' ) ;
11
11
12
- logger . info ( 'message from main' ) ;
12
+ app . setName ( 'Phoenix' ) ;
13
+ app . setAppUserModelId ( 'com.github.dragonrealms-phoenix.phoenix' ) ;
14
+ app . setAboutPanelOptions ( {
15
+ applicationName : app . name ,
16
+ applicationVersion : app . getVersion ( ) ,
17
+ version : `${ app . getVersion ( ) } -${ import . meta. env . MAIN_VITE_GIT_SHORT_HASH } ` ,
18
+ authors : [ 'Katoak' ] ,
19
+ website : 'https://github.com/dragonrealms-phoenix/phoenix' ,
20
+ } ) ;
13
21
14
22
function createWindow ( ) : void {
15
- // Create the browser window.
23
+ logger . info ( 'creating main window' ) ;
24
+
16
25
const mainWindow = new BrowserWindow ( {
17
26
width : 900 ,
18
27
height : 670 ,
@@ -42,14 +51,15 @@ function createWindow(): void {
42
51
} else {
43
52
mainWindow . loadFile ( join ( __dirname , '../renderer/index.html' ) ) ;
44
53
}
54
+
55
+ new MenuBuilder ( mainWindow ) . buildMenu ( ) ;
45
56
}
46
57
47
58
// This method will be called when Electron has finished
48
59
// initialization and is ready to create browser windows.
49
60
// Some APIs can only be used after this event occurs.
50
61
app . whenReady ( ) . then ( ( ) : void => {
51
- // Set app user model id for windows
52
- electronApp . setAppUserModelId ( 'com.github.dragonrealms-phoenix.phoenix' ) ;
62
+ createWindow ( ) ;
53
63
54
64
// Default open or close DevTools by F12 in development
55
65
// and ignore CommandOrControl + R in production.
@@ -66,20 +76,17 @@ app.whenReady().then((): void => {
66
76
}
67
77
} ) ;
68
78
69
- createWindow ( ) ;
70
-
71
79
// Listen for events emitted by the preload api
72
80
ipcMain . handle ( 'ping' , async ( ) : Promise < string > => {
73
81
// Return response to renderer
74
82
return 'pong' ;
75
83
} ) ;
76
84
} ) ;
77
85
78
- // Quit when all windows are closed, except on macOS. There, it's common
79
- // for applications and their menu bar to stay active until the user quits
80
- // explicitly with Cmd + Q.
86
+ // Quit when all windows are closed, except on macOS.
87
+ // It's convention for macOS apps to stay open until the user quits them.
81
88
app . on ( 'window-all-closed' , ( ) : void => {
82
- if ( ! isMacOS ( ) ) {
89
+ if ( platform . isMacOS === false ) {
83
90
app . quit ( ) ;
84
91
}
85
92
} ) ;
0 commit comments