提交 4bfa8921 authored 作者: zyx's avatar zyx

以json结构的方式完整上传并快速提交

上级 45219f6a
...@@ -25,7 +25,13 @@ const setTable = (req, res) => { ...@@ -25,7 +25,13 @@ const setTable = (req, res) => {
return return
} }
let _json = JSON.parse(fs.readFileSync(path1).toString() || '{}') let _json = JSON.parse(fs.readFileSync(path1).toString() || '{}')
if (req.body.chapterId) {
_json[req.body.chapterId] = req.body.url _json[req.body.chapterId] = req.body.url
} else {
for (let k in req.body) {
_json[k] = req.body[k]
}
}
fs.writeFileSync(path1, JSON.stringify(_json), 'utf8') fs.writeFileSync(path1, JSON.stringify(_json), 'utf8')
res.status(200).json(_json) res.status(200).json(_json)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论