Created
February 21, 2016 12:01
-
-
Save KimuraTakaumi/b317b4133fed996cdb79 to your computer and use it in GitHub Desktop.
Electronで設定ファイルを保存する ref: http://qiita.com/KimuraTakaumi/items/fcae3fb9ca62143a00b4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install --save electron-json-storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const storage = require('electron-json-storage'); | |
storage.get('config', function (error, data) { | |
if (error) throw error; | |
if (Object.keys(data).length === 0) { | |
// データがないときの処理 | |
} else { | |
// データがあるときの処理 | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var json = { | |
user: 'hoge' | |
}; | |
storage.set('config', json, function (error) { | |
if (error) throw error; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment