为什么我的文件未添加到适应性(电子应用)中
我有一个电子应用程序,该应用程序使用以下代码打开的数据库:
const fs = require("fs")
const sqlite = require("aa-sqlite")
await sqlite.open('cregr_db.db');
我的package.json包含:
"build": {
"appId": "crergr",
"linux": {
"target": [
"AppImage"
],
"icon": "icon512.png"
},
"win": {
"target": "NSIS",
"icon": "icon256.ico"
},
"extraFiles": [
"cregr_db.db"
]
},
cregr_db.db与我的 *js,index.html和style.css位于同一文件夹中。 从我的应用程序的根目录启动时,一切都很好。
如果我从其他地方运行应用程序映像,则在查询数据库时会有一个例外,实际上,数据库文件未显示在文件层次结构中。 我不能在这里发布图像,但是您可以在 我做错了什么? 感谢您的帮助。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,可能添加了数据库文件,但在ASAR存档中,因此无法通过上面发布的代码读取。
我选择的解决方案是在不构建ASAR存档的情况下分发该应用程序,在这种情况下,一切都与您正在测试应用程序(在Linux和Windows上测试)一样工作。
关于没有ASAR的应用程序,有很大的警告。我选择不关注,因为有任何方法可以解开ASAR并查看代码,此外,我的应用程序是GPLED的。
In fact, the db file was probably added but in an ASAR archive so can't be read by the code posted above.
The solution I chose was to distribute the app without building an ASAR archive and in this case, everything works exactly like you are testing your app (tested on Linux and Windows).
There is a strong warning about building an app without an ASAR. I chose not to pay attention because any way there are ways to unpack the ASAR and see the code and besides, my app is GPL'ed.