ZhangXianQiang
2024-06-13 6c34d8df858b0c795dd06da0962c22f9d1c40bd2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";
const { app, BrowserWindow, screen, globalShortcut, ipcMain } = require("electron");
const { join } = require("path");
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
const createWindow = (width, height) => {
  const win = new BrowserWindow({
    width,
    height,
    minWidth: 1280,
    minHeight: 720,
    webPreferences: {
      preload: join(__dirname, "preload.js")
    }
  });
  win.maximize();
  if (process.env.VITE_DEV_SERVER_URL) {
    win.loadURL(process.env.VITE_DEV_SERVER_URL);
    win.webContents.openDevTools();
  } else {
    win.loadFile(join(__dirname, "../dist/index.html"));
  }
};
app.whenReady().then(() => {
  const { width, height } = screen.getPrimaryDisplay().bounds;
  createWindow(width, height);
  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0)
      createWindow();
  });
  ipcMain.on("open-new-window", () => {
    const childWin = new BrowserWindow({
      width,
      height,
      minWidth: width,
      minHeight: height,
      webPreferences: {
        preload: join(__dirname, "preload.js")
      }
    });
    childWin.maximize();
    if (process.env.VITE_DEV_SERVER_URL) {
      childWin.loadURL(process.env.VITE_DEV_SERVER_URL + "#/meet");
    } else {
      childWin.loadFile(join(__dirname, "../dist/index.html"), {
        hash: "/meet"
      });
    }
  });
});
app.on("window-all-closed", () => {
  if (process.platform !== "darwin")
    app.quit();
});