armcord/src/tray.ts

61 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-04-20 19:50:23 +00:00
import { app, Menu, Tray } from "electron";
import { mainWindow } from "./window";
import { getConfig } from "./utils";
2022-03-04 17:53:18 +00:00
import * as path from "path";
2022-04-20 19:50:23 +00:00
import { createSettingsWindow } from "./settings/main";
let tray: any = null;
app.whenReady().then(async () => {
if (await getConfig("windowStyle") == "discord") {
tray = new Tray(path.join(__dirname, "../", "/assets/ac_plug.png"));
const contextMenu = Menu.buildFromTemplate([
{
label: "Open ArmCord",
click: function () {
mainWindow.show();
}
},
{
label: "Quit ArmCord",
click: function () {
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 {
tray = new Tray(path.join(__dirname, "../", "/assets/ac_plug.png"));
const contextMenu = Menu.buildFromTemplate([
{
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");
}
},
{
label: "Quit ArmCord",
click: function () {
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
});