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

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

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