59e51671
“wangming”
1
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import { buildEscPosLabelData, buildEscPosTestPrintData } from '../protocols/escPosBuilder'
import type { PrinterCandidate, PrinterDriver } from '../types/printer'
const KEYWORDS = [
'gp-r3',
'gp r3',
'gpr3',
]
function score (device: PrinterCandidate): number {
const text = `${device.name || ''} ${device.deviceId || ''}`.toLowerCase()
let total = 0
KEYWORDS.forEach((keyword) => {
if (text.includes(keyword)) total += 60
})
if (text.includes('gprinter')) total += 10
return total
}
export const gpR3Driver: PrinterDriver = {
key: 'gp-r3',
brand: 'Gprinter',
model: 'GP-R3',
displayName: 'Gprinter GP-R3',
protocol: 'esc',
preferredConnection: 'classic',
preferredBleMtu: 20,
imageMaxWidthDots: 384,
imageDpi: 203,
keywords: KEYWORDS,
matches (device) {
return score(device)
},
resolveConnectionType (device) {
if (device.type === 'ble') return 'ble'
return 'classic'
},
buildTestPrintData () {
return buildEscPosTestPrintData()
},
buildLabelData (payload) {
return buildEscPosLabelData(payload)
},
}
|