ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
[TOC] ## 安装 `npm install -S electron-store` ## 配置设置 ``` const Store = require('electron-store'); let option={ name:"config",//文件名称,默认 config fileExtension:"json",//文件后缀,默认json cwd:app.getPath('userData'),//文件位置,尽量不要动 // encryptionKey:"aes-256-cbc" ,//对配置文件进行加密 clearInvalidConfig:true, // 发生 SyntaxError 则清空配置, } const store = new Store(option); ``` ## 方法 ### .set(key, value) ### .set(object) ### .get(key, [defaultValue]) ### .has(key) ### .delete(key) ### .clear() ### .onDidChange(key, callback) `callback: (newValue, oldValue) => {} ` ### .openInEditor() 用默认编辑器打开 配置文件 ## 属性 ### .size ### .store ### .path