This commit is contained in:
iqudoo
2026-04-30 10:30:27 +08:00
parent 3f7d195c62
commit 11a523bf86
5 changed files with 118 additions and 17 deletions

62
dist/index.d.ts vendored
View File

@@ -7,7 +7,7 @@ interface ScanConfigOptions {
*/
webCanvasStyle?: string,
/**
* 微信JSSDK配置配置后会自动初始化微信JSSDK
* 微信JSSDK配置微信环境才会生效,配置后会自动初始化微信JSSDK
*/
initWechatJssdk: {
/**
@@ -33,6 +33,47 @@ interface ScanResult {
key: string
}
/**
* 监听key
*/
interface ScanListenerInfo {
/**
* 监听key
*/
key?: string;
/**
* 监听匹配
*/
match?: string;
/**
* 监听级别
*/
level?: number;
/**
* 监听回调
*/
listener: ScanCallback;
/**
* 取消监听
*/
cancel: () => void;
}
/**
* 监听状态
*/
type ScanStatus = "scanning" | "closed";
/**
* 监听回调
*/
type ScanCallback = (result: ScanResult) => any;
/**
* 监听状态
*/
type ScanStatusCallback = (status: ScanStatus) => any;
/** IScan */
interface IScan {
/**
@@ -44,7 +85,7 @@ interface IScan {
* 监听扫码状态
* @param callback 监听回调
*/
setStatusListener(callback: (status: "scanning" | "closed") => any): void;
setStatusListener(callback: ScanStatusCallback): void;
/**
* 监听扫码结果
* @param callback 监听回调
@@ -52,17 +93,17 @@ interface IScan {
* @param match 监听匹配
* @param level 监听级别
*/
onScanListener(callback: (result: ScanResult) => any, key: string, match: string, level: number): void;
onScanListener(callback: ScanCallback, key: string, match?: string, level?: number): ScanListenerInfo;
/**
* 取消监听扫码结果
* @param callback 监听回调
* @param callback 监听回调或监听key
*/
offScanListener(callback: (result: ScanResult) => any): void;
offScanListener(callback: ScanCallback | string): void;
/**
* 获取扫码状态
* @returns "scanning" | "closed"
* @returns ScanStatus
*/
getStatus(): "scanning" | "closed";
getStatus(): ScanStatus;
/**
* 关闭扫码
*/
@@ -78,8 +119,15 @@ interface IScan {
}
/**
* IScan 实例
*/
declare var IScan: IScan;
/**
* 将 IScan 实例挂载到 Window 对象上
* 方便在全局使用
*/
declare interface Window {
IScan: IScan;
}

2
dist/index.js vendored

File diff suppressed because one or more lines are too long