Skip to content

Commit 64fddf1

Browse files
committed
merge client and server
1 parent 4433cb6 commit 64fddf1

File tree

18 files changed

+107
-242
lines changed

18 files changed

+107
-242
lines changed

build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ logger.info('Building...');
1414
splitting: false,
1515
write: false,
1616
minify: true,
17-
entryPoints: [path.resolve(process.cwd(), 'entry.ts')],
17+
entryPoints: [path.resolve(process.cwd(), 'packages/server/index.ts')],
1818
loader: {
1919
'.frontend': 'base64',
2020
'.ttf': 'base64',

entry.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/client/fetcher.ts

Whitespace-only changes.

packages/client/index.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/client/init.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

packages/client/interface.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/client/package.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/client/utils.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.
File renamed without changes.

packages/client/balloon.ts renamed to packages/server/client/balloon.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
11
import path from 'path';
2+
import EscPosEncoder from '@freedom_sky/esc-pos-encoder';
23
import superagent from 'superagent';
4+
import { config } from '../config';
35
import {
4-
fs, Logger, receiptText, sleep,
5-
} from './utils';
6+
fs, Logger, sleep,
7+
} from '../utils';
8+
9+
const encoder = new EscPosEncoder();
10+
11+
export const receiptText = (
12+
id: number, location: string, problem: string, color: string, comment: string, teamname: string, status: string,
13+
) => encoder
14+
.initialize()
15+
.codepage('cp936')
16+
.setPinterType(80) // wrong typo in the library
17+
.align('center')
18+
.bold(true)
19+
.size(2)
20+
.line('气球打印单')
21+
.emptyLine(1)
22+
.line(`ID: ${id}`)
23+
.emptyLine(1)
24+
.bold(false)
25+
.size(1)
26+
.line('===========================================')
27+
.emptyLine(1)
28+
.oneLine('座位', location)
29+
.oneLine('气球', problem)
30+
.oneLine('颜色', color)
31+
.oneLine('备注', comment)
32+
.emptyLine(1)
33+
.align('center')
34+
.bold(true)
35+
.line('===========================================')
36+
.emptyLine(2)
37+
.size(0)
38+
.line(`队伍: ${teamname}`)
39+
.line('队伍当前气球状态:')
40+
.line(`${status}`)
41+
.emptyLine(2)
42+
.line('Powered by hydro-dev/xcpc-tools')
43+
.emptyLine(3)
44+
.cut()
45+
.encode();
646

747
const logger = new Logger('fetcher');
848

@@ -46,11 +86,6 @@ async function fetchTask(c) {
4686
}
4787

4888
export async function apply() {
49-
const { config } = global.Tools;
50-
if (!config) {
51-
logger.error('config not found');
52-
return;
53-
}
5489
printer = config.balloon;
5590
if (config.token && config.server && config.balloon) await fetchTask(config);
5691
}

0 commit comments

Comments
 (0)