Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy committed Jun 14, 2024
1 parent 487be1c commit 0df2517
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/server/client/balloon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -54,7 +54,7 @@ export const receiptText = (
.emptyLine(1)
.align('center')
.bold(true)
.line('===========================================')
.line('================================')
.emptyLine(2)
.size(0)
.line(`${i18n[lang].team}: ${teamname}`)
Expand All @@ -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',
Expand All @@ -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.`);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ password:
server: '',
balloon: '',
balloonLang: 'zh',
balloonType: 80,
printers,
token: '',
});
Expand Down Expand Up @@ -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([]),
Expand Down

0 comments on commit 0df2517

Please sign in to comment.