bridge.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. interface HandSummary {
  2. chi: string;
  3. cun: string;
  4. guan: string;
  5. summary: string[];
  6. }
  7. type HandKeys = 'chen' | 'chi' | 'fu' | 'hua' | 'kong' | 'ruan' | 'shi' | 'shu' | 'xi' | 'xian';
  8. interface ScanData {
  9. code: string;
  10. state: number;
  11. type: number;
  12. }
  13. type ScanEvent = CustomEvent<{code: number, data?: ScanData, message?: string}>;
  14. export class Bridge extends EventTarget {
  15. public static getInstance(): Bridge;
  16. public static pulse(userId: string): Promise<{
  17. measureId: string;
  18. summaryLabel: {
  19. summary?: HandSummary['summary'];
  20. left?: HandSummary;
  21. right?: HandSummary;
  22. };
  23. summaryValue: Record<HandKeys, number[]>;
  24. time: string;
  25. appId?: string;
  26. userId?: string;
  27. url: string;
  28. report: string;
  29. }>;
  30. public static print(): Promise<void>;
  31. public static print(params: { url?: string }): Promise<void>;
  32. /**
  33. * 监听扫码事件
  34. * @param type 事件类型 'scan'
  35. * @param listener 事件回调,参数为 ScanEvent
  36. * @param options
  37. */
  38. addEventListener(type: 'scan', listener: (event: ScanEvent) => void, options?: boolean | AddEventListenerOptions): void;
  39. }
  40. export interface globalAIO {
  41. scan(value: string): number;
  42. print(value: string): void;
  43. }