From f88c12235d901fe6436d2cc56011ae4231241db7 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Thu, 9 Nov 2023 15:53:46 +0800 Subject: [PATCH] =?UTF-8?q?uni-usercapturescreen=E6=8F=92=E4=BB=B6=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0index.d.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-usercapturescreen/index.d.ts | 155 ++++++++++++++++++- 1 file changed, 147 insertions(+), 8 deletions(-) diff --git a/uni_modules/uni-usercapturescreen/index.d.ts b/uni_modules/uni-usercapturescreen/index.d.ts index debf1a1..e88abe7 100644 --- a/uni_modules/uni-usercapturescreen/index.d.ts +++ b/uni_modules/uni-usercapturescreen/index.d.ts @@ -1,18 +1,157 @@ declare namespace UniNamespace { - type OnUserCaptureScreenCallback = (res?: { errMsg: string }) => void + /** + * uni.onUserCaptureScreen/uni.offUserCaptureScreen回调参数 + */ + type OnUserCaptureScreenCallbackResult = { + /** + * 截屏文件路径(仅Android返回) + */ + path ?: string + } + + /** + * uni.onUserCaptureScreen/uni.offUserCaptureScreen回调函数定义 + */ + type UserCaptureScreenCallback = (res : OnUserCaptureScreenCallbackResult) => void + + type OnUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void + + type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void + + /** + * uni.setUserCaptureScreen成功回调参数 + */ + type SetUserCaptureScreenSuccess = { + + } + + /** + * uni.setUserCaptureScreen成功回调函数定义 + */ + type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuccess) => void + + /** + * 错误码 + * - 12001 "setUserCaptureScreen:system not support" + * - 12010 "setUserCaptureScreen:system internal error" + */ + type SetUserCaptureScreenErrorCode = 12001 | 12010; + + /** + * SetUserCaptureScreen 的错误回调参数 + */ + interface SetUserCaptureScreenFail { + errCode : SetUserCaptureScreenErrorCode + } + + /** + * uni.setUserCaptureScreen失败回调函数定义 + */ + type SetUserCaptureScreenFailCallback = (res : SetUserCaptureScreenFail) => void + + /** + * uni.setUserCaptureScreen完成回调函数定义 + */ + type SetUserCaptureScreenCompleteCallback = (res : any) => void + + /** + * uni.setUserCaptureScreen参数 + */ + type SetUserCaptureScreenOptions = { + /** + * true: 允许用户截屏 false: 不允许用户截屏,防止用户截屏到应用页面内容 + */ + enable : boolean; + /** + * 接口调用成功的回调函数 + */ + // success : SetUserCaptureScreenSuccessCallback | null, + success ?: SetUserCaptureScreenSuccessCallback, + /** + * 接口调用失败的回调函数 + */ + // fail : SetUserCaptureScreenFailCallback | null, + fail ?: SetUserCaptureScreenFailCallback, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + // complete : SetUserCaptureScreenSuccessCallback | SetUserCaptureScreenFailCallback | null + complete ?: SetUserCaptureScreenCompleteCallback + } + + type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void } declare interface Uni { /** - * 监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件。 + * 开启截屏监听 * - * 文档: [https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen) + * @param {UserCaptureScreenCallback} callback + * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4.4", + * "uniVer": "3.7.7", + * "unixVer": "3.9.0" + * }, + * "ios": { + * "osVer": "9.0", + * "uniVer": "3.7.7", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVersion 3.7.7 + * @uniVueVersion 2,3 //支持的vue版本 + * @autotest { expectCallback: true } */ - onUserCaptureScreen(callback: UniNamespace.OnUserCaptureScreenCallback): void; + onUserCaptureScreen(callback : UniNamespace.UserCaptureScreenCallback | null) : void, /** - * 用户主动截屏事件。取消事件监听。 + * 关闭截屏监听 * - * 文档: [https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen) + * @param {UserCaptureScreenCallback} callback + * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4.4", + * "uniVer": "3.7.7", + * "unixVer": "3.9.0" + * }, + * "ios": { + * "osVer": "9.0", + * "uniVer": "3.7.7", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVersion 3.7.7 + * @uniVueVersion 2,3 //支持的vue版本 + * @autotest { expectCallback: true } */ - offUserCaptureScreen(callback: UniNamespace.OnUserCaptureScreenCallback): void; -} + offUserCaptureScreen(callback : UniNamespace.UserCaptureScreenCallback | null) : void, + /** + * 设置防截屏 + * + * @param {SetUserCaptureScreenOptions} options + * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4.4", + * "uniVer": "3.7.7", + * "unixVer": "3.9.0" + * }, + * "ios": { + * "osVer": "13.0", + * "uniVer": "3.7.7", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVersion 3.7.7 + * @uniVueVersion 2,3 //支持的vue版本 + */ + setUserCaptureScreen(options : UniNamespace.SetUserCaptureScreenOptions) : void +} \ No newline at end of file -- GitLab