Blame view

泰额版/Food Labeling Management App UniApp/src/utils/deviceInfo.ts 2.06 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  export interface DeviceIdentity {
    model: string
    brand: string
    manufacturer: string
    product: string
    device: string
    platform: string
  }
  
  let cachedDeviceIdentity: DeviceIdentity | null = null
  
  function safeText (value: unknown): string {
    return String(value || '').trim()
  }
  
  export function getDeviceIdentity (): DeviceIdentity {
    if (cachedDeviceIdentity) return cachedDeviceIdentity
  
    const info = (() => {
      try {
        return uni.getSystemInfoSync()
      } catch (_) {
        return {} as UniApp.GetSystemInfoResult
      }
    })()
  
    const identity: DeviceIdentity = {
      model: safeText((info as any).model),
      brand: safeText((info as any).brand),
      manufacturer: '',
      product: '',
      device: '',
      platform: safeText((info as any).platform),
    }
  
    // #ifdef APP-PLUS
    try {
      const Build = plus.android.importClass('android.os.Build')
      identity.model = safeText((Build as any).MODEL) || identity.model
      identity.brand = safeText((Build as any).BRAND) || identity.brand
      identity.manufacturer = safeText((Build as any).MANUFACTURER)
      identity.product = safeText((Build as any).PRODUCT)
      identity.device = safeText((Build as any).DEVICE)
    } catch (_) {}
    // #endif
  
    cachedDeviceIdentity = identity
    return identity
  }
  
  export function getDeviceFingerprint (): string {
    const identity = getDeviceIdentity()
    return [
      identity.brand,
      identity.manufacturer,
      identity.model,
      identity.product,
      identity.device,
    ]
      .filter(Boolean)
      .join(' | ')
      .toLowerCase()
  }
5a192b24   杨鑫   最新同步
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  
  /** Gprinter AOA 一体机(rk3568 / 型号含 AOA):走内置 UPOS/TCP,勿依赖外接蓝牙扫描 */
  export function isAoaAioDevice (): boolean {
    const identity = getDeviceIdentity()
    const fingerprint = getDeviceFingerprint()
    const blob = [
      identity.model,
      identity.product,
      identity.device,
      identity.brand,
      fingerprint,
    ]
      .map((s) => String(s || '').toLowerCase())
      .join(' ')
    if (!blob.trim()) return false
    return (
      blob.includes('aoa_rk3568')
      || blob.includes('rk3568')
      || /\baoa\b/.test(blob)
    )
  }