diff --git a/electron/main.js b/electron/main.js
index c74b575..f22192e 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -1,9 +1,8 @@
const path = require("path");
-const { app, BrowserWindow, ipcMain } = require("electron");
+const { app, BrowserWindow, Tray, Menu, ipcMain } = require("electron");
const isDev = require("electron-is-dev");
const settings = require("electron-settings");
-const ipcTypes = require("../src/ipc.types");
-const { StartWatcher } = require("./file-watcher/file-watcher");
+const { default: ipcTypes } = require("../src/ipc.types");
require("./ipc-main-handler");
@@ -23,13 +22,16 @@ if (require("electron-squirrel-startup")) {
console.log(`${__dirname}/preload.js`);
let mainWindow;
+let tray = null;
function createWindow() {
makeSingleInstance();
// Create the browser window.
+
mainWindow = new BrowserWindow({
width: 800,
height: 600,
title: "ImEX RPS",
+ icon: path.join(__dirname, "../src/assets/logo192.png"),
webPreferences: {
nodeIntegration: false,
enableRemoteModule: false,
@@ -46,6 +48,23 @@ function createWindow() {
: `file://${path.join(__dirname, "../build/index.html")}`
);
+ // mainWindow.on("close", function (event) {
+ // event.preventDefault();
+ // mainWindow.hide();
+ // tray = createTray();
+ // });
+
+ mainWindow.on("minimize", function (event) {
+ event.preventDefault();
+ mainWindow.hide();
+ tray = createTray();
+ });
+
+ ipcMain.on(ipcTypes.quit, (event, arg) => {
+ app.isQuiting = true;
+ app.quit();
+ });
+
// Open the DevTools.
if (isDev) {
mainWindow.webContents.openDevTools({
@@ -67,7 +86,7 @@ app.whenReady().then(() => {
.then((name) => console.log(`Added Extension: ${name}`))
.catch((error) => console.log(`An error occurred: , ${error}`));
}
- StartWatcher();
+
// ipcMain.on(ipcTypes.default.webcontent, (event, ...obj) => {
// console.log("event", event);
// mainWindow.webContents.send(event, obj);
@@ -106,3 +125,29 @@ function makeSingleInstance() {
}
});
}
+
+function createTray() {
+ let appIcon = new Tray(path.join(__dirname, "../src/assets/logo192.png"));
+ const contextMenu = Menu.buildFromTemplate([
+ {
+ label: "Show",
+ click: function () {
+ mainWindow.show();
+ },
+ },
+ {
+ label: "Exit",
+ click: function () {
+ app.isQuiting = true;
+ app.quit();
+ },
+ },
+ ]);
+
+ appIcon.on("double-click", function (event) {
+ mainWindow.show();
+ });
+ appIcon.setToolTip("ImEX RPS");
+ appIcon.setContextMenu(contextMenu);
+ return appIcon;
+}
diff --git a/src/components/organisms/sider-menu/sider-menu.organism.jsx b/src/components/organisms/sider-menu/sider-menu.organism.jsx
index ddade40..042545d 100644
--- a/src/components/organisms/sider-menu/sider-menu.organism.jsx
+++ b/src/components/organisms/sider-menu/sider-menu.organism.jsx
@@ -1,8 +1,14 @@
-import { PieChartOutlined, SettingFilled } from "@ant-design/icons";
+import {
+ PieChartOutlined,
+ SettingFilled,
+ CloseOutlined,
+} from "@ant-design/icons";
import { Menu } from "antd";
import React from "react";
import { Link } from "react-router-dom";
+import ipcTypes from "../../../ipc.types";
import SiderSignOut from "../../molecules/sider-sign-out/sider-sign-out.molecule";
+const { ipcRenderer } = window;
export default function SiderMenuOrganism() {
return (
@@ -14,6 +20,16 @@ export default function SiderMenuOrganism() {
Settings