Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6 screenshot of the filled week #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 62 additions & 47 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,92 @@
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
const path = require('path')
const appSettings = require('./electron/appSettings');
const { app, BrowserWindow, Menu, ipcMain } = require("electron");
const path = require("path");
const appSettings = require("./electron/appSettings");
let win;
let isDev = !app.isPackaged
let isDev = !app.isPackaged;

require('./electron/eventBus');
!isDev && require('./shared/sentry');
require("./electron/eventBus");
!isDev && require("./shared/sentry");

const getBrowserWindowInstance = () => {
return new BrowserWindow({
show: false,
width: 560,
height: 690,
center: true,
resizable: isDev,
webPreferences: {
nodeIntegration: true,
scrollBounce: true,
devTools: isDev,
preload: path.join(__dirname, 'shared', 'sentry.js'),
nativeWindowOpen: true
},
icon: path.join(__dirname, 'assets/icons/icon.png')
})
}

function createWindow() {
// Create the browser window.
win = new BrowserWindow({
show: false,
width: 560,
height: 690,
center: true,
resizable: isDev,
webPreferences: {
nodeIntegration: true,
scrollBounce: true,
devTools: isDev,
preload: path.join(__dirname, 'shared', 'sentry.js')
},
icon: path.join(__dirname, 'assets/icons/icon.png')
})

win = getBrowserWindowInstance();
isDev && win.webContents.openDevTools();

const menu = Menu.buildFromTemplate([
{ role: 'fileMenu' },
{ role: 'editMenu'},
{ role: "fileMenu" },
{ role: "editMenu" },
{
label: 'Debug',
submenu: [
{
label: 'Show browser',
click() {
appSettings.toggle('showBrowser');
},
type: 'checkbox',
checked: appSettings.get('showBrowser'),
accelerator: 'CmdOrCtrl+Shift+B'
label: "Debug",
submenu: [
{
label: "Show browser",
click() {
appSettings.toggle("showBrowser");
},
]
type: "checkbox",
checked: appSettings.get("showBrowser"),
accelerator: "CmdOrCtrl+Shift+B"
}
]
}
])
]);
Menu.setApplicationMenu(menu);

win.once('ready-to-show', () => {
win.show()
})
win.once("ready-to-show", () => {
win.show();
});

// and load the index.html of the app.
win.loadURL(
isDev
? 'http://localhost:1234/'
? "http://localhost:1234/"
: `file://${path.join(__dirname, "./dist/index.html")}`
)
);

win.webContents.on("new-window", function(event, url) {
win.webContents.on("new-window", function(event, url, frameName, disposition, options) {
event.preventDefault();
if (frameName === "modal") {
// open window as modal
event.preventDefault();
Object.assign(options, {
modal: true,
parent: win,
width: 500,
height: 500
});
event.newGuest = new BrowserWindow(options);
}
});

win.on("closed", () => (win = null));
}

app.whenReady().then(createWindow)
app.whenReady().then(createWindow);

ipcMain.on('anteater.error', () => {
console.log('Error triggered in main processes');
throw new Error('Error triggered in main processes');
ipcMain.on("anteater.error", () => {
console.log("Error triggered in main processes");
throw new Error("Error triggered in main processes");
});

ipcMain.on('anteater.crash', () => {
console.log('process.crash()');
ipcMain.on("anteater.crash", () => {
console.log("process.crash()");
process.crash();
});
Loading