window.js 916 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const config = require('../config');
  2. const { BrowserWindow } = require('electron');
  3. const window = {};
  4. window.new = function (file, width, height) {
  5. // Default values
  6. width = width ? width : config.window.width;
  7. height = height ? height : config.window.height;
  8. // New window
  9. const win = new BrowserWindow ({
  10. width: width,
  11. height: height,
  12. webPreferences: {
  13. nodeIntegration: true
  14. }
  15. });
  16. win.loadFile(file);
  17. return win;
  18. }
  19. window.simple = function (file, width, height) {
  20. // Default values
  21. width = width ? width : config.window.width;
  22. height = height ? height : config.window.height;
  23. // New window
  24. const win = new BrowserWindow ({
  25. width: width,
  26. height: height,
  27. webPreferences: {
  28. nodeIntegration: false
  29. }
  30. });
  31. win.loadFile(file);
  32. return win;
  33. }
  34. module.exports = window;