()
| 688 | }); |
| 689 | }; |
| 690 | const createMainWin = () => { |
| 691 | const isMainWindVisible = isWindowPartiallyVisible({ |
| 692 | width: parseInt(store.get("mainWinWidth") || 1050) / mainWinDisplayScale, |
| 693 | height: parseInt(store.get("mainWinHeight") || 660) / mainWinDisplayScale, |
| 694 | x: parseInt(store.get("mainWinX")), |
| 695 | y: parseInt(store.get("mainWinY")), |
| 696 | }); |
| 697 | if (!isMainWindVisible) { |
| 698 | delete options.x; |
| 699 | delete options.y; |
| 700 | } |
| 701 | mainWin = new BrowserWindow(options); |
| 702 | if (store.get("isAlwaysOnTop") === "yes") { |
| 703 | mainWin.setAlwaysOnTop(true); |
| 704 | } |
| 705 | if (store.get("isAutoMaximizeWin") === "yes") { |
| 706 | mainWin.maximize(); |
| 707 | } |
| 708 | |
| 709 | if (!isDev) { |
| 710 | Menu.setApplicationMenu(null); |
| 711 | } |
| 712 | |
| 713 | const urlLocation = isDev |
| 714 | ? "http://localhost:3000" |
| 715 | : `file://${path.join(__dirname, "./build/index.html")}`; |
| 716 | mainWin.loadURL(urlLocation); |
| 717 | // Handle deep link on cold start: wait for renderer to mount its IPC listeners |
| 718 | mainWin.webContents.once("did-finish-load", () => { |
| 719 | if (pendingDeepLink) { |
| 720 | const link = pendingDeepLink; |
| 721 | pendingDeepLink = null; |
| 722 | // Give React time to register ipcRenderer listeners before dispatching |
| 723 | setTimeout(() => handleCallback(link), 1500); |
| 724 | } |
| 725 | }); |
| 726 | mainWin.on("close", (event) => { |
| 727 | if (!isQuitting && store.get("isMinimizeToTray") === "yes") { |
| 728 | event.preventDefault(); |
| 729 | mainWin.hide(); |
| 730 | if (!tray) { |
| 731 | createTray(); |
| 732 | } |
| 733 | return; |
| 734 | } |
| 735 | if (mainWin && !mainWin.isDestroyed()) { |
| 736 | let bounds = mainWin.getBounds(); |
| 737 | const currentDisplay = screen.getDisplayMatching(bounds); |
| 738 | const primaryDisplay = screen.getPrimaryDisplay(); |
| 739 | if (bounds.width > 300 && bounds.height > 100) { |
| 740 | store.set({ |
| 741 | mainWinWidth: bounds.width, |
| 742 | mainWinHeight: bounds.height, |
| 743 | mainWinX: mainWin.isMaximized() ? 0 : bounds.x, |
| 744 | mainWinY: mainWin.isMaximized() ? 0 : bounds.y, |
| 745 | mainWinDisplayScale: |
| 746 | currentDisplay.scaleFactor / primaryDisplay.scaleFactor, |
| 747 | }); |
no test coverage detected