32 lines
623 B
JavaScript
32 lines
623 B
JavaScript
const Router = require("koa-router")
|
|
const config = require("../util/config/config")
|
|
const router = new Router({
|
|
prefix: "/config"
|
|
})
|
|
|
|
/**
|
|
* 获取配置文件接口
|
|
*/
|
|
router.get('/getConfig', async (ctx) => {
|
|
let json = config.getConfig();
|
|
const b = json === '{}'
|
|
|
|
return {
|
|
code: b ? -1 : 0,
|
|
msg: b ? 'ok' : "error",
|
|
data: json
|
|
}
|
|
})
|
|
/**
|
|
* 设置配置文件接口
|
|
*/
|
|
router.get('/setConfig', async (ctx) => {
|
|
let b = config.setConfig(ctx.data);
|
|
return {
|
|
code: b ? -1 : 0,
|
|
msg: b ? 'ok' : "error",
|
|
data: null
|
|
}
|
|
})
|
|
|
|
module.exports = router |