fin control panel

This commit is contained in:
Jay
2017-09-14 15:55:10 +08:00
parent 0aad260946
commit 0ff6508d2f
5 changed files with 67 additions and 22 deletions
+4
View File
@@ -65,6 +65,8 @@ router.post('/api/print', KoaBody(), async (c, n) => {
c.async = true
let arr = c.request.body
if (!arr.data) throw 'print data empty'
if (config.api.secret && !arr.key) throw 'access key enpty'
if (config.api.secret !== arr.key.trim()) throw 'access key error'
let status = await Printer.printerString(arr.data)
@@ -117,6 +119,8 @@ router.post('/api/print', KoaBody(), async (c, n) => {
json.printer.serial = arr.tty
json.printer.feed = feed
json.api.secret = arr.secret || ''
let wconfig = await new Promise((resolve, reject) => {
fs.writeFile(path.resolve(process.env.PROJECT_ROOT, 'config.json'), JSON.stringify(json, null, 2), {
mode: 0o664,