为什么我的文件未添加到适应性(电子应用)中

发布于 2025-02-04 23:08:57 字数 858 浏览 1 评论 0 原文

我有一个电子应用程序,该应用程序使用以下代码打开的数据库:

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位于同一文件夹中。 从我的应用程序的根目录启动时,一切都很好。

如果我从其他地方运行应用程序映像,则在查询数据库时会有一个例外,实际上,数据库文件未显示在文件层次结构中。 我不能在这里发布图像,但是您可以在 我做错了什么? 感谢您的帮助。

I have an electron app which uses a database opened with the following code:

const fs = require("fs")
const sqlite = require("aa-sqlite")
await sqlite.open('cregr_db.db');

My package.json contains :

  "build": {
    "appId": "crergr",
    "linux": {
      "target": [
        "AppImage"
      ],
      "icon": "icon512.png"
    },
    "win": {
      "target": "NSIS",
      "icon": "icon256.ico"
    },
    "extraFiles": [
      "cregr_db.db"
    ]
  },

the cregr_db.db is in the same folder as my *js, index.html and style.css.
Everything runs fine when launched from the root directory of my app.

If I run the app image from elsewhere, I have an exception when I query the database and, in fact, the database file is not displayed in the file hierarchy.
I can not post an image here but you can find one at http://alainbe.free.fr/files.png
What I am doing wrong ?
Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2025-02-11 23:08:57

实际上,可能添加了数据库文件,但在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文