From 214aec20ab21627c12df983ac4eddc6f2477e7b6 Mon Sep 17 00:00:00 2001 From: lizhongyi Date: Fri, 27 Oct 2023 18:23:51 +0800 Subject: [PATCH] =?UTF-8?q?uni-usercapturescreen=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=A0=81=E9=81=B5=E5=BE=AA=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-getbatteryinfo/utssdk/interface.uts | 23 +----------- .../utssdk/app-ios/index.uts | 6 ++-- .../utssdk/interface.uts | 15 +++++++- .../uni-usercapturescreen/utssdk/unierror.uts | 35 +++++++++++++++++++ 4 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 uni_modules/uni-usercapturescreen/utssdk/unierror.uts diff --git a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts index 9c7f25f..214180b 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 003f572..5f6273f 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 ad625ee..5339338 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 0000000..817cb79 --- /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 -- GitLab