ref: 项目基础开发

This commit is contained in:
muwoo
2021-06-08 10:06:40 +08:00
parent d9c0f5ed7b
commit 02d9c30bc9
13 changed files with 483 additions and 132 deletions

21
src/main/common/utils.js Normal file
View File

@@ -0,0 +1,21 @@
import fs from "fs";
export const getlocalDataFile = () => {
let localDataFile = process.env.HOME;
if (!localDataFile) {
localDataFile = process.env.LOCALAPPDATA;
}
return localDataFile;
};
export function saveData(path, value) {
fs.writeFileSync(path, JSON.stringify(value));
}
export function getData(path, defaultValue) {
try {
return JSON.parse(fs.readFileSync(path, 'utf8'));
} catch (e) {
return defaultValue || undefined;
}
}