12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { app, BrowserWindow } from "electron";
- import { createWindow, mainWindow } from "../win/mainWin";
- import { initIpcMain } from "./ipcMain";
- import { initTray } from "./tray";
- import { initExpress } from "./express";
- (process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] as unknown) = true;
- if (!app.requestSingleInstanceLock()) {
- app.quit();
- process.exit(0);
- } else {
- app.on("second-instance", (event, commandLine, workingDirectory) => {
- if (mainWindow) {
- if (mainWindow.isMinimized()) mainWindow.restore();
- mainWindow.show();
- mainWindow.focus();
- }
- });
- }
- app.whenReady().then(() => {
- AtLogin();
- createWindow();
- initTray();
- initExpress();
- });
- const AtLogin = async () => {
- if (app.isPackaged) {
-
- app.setLoginItemSettings({
- openAtLogin: true,
- path: app.getPath("exe"),
- args: ["--openAsHidden"],
- });
- }
- };
- app.on("activate", function () {
-
-
-
- console.log("activate=====>");
- const allWindows = BrowserWindow.getAllWindows();
- if (!allWindows.length) {
- createWindow();
- }
- });
- app.on("window-all-closed", function () {
-
- if (process.platform !== "darwin") app.quit();
- });
- initIpcMain();
|