2022-05-22 11:52:26 +00:00
|
|
|
import {app, Menu, Tray} from "electron";
|
|
|
|
import {mainWindow} from "./window";
|
2022-06-16 15:24:37 +00:00
|
|
|
import {getConfig, setWindowState} from "./utils";
|
2022-03-04 17:53:18 +00:00
|
|
|
import * as path from "path";
|
2022-05-22 11:52:26 +00:00
|
|
|
import {createSettingsWindow} from "./settings/main";
|
2022-06-14 14:49:12 +00:00
|
|
|
import {platform} from "process";
|
2022-04-20 19:50:23 +00:00
|
|
|
let tray: any = null;
|
2022-06-14 14:49:12 +00:00
|
|
|
let defaultIcon = "ac_plug_colored";
|
2022-04-20 19:50:23 +00:00
|
|
|
app.whenReady().then(async () => {
|
2022-06-14 14:49:12 +00:00
|
|
|
if (platform == "darwin") {
|
|
|
|
defaultIcon = "macos"
|
|
|
|
}
|
2022-05-22 11:52:26 +00:00
|
|
|
if ((await getConfig("windowStyle")) == "discord") {
|
2022-04-21 16:20:58 +00:00
|
|
|
tray = new Tray(path.join(__dirname, "../", "/assets/dsc-tray.png"));
|
2022-04-20 19:50:23 +00:00
|
|
|
const contextMenu = Menu.buildFromTemplate([
|
|
|
|
{
|
|
|
|
label: "Open ArmCord",
|
|
|
|
click: function () {
|
|
|
|
mainWindow.show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Quit ArmCord",
|
|
|
|
click: function () {
|
2022-06-16 15:24:37 +00:00
|
|
|
let [width, height] = mainWindow.getSize()
|
|
|
|
setWindowState({
|
|
|
|
width: width,
|
|
|
|
height: height,
|
|
|
|
isMaximized: mainWindow.isMaximized()
|
|
|
|
})
|
2022-04-20 19:50:23 +00:00
|
|
|
app.quit();
|
|
|
|
}
|
2022-03-04 17:53:18 +00:00
|
|
|
}
|
2022-04-20 19:50:23 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
tray.setToolTip("Discord");
|
|
|
|
tray.setContextMenu(contextMenu);
|
|
|
|
} else {
|
2022-06-14 14:49:12 +00:00
|
|
|
var trayIcon = (await getConfig("trayIcon")) ?? defaultIcon;
|
2022-05-22 14:46:18 +00:00
|
|
|
tray = new Tray(path.join(__dirname, "../", `/assets/${trayIcon}.png`));
|
2022-04-20 19:50:23 +00:00
|
|
|
const contextMenu = Menu.buildFromTemplate([
|
2022-05-14 17:55:06 +00:00
|
|
|
{
|
2022-05-22 11:52:26 +00:00
|
|
|
label: "ArmCord"
|
2022-05-14 17:55:06 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "separator"
|
|
|
|
},
|
2022-04-20 19:50:23 +00:00
|
|
|
{
|
|
|
|
label: "Open ArmCord",
|
|
|
|
click: function () {
|
|
|
|
mainWindow.show();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Open Settings",
|
|
|
|
click: function () {
|
|
|
|
createSettingsWindow();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Support Discord Server",
|
|
|
|
click: function () {
|
|
|
|
mainWindow.show();
|
|
|
|
mainWindow.loadURL("https://discord.gg/TnhxcqynZ2");
|
|
|
|
}
|
|
|
|
},
|
2022-05-14 17:55:06 +00:00
|
|
|
{
|
|
|
|
type: "separator"
|
|
|
|
},
|
2022-04-20 19:50:23 +00:00
|
|
|
{
|
|
|
|
label: "Quit ArmCord",
|
|
|
|
click: function () {
|
2022-06-16 15:24:37 +00:00
|
|
|
let [width, height] = mainWindow.getSize()
|
|
|
|
setWindowState({
|
|
|
|
width: width,
|
|
|
|
height: height,
|
|
|
|
isMaximized: mainWindow.isMaximized()
|
|
|
|
})
|
2022-04-20 19:50:23 +00:00
|
|
|
app.quit();
|
|
|
|
}
|
2022-03-04 17:53:18 +00:00
|
|
|
}
|
2022-04-20 19:50:23 +00:00
|
|
|
]);
|
2022-03-04 17:53:18 +00:00
|
|
|
|
2022-04-20 19:50:23 +00:00
|
|
|
tray.setToolTip("ArmCord " + app.getVersion());
|
|
|
|
tray.setContextMenu(contextMenu);
|
|
|
|
}
|
2022-03-04 17:53:18 +00:00
|
|
|
});
|