summaryrefslogtreecommitdiff
path: root/main.js
diff options
context:
space:
mode:
authoraltaf-creator <64111012+altaf-creator@users.noreply.github.com>2023-05-03 22:12:11 +0700
committeraltaf-creator <64111012+altaf-creator@users.noreply.github.com>2023-05-03 22:12:11 +0700
commit568debd74070ecb23433a8fb413b48dcc56141eb (patch)
tree1916a58c3a5ec60827da2ea6e38baf2116b266d2 /main.js
Initial commit
Diffstat (limited to 'main.js')
-rw-r--r--main.js61
1 files changed, 61 insertions, 0 deletions
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