electronStart.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const { app, BrowserWindow } = require("electron");
  2. // Keep a global reference of the window object, if you don't, the window will
  3. // be closed automatically when the JavaScript object is garbage collected.
  4. let win;
  5. function createWindow() {
  6. // Create the browser window.
  7. win = new BrowserWindow({
  8. width: 1000,
  9. height: 720,
  10. webPreferences: {
  11. preload: require("path").join(__dirname, "faceSetMysql.js"),
  12. },
  13. });
  14. // and load the index.html of the app.
  15. win.loadURL("http://localhost:8080");
  16. // Open the DevTools.
  17. // win.webContents.openDevTools();
  18. // Emitted when the window is closed.
  19. win.on("closed", () => {
  20. // Dereference the window object, usually you would store windows
  21. // in an array if your app supports multi windows, this is the time
  22. // when you should delete the corresponding element.
  23. win = null;
  24. });
  25. }
  26. // This method will be called when Electron has finished
  27. // initialization and is ready to create browser windows.
  28. // Some APIs can only be used after this event occurs.
  29. app.on("ready", createWindow);
  30. // Quit when all windows are closed.
  31. app.on("window-all-closed", () => {
  32. // On macOS it is common for applications and their menu bar
  33. // to stay active until the user quits explicitly with Cmd + Q
  34. if (process.platform !== "darwin") {
  35. app.quit();
  36. }
  37. });
  38. app.on("activate", () => {
  39. // On macOS it's common to re-create a window in the app when the
  40. // dock icon is clicked and there are no other windows open.
  41. if (win === null) {
  42. createWindow();
  43. }
  44. });
  45. // In this file you can include the rest of your app's specific main process
  46. // code. You can also put them in separate files and require them here.