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.
 
 
 

33 lines
975 B

// const Store = require('electron-store');
// const store = new Store();//
const path = require("path")
const data_path = path.join(__dirname, './data.json');
const fs = require("fs")
class Store {
constructor(){
// fs.writeFileSync(data_path,JSON.stringify({}))
}
set(key, param) {
// let saveData = {key:param};
// console.log("------",key,param);
let oldData = require(data_path);
oldData[key] = param;
// console.log('======',JSON.stringify(oldData),data_path);
fs.writeFileSync(data_path,JSON.stringify(oldData))
}
get(key){
const data = JSON.parse(fs.readFileSync(data_path,'utf-8'));
// console.log('get>>>>>>>>>',data[key],data_path)
return data[key];
}
delete(key){
let oldData = require(data_path);
delete oldData[key];
fs.writeFileSync(data_path,JSON.stringify(oldData))
}
}
const store = new Store();
module.exports = store