美文网首页
To run a local app, execute the

To run a local app, execute the

作者: 程序员李钟意 | 来源:发表于2020-08-13 01:48 被阅读0次

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

      本文链接:https://www.haomeiwen.com/subject/phbvdktx.html