From 0df25175d4a536d351fdd6da3bc6e55771857da9 Mon Sep 17 00:00:00 2001 From: panda Date: Fri, 14 Jun 2024 21:24:48 +0800 Subject: [PATCH] fix --- packages/server/client/balloon.ts | 10 +++++----- packages/server/config.ts | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/server/client/balloon.ts b/packages/server/client/balloon.ts index ffa0134..f6804d8 100644 --- a/packages/server/client/balloon.ts +++ b/packages/server/client/balloon.ts @@ -35,7 +35,7 @@ export const receiptText = ( ) => encoder .initialize() .codepage('cp936') - .setPinterType(80) // wrong typo in the library + .setPinterType(config.balloonType ?? 80) // wrong typo in the library .align('center') .bold(true) .size(2) @@ -45,7 +45,7 @@ export const receiptText = ( .emptyLine(1) .bold(false) .size(1) - .line('===========================================') + .line('===============================') .emptyLine(1) .oneLine(i18n[lang].location, location) .oneLine(i18n[lang].problem, problem) @@ -54,7 +54,7 @@ export const receiptText = ( .emptyLine(1) .align('center') .bold(true) - .line('===========================================') + .line('================================') .emptyLine(2) .size(0) .line(`${i18n[lang].team}: ${teamname}`) @@ -76,7 +76,7 @@ async function printBalloon(doc, lang) { doc.balloonid, doc.location ? doc.location : 'N/A', doc.problem, - lang === 'zh' ? convertToChinese(doc.contestproblem.color) : doc.contestproblem.color, + lang === 'zh' ? await convertToChinese(doc.contestproblem.color) : doc.contestproblem.color, doc.awards ? doc.awards : 'N/A', doc.team, doc.total ? Object.keys(doc.total).map((k) => `- ${k}: ${doc.total[k].color}`).join('\n') : 'N/A', @@ -94,7 +94,7 @@ async function fetchTask(c) { if (body.balloons) { for (const doc of body.balloons) { logger.info(`Print balloon task ${doc.teamid}#${doc.balloonid}...`); - await printBalloon(doc, config.receiptLang); + await printBalloon(doc, config.balloonLang); await post(`${c.server}/client/${c.token}/doneballoon/${doc.balloonid}`); logger.info(`Print task ${doc.teamid}#${doc.balloonid} completed.`); } diff --git a/packages/server/config.ts b/packages/server/config.ts index ae59c11..e95fa65 100644 --- a/packages/server/config.ts +++ b/packages/server/config.ts @@ -40,6 +40,7 @@ password: server: '', balloon: '', balloonLang: 'zh', + balloonType: 80, printers, token: '', }); @@ -84,6 +85,7 @@ const clientSchema = Schema.object({ server: Schema.string().role('url').required(), balloon: Schema.string(), balloonLang: Schema.union(['zh', 'en']).default('zh').required(), + balloonType: Schema.union([58, 80]).default(80), printers: Schema.array(Schema.string()).default([]).description('printer id list, will disable printing if unset'), token: Schema.string().required().description('Token generated on server'), fonts: Schema.array(Schema.string()).default([]),