From 4aea89a30ce7d4b372d55ad7ad90b3039aec4fc7 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Fri, 10 Mar 2023 15:28:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=AE=E5=A4=8D=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-android/index.uts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts b/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts index 114cde5..03698cc 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts @@ -88,7 +88,7 @@ class ScreenFileObserver extends FileObserver { * 开启截图监听 */ @Suppress("DEPRECATION") -export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UTSCallback) { +export const onUserCaptureScreen : OnUserCaptureScreen = function (callback ?: UTSCallback) { // 检查相关权限是否已经具备 if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { @@ -99,7 +99,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UT let ret = { errCode:-1 } - callback(ret); + callback?.(ret); return ; } @@ -120,14 +120,14 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UT screenOB!.stopWatching() } //开始监听 - screenOB = new ScreenFileObserver(directory_screenshot.path) + screenOB = new ScreenFileObserver(directory_screenshot.getPath()) screenOB!.startWatching() // 监听成功 let ret = { errCode:0 } - callback(ret); + callback?.(ret); } @@ -135,7 +135,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UT /** * 关闭截屏监听 */ -export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : UTSCallback) { +export const offUserCaptureScreen : OffUserCaptureScreen = function (callback ?: UTSCallback) { // android 10以上,关闭监听通过移除文件监听器实现 if (screenOB != null) { @@ -144,7 +144,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : } lastFileObserverTime = 0; - callback({}); + callback?.({}); } /** -- GitLab