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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。