manager/main.js

92 lines
1.9 KiB
JavaScript

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