加入WebAPI
1.PrinterDev add EventEmitter 2.add Printer WebAPI
This commit is contained in:
@@ -37,4 +37,16 @@ router.get('/', async (c, n) => {
|
||||
await c.render('dashboard/index', c.data)
|
||||
})
|
||||
|
||||
router.post('/api/print', KoaBody(), async (c, n) => {
|
||||
c.async = true
|
||||
let arr = c.request.body
|
||||
if (!arr.data) throw 'print data empty'
|
||||
|
||||
let status = await Printer.printerString(arr.data)
|
||||
|
||||
if (!status) throw 'printer fail'
|
||||
|
||||
c.body = 'print success'
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
||||
Reference in New Issue
Block a user