Skip to content

Commit

Permalink
docs: update forge create-electron-app template to match tutorial (#3528
Browse files Browse the repository at this point in the history
)

* docs: update forge template to match best practices in tutorials

* chore: run prettier

* chore: use node prefix with path module

---------

Co-authored-by: Alice Zhao <[email protected]>
  • Loading branch information
alicelovescake and Alice Zhao committed Mar 11, 2024
1 parent a6a8bde commit 3c5bf3d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/template/base/tmpl/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
const path = require('node:path');

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
Expand All @@ -26,7 +26,17 @@ const createWindow = () => {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
app.whenReady().then(() => {
createWindow();

// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
Expand All @@ -37,13 +47,5 @@ app.on('window-all-closed', () => {
}
});

app.on('activate', () => {
// On OS X 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 (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.

0 comments on commit 3c5bf3d

Please sign in to comment.