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
975 B

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