manager/main.js

92 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2023-04-26 21:26:20 +00:00
const {app, BrowserWindow, ipcMain, Notification, nativeImage, Tray, Menu, shell} = require("electron")
2023-04-24 15:51:18 +00:00
const path = require("path")
const fs = require("fs")
const ipc = ipcMain
2023-04-26 21:26:20 +00:00
const { io } = require("socket.io-client");
2023-04-29 18:05:31 +00:00
const log = require("./sub-log");
2023-04-29 16:19:45 +00:00
const updater = require("./updatetools")
2023-04-24 15:51:18 +00:00
// [Function] Main Window Function
2023-04-27 14:54:48 +00:00
// BUILDER "build": "
2023-04-26 21:37:15 +00:00
2023-04-26 21:26:20 +00:00
async function createWindow() {
2023-04-24 15:51:18 +00:00
const win = new BrowserWindow({
2023-08-29 10:20:07 +00:00
width: 1920,
height: 1080,
minWidth: 1280,
minHeight: 720,
resizable: true,
2023-04-24 15:51:18 +00:00
movable: true,
closable: true,
2023-08-29 10:20:07 +00:00
frame: true,
autoHideMenuBar: true,
2023-04-24 15:51:18 +00:00
icon: path.join(__dirname, './src/logo.ico'),
title: "Submanager",
webPreferences: {
devTools: true
}
})
2023-04-29 16:19:45 +00:00
if(process.env.DEV != "true") {
updater.checkUpdate()
} else {
2023-04-24 15:51:18 +00:00
2023-04-29 16:19:45 +00:00
log.update("Desactivation des mises a jour -> DEV MOD ENABLE")
}
2023-04-24 15:51:18 +00:00
2023-08-29 10:20:07 +00:00
await win.loadURL("https://subsonics.raphix.fr")
2023-04-26 21:26:20 +00:00
2023-04-24 15:51:18 +00:00
}
2023-04-26 21:26:20 +00:00
app.on("open-url", (ev, url) => {
app.quit()
2023-08-29 10:20:07 +00:00
})
2023-04-26 21:26:20 +00:00
2023-04-24 15:51:18 +00:00
app.whenReady().then(() => {
2023-04-30 17:00:04 +00:00
const icon = nativeImage.createFromPath(__dirname + path.sep + 'src' + path.sep + "logo.ico")
2023-04-24 15:51:18 +00:00
tray = new Tray(icon)
const contextMenu = Menu.buildFromTemplate([
{ label:"Quitter", click() { app.quit()}}
])
tray.setToolTip("Submanager")
tray.setContextMenu(contextMenu)
//[Operation] - Check settings
2023-04-29 16:19:45 +00:00
log.client("Submanager - Version : " + require("./package.json").version + " - Raphix")
2023-04-26 21:26:20 +00:00
log.client("Starting Application")
2023-04-29 16:19:45 +00:00
createWindow()
2023-04-24 15:51:18 +00:00
app.on('activate', () => {
2023-04-26 21:26:20 +00:00
autoUpdater.checkForUpdates()
2023-04-24 15:51:18 +00:00
if(BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
2023-04-26 21:26:20 +00:00
//EXPORT COMMAND : npx electron-packager . submanager-beta-1 --platform="win32" --out="C:\Users\picot\OneDrive\Bureau\"