12345678910111213141516171819202122232425262728 |
- interface ScanData {
- code: string;
- state: number;
- type: number;
- message?: string;
- }
- export interface BridgeEventMap {
- scan: CustomEvent<{code: number, data?: ScanData, message?: string}>;
- }
- export class Bridge extends EventTarget {
- public static getInstance(): Bridge;
- public static print(): Promise<void>;
- public static print(params: { url?: string }): Promise<void>;
- public static scan(params: { timeout?: number; signal?: AbortSignal }): Promise<ScanData>;
- /**
- * 监听扫码事件
- * @param type 事件类型 'scan'
- * @param listener 事件回调,参数为 ScanEvent
- * @param options
- */
- addEventListener<T extends keyof BridgeEventMap>(type: T, listener: (event: BridgeEventMap[T]) => void, options?: boolean | AddEventListenerOptions): () => void;
- removeEventListener<T extends keyof BridgeEventMap>(type: T, listener: (event: BridgeEventMap[T]) => void, options?: boolean | AddEventListenerOptions): () => void;
- }
|