我正在构建一个Electron应用程序,该应用程序仅在BrowserWindow中显示一个Web URL。我正在使用电子生成器将应用程序打包为.deb包和Snap。 .deb正常工作。但是,当我使用“ strict ”限制构建快照时,电子商店没有权限访问HOME目录中的config.json。
当我使用'经典'或' devmode '限制时,一切正常。
我尝试清除$ HOME / .config中的所有npm缓存和configStore文件。
main.js在发出调整大小和关闭事件时请求调用ElectronStore.set()
。那是错误出现的时候。
对应的 main.js 代码
mainWindow.on('close', function() {
conf.set('windowBounds', mainWindow.getBounds())
conf.set("lastLink", mainWindow.webContents.getURL())
})
构建说明,用于 package.json
中的电子生成器"build": {
"appId": "org.anuj.${name}",
"asar": true,
"copyright": "MIT ©2019 Anuj Datar",
"linux": {
"category": "Notes;Office;Productivity",
"packageCategory": "Notes;Office;Productivity",
"description": "OneNote Desktop Client for Linux",
"synopsis": "OneNote Desktop Client",
"icon": "./src/images/icon.icns",
"target": [
"deb",
"AppImage",
"snap"
],
"maintainer": "Anuj Datar <anuj.datar@gmail.com>",
"artifactName": "${name}-${version}-${arch}.${ext}"
},
"deb": {
"depends": [
"gconf2",
"gconf-service",
"libnotify4",
"libappindicator1",
"libxtst6",
"libnss3"
]
},
"snap": {
"confinement": "strict",
"grade": "stable"
},
"appImage": {
"license": "LICENSE.md"
}
}
}
窗口大小和上次访问的链接应该存储在config中,因此下次启动应用时可以恢复会话。相反,什么也没有保存,并且出现以下错误消息:
主要过程中发生了JavaScript错误
未捕获的异常:
错误:EPERM:不允许操作,chown '/home/anuj/snap/onenote-desktop/x1/.config/OneNote/config.json.1014786569'
- 在Object.chownSync(fs.js:1142:3)
- 在Function.writeFileSync [作为同步](/snap/onenote-desktop/x1/resources/app.asar/node_modules/write-file-atomic/index.js:196:27)
- 在ElectronStore.set商店[作为商店](/snap/onenote-desktop/x1/resources/app.asar/node_modules/conf/index.js:227:19)
- 在ElectronStore.set商店(/snap/onenote-desktop/x1/resources/app.asar/node_modules/conf/index.js:152:14)
- 在BrowseWindow上。
<anonymous>
(/snap/onenote-desktop/x1/resources/app.asar/src/main.js:44:10)- 在BrowserWindow.emit(events.js:194:13)
这里是Cameron