- electron-builder 版本: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设置
"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"
}
},
关于至少我如何指定提取路径或将其提取为执行文件夹的任何想法?
顺便说一句,我已经创建了一个 issue关于这个在 electron-builder 仓库中
最佳答案
在 20.40.1
版本中,他们添加了一个新的配置 key 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 .
关于javascript - 可移植 Electron 应用程序每次打开时都被提取到不同的文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50436934/