electron launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
891 B

4 years ago
  1. // const Store = require('electron-store');
  2. // const store = new Store();//
  3. const data_path = "./data.json";
  4. const fs = require("fs")
  5. class Store {
  6. constructor(){
  7. fs.writeFileSync(data_path,JSON.stringify({}))
  8. }
  9. set(key, param) {
  10. // let saveData = {key:param};
  11. console.log("------",key,param);
  12. let oldData = require('./data.json');
  13. oldData[key] = param;
  14. // console.log('======',oldData);
  15. fs.writeFileSync(data_path,JSON.stringify(oldData))
  16. }
  17. get(key){
  18. const data = JSON.parse(fs.readFileSync(data_path,'utf-8'));
  19. // console.log('get>>>>>>>>>',data[key])
  20. return data[key];
  21. }
  22. delete(key){
  23. let oldData = require('./data.json');
  24. delete oldData[key];
  25. fs.writeFileSync(data_path,JSON.stringify(oldData))
  26. }
  27. }
  28. const store = new Store();
  29. module.exports = store