提交 ce930e42 编写于 作者: lizhongyi_'s avatar lizhongyi_

uni-getbatteryinfo、uni-usercapturescreen 插件中错误回调改为UniError

上级 15db17d5
...@@ -2,7 +2,7 @@ import Context from "android.content.Context"; ...@@ -2,7 +2,7 @@ import Context from "android.content.Context";
import BatteryManager from "android.os.BatteryManager"; import BatteryManager from "android.os.BatteryManager";
import { UTSAndroid } from "io.dcloud.uts"; import { UTSAndroid } from "io.dcloud.uts";
import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoFail, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts' import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts'
/** /**
* 异步获取电量 * 异步获取电量
* @param {Object} options * @param {Object} options
...@@ -24,12 +24,13 @@ export const getBatteryInfo : GetBatteryInfo = function (options) { ...@@ -24,12 +24,13 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
options.success?.(res) options.success?.(res)
options.complete?.(res) options.complete?.(res)
} else { } else {
const res : GetBatteryInfoFail = { // const res : GetBatteryInfoFail = {
errSubject: "uni-getBatteryInfo", // errSubject: "uni-getBatteryInfo",
errCode: 1001, // errCode: 1001,
errMsg: 'getBatteryInfo:fail getAppContext is null', // errMsg: 'getBatteryInfo:fail getAppContext is null',
cause: null // cause: null
} // }
const res = new UniError("uni-getBatteryInfo", 1001, "getBatteryInfo:fail getAppContext is null")
options.fail?.(res) options.fail?.(res)
options.complete?.(res) options.complete?.(res)
} }
......
...@@ -10,24 +10,24 @@ export type GetBatteryInfoSuccess = { ...@@ -10,24 +10,24 @@ export type GetBatteryInfoSuccess = {
isCharging : boolean isCharging : boolean
} }
export type GetBatteryInfoFail = { // export type GetBatteryInfoFail = {
/** // /**
* 错误码 // * 错误码
*/ // */
errCode : number, // errCode : number,
/** // /**
* 调用API的名称 // * 调用API的名称
*/ // */
errSubject : string, // errSubject : string,
/** // /**
* 错误的详细信息 // * 错误的详细信息
*/ // */
errMsg : string, // errMsg : string,
/** // /**
* 错误来源 // * 错误来源
*/ // */
cause : any | null // cause : any | null
} // }
...@@ -39,7 +39,7 @@ export type GetBatteryInfoOptions = { ...@@ -39,7 +39,7 @@ export type GetBatteryInfoOptions = {
/** /**
* 接口调用失败的回调函数 * 接口调用失败的回调函数
*/ */
fail ?: (res : GetBatteryInfoFail) => void fail ?: (res : UniError) => void
/** /**
* 接口调用成功的回调 * 接口调用成功的回调
*/ */
......
...@@ -3,7 +3,7 @@ import { CGRect } from "CoreFoundation"; ...@@ -3,7 +3,7 @@ import { CGRect } from "CoreFoundation";
import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit" import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit"
import { UTSiOS } from "DCloudUTSFoundation" import { UTSiOS } from "DCloudUTSFoundation"
import { DispatchQueue } from 'Dispatch'; import { DispatchQueue } from 'Dispatch';
import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess, SetUserCaptureScreenFail } from "../interface.uts" import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess } from "../interface.uts"
/** /**
* 定义监听截屏事件工具类 * 定义监听截屏事件工具类
...@@ -119,20 +119,12 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : ...@@ -119,20 +119,12 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback :
*/ */
export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) { export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) {
if (UIDevice.current.systemVersion < "13.0") { if (UIDevice.current.systemVersion < "13.0") {
let res: SetUserCaptureScreenFail = { let res = new UniError("uni-usercapturescreen", 12001, "setUserCaptureScreen:system not support")
errCode: 12001,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:system not support"
}
options.fail?.(res); options.fail?.(res);
options.complete?.(res); options.complete?.(res);
} else if (UIDevice.current.systemVersion == "15.1") { } else if (UIDevice.current.systemVersion == "15.1") {
let res: SetUserCaptureScreenFail = { let res = new UniError("uni-usercapturescreen", 12010, "setUserCaptureScreen:system internal error")
errCode: 12010,
errSubject: "uni-usercapturescreen",
errMsg: "setUserCaptureScreen:system internal error"
}
options.fail?.(res); options.fail?.(res);
options.complete?.(res); options.complete?.(res);
} else { } else {
......
...@@ -23,25 +23,6 @@ export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) ...@@ -23,25 +23,6 @@ export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null)
export type SetUserCaptureScreenSuccess = { export type SetUserCaptureScreenSuccess = {
} }
/**
* uni.setUserCaptureScreen失败回调参数
*/
export type SetUserCaptureScreenFail = {
/**
* 错误码
* 12001:system not support
* 12010:system internal error
*/
errCode : number,
/**
* 调用API的名称
*/
errSubject : string,
/**
* 错误的详细信息
*/
errMsg : string,
}
/** /**
* uni.setUserCaptureScreen成功回调函数定义 * uni.setUserCaptureScreen成功回调函数定义
...@@ -51,7 +32,7 @@ export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuc ...@@ -51,7 +32,7 @@ export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuc
/** /**
* uni.setUserCaptureScreen失败回调函数定义 * uni.setUserCaptureScreen失败回调函数定义
*/ */
export type SetUserCaptureScreenFailCallback = (res : SetUserCaptureScreenFail) => void export type SetUserCaptureScreenFailCallback = (res : UniError) => void
/** /**
* uni.setUserCaptureScreen完成回调函数定义 * uni.setUserCaptureScreen完成回调函数定义
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册