modified: model/setu.js

This commit is contained in:
yeyang
2023-01-15 00:12:47 +08:00
parent 5bc7705bfe
commit 7f1a2b84bc
4 changed files with 110 additions and 186 deletions

View File

@@ -34,9 +34,7 @@ let Data = {
})
},
/*
* 读取json
* */
/**读取json */
readJSON(file = '', root = '') {
root = getRoot(root)
if (fs.existsSync(`${root}/${file}`)) {
@@ -49,15 +47,19 @@ let Data = {
return {}
},
/*
* 写JSON
* */
writeJSON(file, data, space = '\t', root = '') {
/**写JSON */
writeJSON(file, data, root = '', space = '\t') {
// 检查并创建目录
Data.createDir(file, root, true)
root = getRoot(root)
delete data._res
return fs.writeFileSync(`${root}/${file}`, JSON.stringify(data, null, space))
// delete data._res
try {
fs.writeFileSync(`${root}/${file}`, JSON.stringify(data, null, space))
return true
} catch (err) {
logger.error(err)
return false;
}
},
async getCacheJSON(key) {