Skip to content

Commit 0df2517

Browse files
committed
fix
1 parent 487be1c commit 0df2517

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/server/client/balloon.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const receiptText = (
3535
) => encoder
3636
.initialize()
3737
.codepage('cp936')
38-
.setPinterType(80) // wrong typo in the library
38+
.setPinterType(config.balloonType ?? 80) // wrong typo in the library
3939
.align('center')
4040
.bold(true)
4141
.size(2)
@@ -45,7 +45,7 @@ export const receiptText = (
4545
.emptyLine(1)
4646
.bold(false)
4747
.size(1)
48-
.line('===========================================')
48+
.line('===============================')
4949
.emptyLine(1)
5050
.oneLine(i18n[lang].location, location)
5151
.oneLine(i18n[lang].problem, problem)
@@ -54,7 +54,7 @@ export const receiptText = (
5454
.emptyLine(1)
5555
.align('center')
5656
.bold(true)
57-
.line('===========================================')
57+
.line('================================')
5858
.emptyLine(2)
5959
.size(0)
6060
.line(`${i18n[lang].team}: ${teamname}`)
@@ -76,7 +76,7 @@ async function printBalloon(doc, lang) {
7676
doc.balloonid,
7777
doc.location ? doc.location : 'N/A',
7878
doc.problem,
79-
lang === 'zh' ? convertToChinese(doc.contestproblem.color) : doc.contestproblem.color,
79+
lang === 'zh' ? await convertToChinese(doc.contestproblem.color) : doc.contestproblem.color,
8080
doc.awards ? doc.awards : 'N/A',
8181
doc.team,
8282
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) {
9494
if (body.balloons) {
9595
for (const doc of body.balloons) {
9696
logger.info(`Print balloon task ${doc.teamid}#${doc.balloonid}...`);
97-
await printBalloon(doc, config.receiptLang);
97+
await printBalloon(doc, config.balloonLang);
9898
await post(`${c.server}/client/${c.token}/doneballoon/${doc.balloonid}`);
9999
logger.info(`Print task ${doc.teamid}#${doc.balloonid} completed.`);
100100
}

packages/server/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ password:
4040
server: '',
4141
balloon: '',
4242
balloonLang: 'zh',
43+
balloonType: 80,
4344
printers,
4445
token: '',
4546
});
@@ -84,6 +85,7 @@ const clientSchema = Schema.object({
8485
server: Schema.string().role('url').required(),
8586
balloon: Schema.string(),
8687
balloonLang: Schema.union(['zh', 'en']).default('zh').required(),
88+
balloonType: Schema.union([58, 80]).default(80),
8789
printers: Schema.array(Schema.string()).default([]).description('printer id list, will disable printing if unset'),
8890
token: Schema.string().required().description('Token generated on server'),
8991
fonts: Schema.array(Schema.string()).default([]),

0 commit comments

Comments
 (0)