settingwin.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { LOAD_URL } from "./../config";
  2. import { app, Menu, ipcMain } from 'electron'
  3. const isdev = process.env.NODE_ENV == "development"
  4. const loadURL = isdev
  5. ? `${process.env.WEBPACK_DEV_SERVER_URL}#/settingwin`
  6. : `${LOAD_URL}#settingwin`;
  7. const iconSrc = __static + "/images/icon.ico";
  8. // console.log(loadURL)
  9. let settingWindow = null;
  10. const createSettingwin = function (BrowserWindow) {
  11. if (settingWindow !== null) {
  12. return false
  13. }
  14. let obj = {
  15. title: '星空路人-设置',
  16. icon: iconSrc,
  17. height: 160,
  18. width: 300,
  19. show: true,
  20. titleBarStyle: "hiddenInset",
  21. frame: true,
  22. fullscreenable: false,
  23. minimizable: false,
  24. maximizable: false,
  25. transparent: false,
  26. skipTaskbar: false, // 任务栏中不显示窗口
  27. closable: true,
  28. autoHideMenuBar: true,
  29. enableLargerThanScreen: false,
  30. resizable: isdev,
  31. // transparent: process.platform !== "linux",
  32. hasShadow: process.platform !== "darwin",
  33. alwaysOnTop: true,
  34. webPreferences: {
  35. devTools: false,
  36. contextIsolation: false,
  37. sandbox: false,
  38. nodeIntegration: true,
  39. enableRemoteModule: true,
  40. }
  41. };
  42. settingWindow = new BrowserWindow(obj);
  43. Menu.setApplicationMenu(null)
  44. settingWindow.loadURL(loadURL);
  45. if (process.env.WEBPACK_DEV_SERVER_URL) {
  46. settingWindow.webContents.openDevTools();
  47. }
  48. settingWindow.on("close", () => {
  49. settingWindow = null;
  50. });
  51. ipcMain.on("window-reset", () => {
  52. if (!isdev) {
  53. app.relaunch()
  54. app.exit()
  55. }
  56. });
  57. // return settingWindow;
  58. };
  59. export default createSettingwin;