From 568debd74070ecb23433a8fb413b48dcc56141eb Mon Sep 17 00:00:00 2001 From: altaf-creator <64111012+altaf-creator@users.noreply.github.com> Date: Wed, 3 May 2023 22:12:11 +0700 Subject: Initial commit --- main.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 main.js (limited to 'main.js') diff --git a/main.js b/main.js new file mode 100644 index 0000000..73315ca --- /dev/null +++ b/main.js @@ -0,0 +1,61 @@ +const { app, BrowserWindow, ipcMain, shell } = require('electron') +const path = require('path') + +const nativeImage = require('electron').nativeImage; +var icon = nativeImage.createFromPath(__dirname + '/src/images/favicon.png'); + +icon.setTemplateImage(true); + +var isMaximized = false; + +const createWindow = () => { + const win = new BrowserWindow({ + width: 1280, + height: 720, + minWidth: 600, + minHeight: 400, + webPreferences: { + nodeIntegration: true, + contextIsolation: false, + preload: path.join(__dirname, 'preload.js') + }, + autoHideMenuBar: true, + titleBarStyle: 'hiddenInset', + frame: false, + icon: icon + }) + + win.loadFile('index.html') + + win.webContents.setWindowOpenHandler(({ url }) => { + shell.openExternal(url); + return { action: 'deny' }; + }); + + + ipcMain.on('max', () => { + if (isMaximized) { + win.restore() + isMaximized = false; + } else { + win.maximize() + isMaximized = true; + } + }) + + ipcMain.on('min', () => { + win.minimize() + }) +} + +app.whenReady().then(() => { + createWindow() + + app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') app.quit() +}) \ No newline at end of file -- cgit v1.2.3