我想为我的 electron.js 应用程序保存用户数据。该应用程序有一个带有可调值的图表,重新启动该应用程序时该图表会消失。演示: https://puu.sh/Bx5Or/ffb0382d0c.gif
如何保留这些值?可以(并且应该)使用 SQL 完成吗?
最佳答案
在 Electron 应用程序中有很多模块可以存储数据:
- http://lokijs.org
- https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
- https://github.com/agershun/alasql
- https://github.com/amark/gun
- https://github.com/google/leveldb
- https://github.com/google/lovefield
- https://github.com/jakearchibald/idb
- https://github.com/jakearchibald/idb-keyval
- https://github.com/sql-js/sql.js
- https://github.com/localForage/localForage
- https://github.com/louischatriot/nedb
- https://github.com/pouchdb/pouchdb
- https://github.com/pubkey/rxdb
- https://github.com/typicode/lowdb
- https://github.com/w3c/IndexedDB
- https://github.com/yathit/ydn-db
- https://github.com/TomPrograms/stormdb
我建议使用纯 JS 和跨平台兼容的 nedb。 最简单的是 localStorage,它是浏览器原生的。 或者更简单地说,您可以在 JSON 文件中读取/写入数据。
因此,在您的情况下,当值更改时,保存数据。 开始时,从数据库中获取它们并将它们放入您的可调整值中。
关于sql - 如何在 electron.js 应用程序中保存用户数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52392094/