/** * 桥操作 */ interface BridgeOperation { req: Function; def: Function; } /** * 桥返回结果 */ interface BridgeRequestResult { err: String; result: Object; } interface ViewImage { image: String; title: String; } interface ResultObject { err: String; result: any; } interface VideoInfo { video: String; } interface ChooseResourceResult { err: String; result: String; } interface DialogInput { buttons: String[]; } interface ToastInput { title: String; duration: Number; } interface WebAppInput { url: String; title: String; disableHeader: Boolean; enableBridge: Boolean; beforeLoad: Object; } interface RouterInput { router: String; params: Object; } interface FetchInput { url: String; option: Object; } interface RequestFullscreenVideoPlayInput { start: Boolean; } interface AudioRecordInput { start: Boolean; } interface ShareInput { share: Object; id: any; } interface LinkInput { url: String; } interface PickerMenuItem extends Object { title: String; } interface PickerMenuInput { items: Array; } interface LaunchWechatProgramInput { userName: String; path: String; extDic: Object; } interface CurrentPositionInput { type: String; } interface RequestInput { url: String; option: Object; } interface RegisterAppEventInput { event: String; } interface UnRegisterAppEventInput { event: String; } interface TriggerAppEventInput { event: String; params: any; } declare enum Orientation { "PORTRAIT" = 0, "LANDSCAPE" = 1, "LANDSCAPE-RIGHT" = 2, "UNLOCK" = 3 } interface OrientationControlInput { orientation: Orientation; } interface DlnaControlInput { media: String; } interface MusicControlItem { title: String; artwork: String; artist: String; album: String; } declare enum MusicControlState { "play", "pause" } interface MusicControlInput { stop?: Boolean; item?: MusicControlItem; state?: MusicControlState; } interface ReadFileInput { path: string; encoding: string; } interface SaveFileInput { path: string; body: string; encoding: string; } interface UnZipFileInput { path: string; pass: string; encoding: string; } interface UnZipStreamInput { body: string; pass: string; encoding: string; } interface Hook { keys: string[] | string; before?(api: string, input: any, originInput?: any): any; after?(api: string, response: any, originResponse?: any): any; } interface WebBridgeApiCls { /** * 版本 */ version: string; /** * 请求自定义接口 */ requestApi(api: string, params: any): Promise; /** * 定义本地接口 */ defineApi(api: string, handle: Function, times?: number): void; /** * ping */ ping(input: any): Promise; /** * 请求 */ requireVersion(input: Object): Promise; /** * 系统信息 */ sysinfo(): Promise; /** * 扫描二维码 * @param {*} input */ scanCode(input: Object): Promise; /** * 请求授权 */ authorize(input: Object): Promise; /** * 获取当前登录用户信息 */ getUserInfo(input: Object): Promise; /** * 网络请求(Deprecated) * @param {*} input */ fetch(input: FetchInput): Promise; /** * 网络请求 * @param {*} input */ request(input: RequestInput): Promise; /** * 打开路由 * @param {*} RouterInput */ router(input: RouterInput): Promise; /** * 打开支持桥的web页面 * @param {} WebAppInput */ showWebApp(input: WebAppInput): Promise; /** * toast * @param {*} ToastInput */ showToast(input: ToastInput): Promise; /** * 弹出对话框 * @param {*} DialogInput * @type {Number} */ showDialog(input: DialogInput): Promise; /** * 选择图片 * @param input * @type {Promise} */ chooseImage(input: Object): Promise; /** * 选择视频 * @param input * @type {Promise} */ chooseVideo(input: Object): Promise; /** * 预览大图 * @param input ViewImage[] * @type {Promise} */ showImageViewer(input: ViewImage[]): Promise; /** * 播放全屏视频 * @param input */ showFullVideoPlayer(input: VideoInfo): Promise; /** * 请求全屏 注:此接口是webview界面特有接口 * @param input */ requestFullscreenVideoPlay(input: RequestFullscreenVideoPlayInput): Promise; /** * 请求权限 * @param input */ checkPermission(input: any): Promise; /** * 录制麦克风声音 * @param input */ audioRecord(input: AudioRecordInput): Promise; /** * 分享 * @param input */ share(input: ShareInput): Promise; /** * 分享 * @param input */ openLink(input: LinkInput): Promise; /** * 显示Picker菜单 * @param input */ showPickerMenu(input: PickerMenuInput): Promise; /** * 启动微信小程序 * @param input */ launchWechatProgram(input: LaunchWechatProgramInput): Promise; /** * 获取定位信息 * @param input */ getCurrentPosition(input: CurrentPositionInput): Promise; /** * 注册全局事件 * @param input * @param callback */ registerAppEvent(input: RegisterAppEventInput, listener: Function): Promise; /** * 注销全局事件 * @param input */ unRegisterAppEvent(input: UnRegisterAppEventInput): Promise; /** * 触发全局事件 * @param input */ triggerAppEvent(input: TriggerAppEventInput): Promise; /** * 旋转屏幕 * @param input */ orientation(input: OrientationControlInput): Promise; /** * 旋转屏幕 * @param input */ connectDlna(input: DlnaControlInput): Promise; /** * 锁屏声音控制 * @param input */ musicControl(input: MusicControlInput): Promise; /** * 读文件 * @param input */ readFile(input: ReadFileInput): Promise; /** * 写文件 * @param input */ saveFile(input: SaveFileInput): Promise; /** * 解压 * @param input */ unzip(input: UnZipFileInput | UnZipStreamInput): Promise; }