【问题标题】:Portable electron app is extracted in a different folder every time it opens便携式电子应用程序每次打开时都会提取到不同的文件夹中
【发布时间】:2018-10-30 09:46:11
【问题描述】:
  • 电子生成器版本:20.9.2
  • 目标:windows/portable

我正在使用electron-builder 构建一个便携式应用程序,并使用socket.io 保持与后端服务的实时连接,但我遇到了防火墙问题。因为这是一个便携式应用程序,每次打开应用程序时,它看起来都被提取到临时文件夹中,这将在每次运行时生成一个新文件夹(因此应用程序的路径将不同),这将使防火墙认为这是另一个要求连接权限的应用程序。运行应用时如何更改提取路径?

(这是我每次运行应用程序时看到的屏幕)

这是我的 socket.io 配置

const io = require("socket.io")(6524);

io.on("connect", socket => {
    socket.on("notification", data => {
       EventBus.$emit("notifications", JSON.parse(data));
   });
});

我在package.json中的构建设置

"build": {
    "productName": "xxx",
    "appId": "xxx.xxx.xxx",
    "directories": {
        "output": "build"
    },
    "files": [
        "dist/electron/**/*",
        "!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme,test,__tests__,tests,powered-test,example,examples,*.d.ts}",
        "!**/node_modules/.bin",
        "!**/*.{o,hprof,orig,pyc,pyo,rbc}",
        "!**/._*",
        "!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.editorconfig,.flowconfig,.yarn-metadata.json,.idea,appveyor.yml,.travis.yml,circle.yml,npm-debug.log,.nyc_output,yarn.lock,.yarn-integrity}",
        "!**/node_modules/search-index/si${/*}"
    ],
    "win": {
        "icon": "build/icons/myicon.ico",
        "target": "portable"
    }
},

知道我至少可以如何指定提取路径或将其提取为执行文件夹吗?


顺便说一句,我已经在 electron-builder repo 中创建了一个 issue 与此有关

【问题讨论】:

  • 你有没有设法解决这个问题?我们遇到了完全相同的问题。
  • @AleksandarGrbic 不,由于这个问题,我们不得不摆脱便携式构建。

标签: javascript socket.io electron firewall electron-builder


【解决方案1】:

20.40.1 版本中,他们添加了一个新的配置密钥 unpackDirName

/**
   * The unpack directory name in [TEMP](https://www.askvg.com/where-does-windows-store-temporary-files-and-how-to-change-temp-folder-location/) directory.
   *
   * Defaults to [uuid](https://github.com/segmentio/ksuid) of build (changed on each build of portable executable).
   */
  readonly unpackDirName?: string

例子

config: {
  portable: {
    unpackDirName: "0ujssxh0cECutqzMgbtXSGnjorm",
  }
}

更多信息#3799.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-09
    • 1970-01-01
    • 1970-01-01
    • 2012-09-28
    • 2020-12-17
    • 2021-07-05
    • 1970-01-01
    相关资源
    最近更新 更多