To run a local app, execute the following on the command line:

electron 应用,电脑重启后,展示此窗口

To run a local app, execute the following on the command line:

image.png

原因是开发环境也设置了,开机自动启动应用

解决方法

import path from "path";
const appFolder = path.dirname(process.execPath);
const updateExe = path.resolve(appFolder, "..", "Update.exe");
const exeName = path.basename(process.execPath);

const isDevelopment = process.env.NODE_ENV !== "production";

app.on("ready", async () => {
  if (!isDevelopment) launchAtStartup();
}

function launchAtStartup() {
  if (process.platform === "darwin") {
    app.setLoginItemSettings({
      openAtLogin: true,
      openAsHidden: true
    });
  } else {
    app.setLoginItemSettings({
      openAtLogin: true,
      openAsHidden: true,
      path: updateExe,
      args: [
        "--processStart",
        `"${exeName}"`,
        "--process-start-args",
        `"--hidden"`
      ]
    });
  }
}

下面这个地址有答案:

https://stackoverflow.com/questions/60774286/electron-app-auto-launch-shows-an-additional-window-due-to-incorrect-app-path

你可能感兴趣的:(To run a local app, execute the following on the command line:)