diff --git a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts index 9c7f25fbf6873eb1983882b722ee8bfbfda8b2a0..214180b1fd9c777eafd021fba91cea0351a48950 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts @@ -10,27 +10,6 @@ export type GetBatteryInfoSuccess = { isCharging : boolean } -// export type GetBatteryInfoFail = { -// /** -// * 错误码 -// */ -// errCode : number, -// /** -// * 调用API的名称 -// */ -// errSubject : string, -// /** -// * 错误的详细信息 -// */ -// errMsg : string, -// /** -// * 错误来源 -// */ -// cause : any | null -// } - - - export type GetBatteryInfoOptions = { /** * 接口调用结束的回调函数(调用成功、失败都会执行) @@ -63,7 +42,7 @@ export type GetBatteryInfoResult = { */ export type GetBatteryInfoErrorCode = 1001 ; /** - * myApi 的错误回调参数 + * GetBatteryInfo 的错误回调参数 */ export interface GetBatteryInfoFail extends IUniError { errCode : GetBatteryInfoErrorCode diff --git a/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts b/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts index 003f572da4802a00268e8114746d34fec0b4b587..5f6273f7bd38e71dded65285d63f401863486982 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts @@ -4,7 +4,7 @@ import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit" import { UTSiOS } from "DCloudUTSFoundation" import { DispatchQueue } from 'Dispatch'; import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess } from "../interface.uts" - +import { SetUserCaptureScreenFailImpl } from "../unierror.uts" /** * 定义监听截屏事件工具类 */ @@ -119,12 +119,12 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : */ export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) { if (UIDevice.current.systemVersion < "13.0") { - let res = new UniError("uni-usercapturescreen", 12001, "setUserCaptureScreen:system not support") + let res = new SetUserCaptureScreenFailImpl(12001) options.fail?.(res); options.complete?.(res); } else if (UIDevice.current.systemVersion == "15.1") { - let res = new UniError("uni-usercapturescreen", 12010, "setUserCaptureScreen:system internal error") + let res = new SetUserCaptureScreenFailImpl(12010) options.fail?.(res); options.complete?.(res); } else { diff --git a/uni_modules/uni-usercapturescreen/utssdk/interface.uts b/uni_modules/uni-usercapturescreen/utssdk/interface.uts index ad625eeabe1b50007ac3eff7d7f5211f105c406d..5339338b3aa31e22edf9ced46579b95ee0ae9462 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/interface.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/interface.uts @@ -63,7 +63,20 @@ export type SetUserCaptureScreenOptions = { */ // complete : SetUserCaptureScreenSuccessCallback | SetUserCaptureScreenFailCallback | null complete ?: SetUserCaptureScreenCompleteCallback -} +} + +/** + * 错误码 + * - 12001 "setUserCaptureScreen:system not support" + * - 12010 "setUserCaptureScreen:system internal error" + */ +export type SetUserCaptureScreenErrorCode = 12001 | 12010; +/** + * SetUserCaptureScreen 的错误回调参数 + */ +export interface SetUserCaptureScreenFail extends IUniError { + errCode : SetUserCaptureScreenErrorCode +}; export type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void diff --git a/uni_modules/uni-usercapturescreen/utssdk/unierror.uts b/uni_modules/uni-usercapturescreen/utssdk/unierror.uts new file mode 100644 index 0000000000000000000000000000000000000000..817cb79cb20c36ec3fbcd2012175e2655abfaf5d --- /dev/null +++ b/uni_modules/uni-usercapturescreen/utssdk/unierror.uts @@ -0,0 +1,35 @@ +import { SetUserCaptureScreenErrorCode, SetUserCaptureScreenFail } from "./interface.uts" +/** + * 错误主题 + */ +export const UniErrorSubject = 'uni-usercapturescreen'; + + +/** + * 错误信息 + * @UniError + */ +export const UniErrors : Map = new Map([ + /** + * 错误码及对应的错误信息 + */ + [12001, 'setUserCaptureScreen:system not support'], + [12010, 'setUserCaptureScreen:system internal error'], +]); + + +/** + * 错误对象实现 + */ +export class SetUserCaptureScreenFailImpl extends UniError implements SetUserCaptureScreenFail { + + /** + * 错误对象构造函数 + */ + constructor(errCode : SetUserCaptureScreenErrorCode) { + super(); + this.errSubject = UniErrorSubject; + this.errCode = errCode; + this.errMsg = UniErrors[errCode] ?? ""; + } +} \ No newline at end of file