1
- import { app , BrowserWindow , Tray , Menu , nativeImage } from 'electron' ;
1
+ import {
2
+ app ,
3
+ BrowserWindow ,
4
+ Tray ,
5
+ Menu ,
6
+ nativeImage ,
7
+ NativeImage ,
8
+ } from 'electron' ;
2
9
import * as path from 'path' ;
3
10
import server from './lib/server' ;
4
- import http from 'http' ;
5
- import fs from 'fs' ;
6
11
7
12
server ( ) ;
8
13
@@ -17,9 +22,17 @@ if (require('electron-squirrel-startup')) {
17
22
app . quit ( ) ;
18
23
}
19
24
20
- let logoPath : string = path . join ( __dirname , 'mcat.png' ) ;
25
+ let ico : NativeImage ;
21
26
22
- console . log ( logoPath ) ;
27
+ if ( process . env . NODE_ENV == 'development' ) {
28
+ ico = nativeImage . createFromPath (
29
+ path . join ( __dirname , '..' , '..' , 'mcat.png' ) ,
30
+ ) ;
31
+ } else {
32
+ ico = nativeImage . createFromPath ( path . join ( __dirname , 'mcat.png' ) ) ;
33
+ }
34
+
35
+ console . log ( process . env . NODE_ENV ) ;
23
36
24
37
let tray : Tray | null ;
25
38
@@ -48,7 +61,7 @@ const createMcat = (): void => {
48
61
49
62
mcatWindow . setMenu ( null ) ;
50
63
51
- mainWindow . setIcon ( nativeImage . createFromPath ( logoPath ) ) ;
64
+ mainWindow . setIcon ( ico ) ;
52
65
53
66
// and load the index.html of the app.
54
67
mcatWindow . loadURL ( 'https://player.monstercat.app' ) ;
@@ -77,7 +90,7 @@ const createWindow = (): void => {
77
90
mainWindow = null ;
78
91
} ) ;
79
92
80
- mainWindow . setIcon ( nativeImage . createFromPath ( logoPath ) ) ;
93
+ mainWindow . setIcon ( ico ) ;
81
94
82
95
// and load the index.html of the app.
83
96
mainWindow . loadURL ( MAIN_WINDOW_WEBPACK_ENTRY ) ;
@@ -90,11 +103,11 @@ app.on('ready', createWindow);
90
103
91
104
app . whenReady ( ) . then ( async ( ) => {
92
105
createWindow ( ) ;
93
- await downloadLogo ( ) ;
106
+ // await downloadLogo();
94
107
runTray ( ) ;
95
108
} ) ;
96
109
97
- const downloadLogo = async ( ) => {
110
+ /* const downloadLogo = async () => {
98
111
return new Promise<void>((resolve) => {
99
112
if (!fs.existsSync('./mcat.png')) {
100
113
resolve();
@@ -121,7 +134,7 @@ const downloadLogo = async () => {
121
134
},
122
135
);
123
136
});
124
- } ;
137
+ }; */
125
138
126
139
// Quit when all windows are closed, except on macOS. There, it's common
127
140
// for applications and their menu bar to stay active until the user quits
@@ -142,12 +155,17 @@ app.on('activate', () => {
142
155
// code. You can also put them in separate files and import them here.
143
156
144
157
function runTray ( ) {
145
- const icon = nativeImage
146
- . createFromPath ( path . resolve ( __dirname , 'mcat.png' ) )
147
- . resize ( { width : 32 , height : 32 } ) ;
158
+ const icon = ico . resize ( { width : 32 , height : 32 } ) ;
148
159
tray = new Tray ( icon ) ;
149
160
const contextMenu = Menu . buildFromTemplate ( [
150
161
{ label : 'Mcat-Dc' , type : 'normal' , enabled : false } ,
162
+ {
163
+ label : 'Main Window' ,
164
+ type : 'normal' ,
165
+ click ( ) {
166
+ createWindow ( ) ;
167
+ } ,
168
+ } ,
151
169
{
152
170
label : 'Player' ,
153
171
type : 'normal' ,
@@ -169,4 +187,6 @@ function runTray() {
169
187
} ) ;
170
188
171
189
tray . setContextMenu ( contextMenu ) ;
190
+
191
+ tray . setToolTip ( 'mcat-discord-rpc' ) ;
172
192
}
0 commit comments