Blame view

泰额版/Food Labeling Management App UniApp/src/utils/print/drivers/d320fax.ts 1005 Bytes
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
  import { buildTscLabelData, buildTscTestPrintData } from '../protocols/tscProtocol'
  import type { PrinterCandidate, PrinterDriver } from '../types/printer'
  
  const KEYWORDS = [
    'd320fax',
    'virtual bt printer',
    'gp-d320fax',
  ]
  
  function score (device: PrinterCandidate): number {
    const text = `${device.name || ''} ${device.deviceId || ''}`.toLowerCase()
    let total = 0
    KEYWORDS.forEach((keyword) => {
      if (text.includes(keyword)) total += 40
    })
    return total
  }
  
  export const d320faxDriver: PrinterDriver = {
    key: 'd320fax',
    brand: 'Gprinter',
    model: 'D320FAX',
    displayName: 'Gprinter D320FAX',
    protocol: 'tsc',
    preferredConnection: 'classic',
    preferredBleMtu: 20,
    imageMaxWidthDots: 800,
    imageDpi: 203,
    keywords: KEYWORDS,
    matches (device) {
      return score(device)
    },
    resolveConnectionType () {
      return 'classic'
    },
    buildTestPrintData () {
      return buildTscTestPrintData()
    },
    buildLabelData (payload) {
      return buildTscLabelData(payload)
    },
  }