budibase/packages/server/src/electron.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

const { app, BrowserWindow } = require("electron");
const { join } = require("path");
const { homedir } = require("os");
const isDev = require("electron-is-dev");
const { autoUpdater } = require("electron-updater");
2020-05-07 14:33:25 +02:00
require("dotenv").config({ path: join(homedir(), ".budibase", ".env") });
const APP_URL = "http://localhost:4001/_builder";
const APP_TITLE = "Budibase Builder";
2020-05-07 14:52:24 +02:00
2020-05-07 14:33:25 +02:00
function createWindow() {
2020-05-07 15:04:32 +02:00
app.server = require("./app");
2020-05-07 14:33:25 +02:00
let win = new BrowserWindow({ width: 1920, height: 1080 });
win.setTitle(APP_TITLE);
win.loadURL(APP_URL);
if (isDev) {
win.webContents.openDevTools();
} else {
autoUpdater.checkForUpdatesAndNotify();
}
2020-05-07 14:33:25 +02:00
}
app.whenReady().then(createWindow)
// Quit when all windows are closed.
app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== "darwin") app.quit();
});
app.on("activate", () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) createWindow();
});