fin control panel
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user