fix 配置接口请求失效

This commit is contained in:
2023-08-01 14:18:44 +08:00
parent a0d7b9b17f
commit e4151b94ed
3 changed files with 26 additions and 12 deletions

View File

@@ -11,22 +11,35 @@ router.get('/getConfig', async (ctx) => {
let json = config.getConfig();
const b = json === '{}'
return {
ctx.body = {
code: b ? -1 : 0,
msg: b ? 'ok' : "error",
msg: b ? 'error' : "ok",
data: json
}
})
/**
* 设置配置文件接口
*/
router.get('/setConfig', async (ctx) => {
let b = config.setConfig(ctx.data);
return {
code: b ? -1 : 0,
msg: b ? 'ok' : "error",
data: null
}
router.post('/setConfig', async (ctx) => {
let body = ctx.request.body;
console.info(body)
// if (body === "") {
// ctx.body = {
// code: -1,
// msg: "提交内容不能为空"
// }
// return
// }
//
// let b = config.setConfig(body);
// console.info(b)
// ctx.body = {
// code: b ? 0 : -1,
// msg: b ? 'ok' : "error",
// data: null
// }
})
module.exports = router