利用electron-store持久化用户数据
发布日期:2021-07-01 05:17:38
浏览次数:2
分类:技术文章
本文共 746 字,大约阅读时间需要 2 分钟。
Electron没有内置的方法来持久保存用户首选项和其他数据。使用electron-store
模块可以帮助完成上述需求,专注于构建应用程序。数据保存在JSON文件中app.getPath(‘userData’)。
GitHub地址:https://github.com/sindresorhus/electron-store
安装
$ npm install electron-store --save
使用
const Store = require('electron-store');const store = new Store();store.set('unicorn', '?');console.log(store.get('unicorn'));//=> '?'// Use dot-notation to access nested propertiesstore.set('foo.bar', true);console.log(store.get('foo'));//=> {bar: true}store.delete('unicorn');console.log(store.get('unicorn'));//=> undefined
保存位置
The data is saved in a JSON file in $ app.getPath('userData')
.
console.log(app.getPath('userData'));//=> C:\Users\xxx\AppData\Roaming\electron-quick-start
打开该路径下config.json文件
{ "foo": { "bar": true }}
转载地址:https://onefine.blog.csdn.net/article/details/100081418 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.240.166.169]2024年05月02日 10时23分16秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Vue 解决跨域问题
2019-05-04
C++的文件操作
2019-05-04
读『开发App常见的九大错误』
2019-05-04
Manifest merger ignores tools:replace when both android:name and tools:ignore are present on applic
2019-05-04
Dump Fragment
2019-05-04
Freeline - Android平台上的秒级编译方案
2019-05-04
美股课堂:美国银行开户亲历记
2019-05-05
逆生长_百度百科
2019-05-05
李光荣_百度百科
2019-05-05
qrcode 4.0.4 : Python Package Index
2019-05-05
首问负责制,综合时薪,标准工时
2019-05-05
众投天地_百度百科
2019-05-05
误读善泳者溺的古训,害人不浅_泳者无涤_新浪博客
2019-05-05
“秀才造反,十年不成”是什么意思? - 已解决 - 搜搜问问
2019-05-05
服装配饰_MAVIN MARVY 高级服装定制_西服定制_衬衫定制_西装定制
2019-05-05
探索者系列_百度百科
2019-05-05
第九课堂-经验与技能分享交易网站
2019-05-05
北京西服定做_衬衫定制_关于我们_Dimoon TLR.
2019-05-05