Skip to content

Commit 3c5bf3d

Browse files
alicelovescakeAlice Zhao
and
Alice Zhao
authored
docs: update forge create-electron-app template to match tutorial (#3528)
* 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]>
1 parent a6a8bde commit 3c5bf3d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/template/base/tmpl/index.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { app, BrowserWindow } = require('electron');
2-
const path = require('path');
2+
const path = require('node:path');
33

44
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
55
if (require('electron-squirrel-startup')) {
@@ -26,7 +26,17 @@ const createWindow = () => {
2626
// This method will be called when Electron has finished
2727
// initialization and is ready to create browser windows.
2828
// Some APIs can only be used after this event occurs.
29-
app.on('ready', createWindow);
29+
app.whenReady().then(() => {
30+
createWindow();
31+
32+
// On OS X it's common to re-create a window in the app when the
33+
// dock icon is clicked and there are no other windows open.
34+
app.on('activate', () => {
35+
if (BrowserWindow.getAllWindows().length === 0) {
36+
createWindow();
37+
}
38+
});
39+
});
3040

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

40-
app.on('activate', () => {
41-
// On OS X it's common to re-create a window in the app when the
42-
// dock icon is clicked and there are no other windows open.
43-
if (BrowserWindow.getAllWindows().length === 0) {
44-
createWindow();
45-
}
46-
});
47-
4850
// In this file you can include the rest of your app's specific main process
4951
// code. You can also put them in separate files and import them here.

0 commit comments

Comments
 (0)