Skip to content

Commit cd66aa7

Browse files
committed
Some new stuff
1 parent 2d7321b commit cd66aa7

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

src/index.ts

+33-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
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';
29
import * as path from 'path';
310
import server from './lib/server';
4-
import http from 'http';
5-
import fs from 'fs';
611

712
server();
813

@@ -17,9 +22,17 @@ if (require('electron-squirrel-startup')) {
1722
app.quit();
1823
}
1924

20-
let logoPath: string = path.join(__dirname, 'mcat.png');
25+
let ico: NativeImage;
2126

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);
2336

2437
let tray: Tray | null;
2538

@@ -48,7 +61,7 @@ const createMcat = (): void => {
4861

4962
mcatWindow.setMenu(null);
5063

51-
mainWindow.setIcon(nativeImage.createFromPath(logoPath));
64+
mainWindow.setIcon(ico);
5265

5366
// and load the index.html of the app.
5467
mcatWindow.loadURL('https://player.monstercat.app');
@@ -77,7 +90,7 @@ const createWindow = (): void => {
7790
mainWindow = null;
7891
});
7992

80-
mainWindow.setIcon(nativeImage.createFromPath(logoPath));
93+
mainWindow.setIcon(ico);
8194

8295
// and load the index.html of the app.
8396
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
@@ -90,11 +103,11 @@ app.on('ready', createWindow);
90103

91104
app.whenReady().then(async () => {
92105
createWindow();
93-
await downloadLogo();
106+
// await downloadLogo();
94107
runTray();
95108
});
96109

97-
const downloadLogo = async () => {
110+
/* const downloadLogo = async () => {
98111
return new Promise<void>((resolve) => {
99112
if (!fs.existsSync('./mcat.png')) {
100113
resolve();
@@ -121,7 +134,7 @@ const downloadLogo = async () => {
121134
},
122135
);
123136
});
124-
};
137+
}; */
125138

126139
// Quit when all windows are closed, except on macOS. There, it's common
127140
// for applications and their menu bar to stay active until the user quits
@@ -142,12 +155,17 @@ app.on('activate', () => {
142155
// code. You can also put them in separate files and import them here.
143156

144157
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 });
148159
tray = new Tray(icon);
149160
const contextMenu = Menu.buildFromTemplate([
150161
{ label: 'Mcat-Dc', type: 'normal', enabled: false },
162+
{
163+
label: 'Main Window',
164+
type: 'normal',
165+
click() {
166+
createWindow();
167+
},
168+
},
151169
{
152170
label: 'Player',
153171
type: 'normal',
@@ -169,4 +187,6 @@ function runTray() {
169187
});
170188

171189
tray.setContextMenu(contextMenu);
190+
191+
tray.setToolTip('mcat-discord-rpc');
172192
}

0 commit comments

Comments
 (0)