diff --git a/pages/index/index.vue b/pages/index/index.vue index fb405a135cdf1e01aa5800b13f1dd957afbb8619..e5f7e775d24c2b9a3cc061b04ded9b4df9bea216 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -44,6 +44,7 @@ uni.connectWifi({ maunal:false, SSID:"Xiaomi_20D0", + BSSID:"", password:"BBBB", complete:(res)=>{ console.log(res); @@ -138,27 +139,11 @@ var that = this; uni.onUserCaptureScreen(function(res) { console.log(res); - - if (uni.getSystemInfoSync().platform == "android") { - // 除android 之外的平台,不需要判断返回状态码 - if(res.errCode == -1){ - // 启动失败 - that.permissionGranted = true; - return ; - }else if(res.errCode == 0){ - uni.showToast({ - icon:"none", - title:'捕获截屏事件' - }) - that.screenImage = res.image - } - }else{ - // 除android 之外的平台,不需要判断返回状态码 - uni.showToast({ - icon:"none", - title:'捕获截屏事件' - }) - } + uni.showToast({ + icon:"none", + title:'捕获截屏事件' + }) + that.screenImage = res.path }); if (uni.getSystemInfoSync().platform != "android" || that.permissionGranted) { diff --git a/uni_modules/uni-getbatteryinfo/package.json b/uni_modules/uni-getbatteryinfo/package.json index 0eb0aace31cf40ae5e6986aad77b02999523a315..0731fe3a54e5924d05c34a1bf58d5bc2fe6e1642 100644 --- a/uni_modules/uni-getbatteryinfo/package.json +++ b/uni_modules/uni-getbatteryinfo/package.json @@ -32,7 +32,7 @@ }, "uni_modules": { "uni-ext-api": { - "uni": "getBatteryInfo" + "uni": ["getBatteryInfo"] }, "dependencies": [], "encrypt": [], diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts index 2b7f0f7433d34daf9662cedfc7d64554793777ee..319368c02692c8ac451d996ee2f64a31aa8c0048 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts @@ -1,39 +1,33 @@ -import Context from "android.content.Context"; -import BatteryManager from "android.os.BatteryManager"; -import { UTSAndroid } from "io.dcloud.uts"; - - -type GetBatteryInfoOptions = { - success?: (res: UTSJSONObject) => void - fail?: (res: UTSJSONObject) => void - complete?: (res: UTSJSONObject) => void -} - -export default function getBatteryInfo(options: GetBatteryInfoOptions) { - const context = UTSAndroid.getAppContext(); - if (context != null) { - const manager = context.getSystemService( - Context.BATTERY_SERVICE - ) as BatteryManager; - const level = manager.getIntProperty( - BatteryManager.BATTERY_PROPERTY_CAPACITY - ); - const res = { - errCode: 0, - errSubject: "uni-getBatteryInfo", - errMsg: 'getBatteryInfo:ok', - level, - isCharging: manager.isCharging() - } - options.success?.(res) - options.complete?.(res) - } else { - const res = { - errSubject: "uni-getBatteryInfo", - errCode: 1001, - errMsg: 'getBatteryInfo:fail getAppContext is null' - } - options.fail?.(res) - options.complete?.(res) - } -} +import Context from "android.content.Context"; +import BatteryManager from "android.os.BatteryManager"; +import { UTSAndroid } from "io.dcloud.uts"; + +import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoFail, GetBatteryInfoOptions } from '../interface.uts' + +export const getBatteryInfo : GetBatteryInfo = function (options) { + const context = UTSAndroid.getAppContext(); + if (context != null) { + const manager = context.getSystemService( + Context.BATTERY_SERVICE + ) as BatteryManager; + const level = manager.getIntProperty( + BatteryManager.BATTERY_PROPERTY_CAPACITY + ); + const res : GetBatteryInfoSuccess = { + errMsg: 'getBatteryInfo:ok', + level, + isCharging: manager.isCharging() + } + options.success?.(res) + options.complete?.(res) + } else { + const res : GetBatteryInfoFail = { + errSubject: "uni-getBatteryInfo", + errCode: 1001, + errMsg: 'getBatteryInfo:fail getAppContext is null', + cause: null + } + options.fail?.(res) + options.complete?.(res) + } +} \ No newline at end of file diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts index 86521893959d03fe928327cac154b7610546e421..755250ff9d42c91ed820889b8103ef9ce850c881 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts @@ -1,32 +1,23 @@ -// 引用 iOS 原生平台 api -import { UIDevice } from "UIKit"; -import { Int } from 'Swift'; - -/** - * 定义 接口参数 - */ -type GetBatteryInfoOptions = { - success?: (res: object) => void; - fail?: (res: object) => void; - complete?: (res: object) => void; -}; - -/** - * 导出 获取电量方法 - */ -export default function getBatteryInfo(options: GetBatteryInfoOptions) { - - // 开启电量检测 - UIDevice.current.isBatteryMonitoringEnabled = true - - // 返回数据 - const res = { - errCode: 0, - errSubject: "uni-getBatteryInfo", - errMsg: "getBatteryInfo:ok", - level: new Int(UIDevice.current.batteryLevel * 100), - isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging, - }; - options.success?.(res); - options.complete?.(res); +// 引用 iOS 原生平台 api +import { UIDevice } from "UIKit"; +import { Int } from 'Swift'; + +import { GetBatteryInfo, GetBatteryInfoSuccess } from '../interface.uts'; + +/** + * 导出 获取电量方法 + */ +export const getBatteryInfo : GetBatteryInfo = function (options) { + + // 开启电量检测 + UIDevice.current.isBatteryMonitoringEnabled = true + + // 返回数据 + const res : GetBatteryInfoSuccess = { + errMsg: "getBatteryInfo:ok", + level: new Int(UIDevice.current.batteryLevel * 100), + isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging, + }; + options.success?.(res); + options.complete?.(res); } \ No newline at end of file diff --git a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts index 975fc6a22a99f9e85cffbadc38fe1e7d91d4b3c7..7d3bbf103e608a021aadc8418a44342f7371c316 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts @@ -1,76 +1,61 @@ -type GetBatteryInfoResult = { - /** - * 错误码 - * 0:成功 - * 1001:getAppContext is null - * 1002:navigator.getBattery is unsupported - */ - errCode : number, - /** - * 调用API的名称 - */ - errSubject : string, - /** - * 错误的详细信息 - */ - errMsg : string, - /** - * 设备电量,范围1 - 100 - */ - level : number, - /** - * 是否正在充电中 - */ - isCharging : boolean +export type GetBatteryInfoSuccess = { + errMsg : string, + /** + * 设备电量,范围1 - 100 + */ + level : number, + /** + * 是否正在充电中 + */ + isCharging : boolean } -interface UniError { - /** - * 错误码 - */ - errCode : number, - /** - * 调用API的名称 - */ - errSubject : string, - /** - * 错误的详细信息 - */ - errMsg : string, - /** - * 错误来源 - */ - cause : any +export type GetBatteryInfoFail = { + /** + * 错误码 + */ + errCode : number, + /** + * 调用API的名称 + */ + errSubject : string, + /** + * 错误的详细信息 + */ + errMsg : string, + /** + * 错误来源 + */ + cause : any | null } export type GetBatteryInfoOptions = { - /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - */ - success ?: (res : GetBatteryInfoResult) => void - /** - * 接口调用失败的回调函数 - */ - fail ?: (res : UniError) => void - /** - * 接口调用成功的回调 - */ - complete ?: (res : object) => void + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + success ?: (res : GetBatteryInfoSuccess) => void + /** + * 接口调用失败的回调函数 + */ + fail ?: (res : GetBatteryInfoFail) => void + /** + * 接口调用成功的回调 + */ + complete ?: (res : any) => void } /** - * 获取电量信息 - * @param {GetBatteryInfoOptions} options - * - * - * @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html - * @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 - * @since 3.6.11 - * - * @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false }) - * @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" }) - */ -export default function getBatteryInfo(options : GetBatteryInfoOptions) : void - +* 获取电量信息 +* @param {GetBatteryInfoOptions} options +* +* +* @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html +* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 +* @since 3.6.11 +* +* @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false }) +* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" }) +*/ +export type GetBatteryInfo = (options : GetBatteryInfoOptions) => void \ No newline at end of file diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js index d40f4e55c460906f8cb1025e6bb84845a577c28b..4fdced2ee3aa9d80eafdffdc5f06d522c7a1f08a 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js +++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js @@ -1,3 +1,3 @@ -export default function getBatteryInfo(options) { +export function getBatteryInfo(options) { return my.getBatteryInfo(options) } diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js index d727cd4d9aea0258e06c365fe4692c95998a0727..5944a774bdc27de75cbe441c1af274dfef4ab8ac 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js +++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js @@ -1,3 +1,3 @@ -export default function getBatteryInfo(options) { +export function getBatteryInfo(options) { return swan.getBatteryInfo(options) } diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js index 8ca00716e45b4ca2e1b26236d1d00b547a4482a3..06287bc468d46e1c12f79e455a934fcbea7c52c5 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js +++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js @@ -1,3 +1,3 @@ -export default function getBatteryInfo(options) { +export function getBatteryInfo(options) { return qq.getBatteryInfo(options) } diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js index c85d6b43908a2a1e8319edfea6633b131123f115..5124b3de21a08a351d2d7eb631aaf96a600aa147 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js +++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js @@ -1,3 +1,3 @@ -export default function getBatteryInfo(options) { +export function getBatteryInfo(options) { return wx.getBatteryInfo(options) } diff --git a/uni_modules/uni-getbatteryinfo/utssdk/web/index.js b/uni_modules/uni-getbatteryinfo/utssdk/web/index.js index 33782f4cd20795c4fd8ee15f998e10b5ac3ef352..4049f5043cf63a84780d2477cee0a590f2fa8ba8 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/web/index.js +++ b/uni_modules/uni-getbatteryinfo/utssdk/web/index.js @@ -1,4 +1,4 @@ -export default function getBatteryInfo(options) { +export function getBatteryInfo(options) { if (navigator.getBattery) { navigator.getBattery().then(battery => { const res = { diff --git a/uni_modules/uni-memorywarning/utssdk/app-android/index.uts b/uni_modules/uni-memorywarning/utssdk/app-android/index.uts index b364d0431a189b41ce5eb855e5d4a475b8b54889..a28f12af07ade2f6be38f7c00ee4aaeb7fa8cceb 100644 --- a/uni_modules/uni-memorywarning/utssdk/app-android/index.uts +++ b/uni_modules/uni-memorywarning/utssdk/app-android/index.uts @@ -1,16 +1,20 @@ import { UTSAndroid } from "io.dcloud.uts" + let listeners: UTSCallback[] = [] -const onAppTrimMemoryListener = (res: number) => { +const onAppTrimMemoryListener = (ret: number) => { listeners.forEach(listener => { + let res = { + level:ret + } listener(res) }) } @Suppress("DEPRECATION") -export function onMemoryWarning(callback: (res: number) => void) { +export function onMemoryWarning(callback: UTSCallback) { if (listeners.length == 0) { // 仅首次执行底层的实际监听 UTSAndroid.onAppTrimMemory(onAppTrimMemoryListener) @@ -22,8 +26,9 @@ export function onMemoryWarning(callback: (res: number) => void) { listeners.push(callback) } + @Suppress("DEPRECATION") -export function offMemoryWarning(callback: UTSCallback | null = null) { +export function offMemoryWarning(callback: UTSCallback | null) { if(callback == null){ // 清除全部回调 @@ -42,3 +47,4 @@ export function offMemoryWarning(callback: UTSCallback | null = null) { UTSAndroid.offAppTrimMemory(onAppTrimMemoryListener) } } + diff --git a/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts b/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts index 2a99ed36e376c54f15734b03bf387c3ec86ab7cd..fd92a79a318574235fcc6189a0e1abf75e539016 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts @@ -8,7 +8,8 @@ import File from "java.io.File"; import Environment from "android.os.Environment"; import System from 'java.lang.System'; import WindowManager from 'android.view.WindowManager'; -import { UserCaptureScreenResult, OnUserCaptureScreenResult, SetUserCaptureScreenOptions, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen } from "../interface.uts"; +import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts"; + /** * 文件监听器 @@ -50,10 +51,7 @@ class ScreenFileObserver extends FileObserver { lastObserverTime = currentTime; const screenShotPath = new File(this.screenFile, path).getPath(); - const res : OnUserCaptureScreenResult = { - errCode: 0, - errMsg: "onUserCaptureScreen:ok", - errSubject: "uni-onUserCaptureScreen", + const res : OnUserCaptureScreenCallbackResult = { path: screenShotPath } listener?.(res); @@ -68,23 +66,15 @@ class ScreenFileObserver extends FileObserver { export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : UserCaptureScreenCallback | null) { // 检查相关权限是否已授予 if (ActivityCompat.checkSelfPermission(UTSAndroid.getAppContext()!, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - // 无权限,申请权限,并且告知用户监听失败 + // 无权限,申请权限 ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 1001); - // 因权限缺失导致监听失败 - const res : OnUserCaptureScreenResult = { - errCode: -1, - errMsg: "onUserCaptureScreen:permission denied", - errSubject: "uni-onUserCaptureScreen" - } - callback?.(res); return; } - // 更新监听 listener = callback; let directory_screenshot : File; - if (Build.MANUFACTURER.toLowerCase() === "xiaomi") { + if (Build.MANUFACTURER.toLowerCase() == "xiaomi") { // @Suppress("DEPRECATION") directory_screenshot = new File(new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM), "Screenshots"); } else { @@ -113,11 +103,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (_ : UserCap export const setUserCaptureScreen : SetUserCaptureScreen = function (option : SetUserCaptureScreenOptions) { // 切换到UI线程 UTSAndroid.getUniActivity()?.runOnUiThread(new SetUserCaptureScreenRunnable(option.enable)); - const res : UserCaptureScreenResult = { - errCode: 0, - errMsg: "setUserCaptureScreen:ok", - errSubject: "uni-setUserCaptureScreen" - } + const res : SetUserCaptureScreenSuccess = {} option.success?.(res); option.complete?.(res); } diff --git a/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts b/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts index f197ffeeea89a25ab2fca8bdff571d0239aa6e9e..544fb212e6caecc98a1d9a7ac34481234fe49fa2 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts @@ -2,8 +2,8 @@ import { NotificationCenter } from 'Foundation'; import { CGRect } from "CoreFoundation"; import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit" import { UTSiOS } from "DCloudUTSFoundation" -import { DispatchQueue } from 'Dispatch'; -import { SetUserCaptureScreenOptions, UserCaptureScreenResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, OnUserCaptureScreenResult } from "../interface.uts" +import { DispatchQueue } from 'Dispatch'; +import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess, SetUserCaptureScreenFail } from "../interface.uts" /** * 定义监听截屏事件工具类 @@ -26,26 +26,15 @@ class CaptureScreenTool { // target-action 的方法前需要添加 @objc 前缀 @objc static userDidTakeScreenshot() { // 回调 - const res: OnUserCaptureScreenResult = { - errCode: 0, - errSubject: "uni-usercapturescreen", - errMsg: "onUserCaptureScreen: ok", - path: null + const res: OnUserCaptureScreenCallbackResult = { } this.listener?.(res) } // 移除监听事件 static removeListen(callback : UserCaptureScreenCallback | null) { - this.listener = null + this.listener = null NotificationCenter.default.removeObserver(this) - const res: OnUserCaptureScreenResult = { - errCode: 0, - errSubject: "uni-usercapturescreen", - errMsg: "offUserCaptureScreen: ok", - path: null - } - callback?.(res) } static createSecureView() : UIView | null { @@ -81,10 +70,7 @@ class CaptureScreenTool { rootView!.frame = rect } } - let res: UserCaptureScreenResult = { - errCode: 0, - errSubject: "uni-usercapturescreen", - errMsg: "setUserCaptureScreen:ok" + let res: SetUserCaptureScreenSuccess = { } option.success?.(res) option.complete?.(res) @@ -106,10 +92,7 @@ class CaptureScreenTool { } this.secureView = null } - let res: UserCaptureScreenResult = { - errCode: 0, - errSubject: "uni-usercapturescreen", - errMsg: "setUserCaptureScreen:ok" + let res: SetUserCaptureScreenSuccess = { } option.success?.(res) option.complete?.(res) @@ -136,7 +119,7 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback : */ export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) { if (UIDevice.current.systemVersion < "13.0") { - let res: UserCaptureScreenResult = { + let res: SetUserCaptureScreenFail = { errCode: 12001, errSubject: "uni-usercapturescreen", errMsg: "setUserCaptureScreen:system not support" @@ -145,7 +128,7 @@ export const setUserCaptureScreen : SetUserCaptureScreen = function (options : S options.complete?.(res); } else if (UIDevice.current.systemVersion == "15.1") { - let res: UserCaptureScreenResult = { + let res: SetUserCaptureScreenFail = { errCode: 12010, errSubject: "uni-usercapturescreen", errMsg: "setUserCaptureScreen:system internal error" diff --git a/uni_modules/uni-usercapturescreen/utssdk/interface.uts b/uni_modules/uni-usercapturescreen/utssdk/interface.uts index d5d744bea085e95b75a952fbbc547d7d5ab25d5f..7535e0d1a965b9f15d0edc8f9809e2d1ad39a77f 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/interface.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/interface.uts @@ -1,27 +1,56 @@ -export type UserCaptureScreenResult = { - /** - * 错误码 - * 0:成功 - * -1:permission denied - * 12001:system not support - * 12010:system internal error - */ - errCode : number, - /** - * 调用API的名称 - */ - errSubject : string, +/** + * uni.onUserCaptureScreen/uni.offUserCaptureScreen回调参数 + */ +export type OnUserCaptureScreenCallbackResult = { /** - * 错误的详细信息 + * 截屏文件路径(仅Android返回) */ - errMsg : string, + path ?: string } -export type OnUserCaptureScreenResult = { +/** + * uni.onUserCaptureScreen/uni.offUserCaptureScreen回调函数定义 + */ +export type UserCaptureScreenCallback = (res : OnUserCaptureScreenCallbackResult) => void + +/** + * uni.onUserCaptureScreen函数定义 + * 开启截屏监听 + * + * @param {UserCaptureScreenCallback} callback + * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen + * @platforms APP-IOS = ^9.0,APP-ANDROID = ^19 + * @since 3.6.8 + */ +export type OnUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void + +/** + * uni.offUserCaptureScreen函数定义 + * 关闭截屏监听 + * + * @param {UserCaptureScreenCallback} callback + * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen + * @platforms APP-IOS = ^9.0,APP-ANDROID = ^19 + * @since 3.6.8 + */ +export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void + +/** + * uni.setUserCaptureScreen成功回调参数 + */ +export type SetUserCaptureScreenSuccess = { +} + +/** + * uni.setUserCaptureScreen失败回调参数 + */ +export type SetUserCaptureScreenFail = { /** * 错误码 * 0:成功 - * -1:permission denied(仅Android返回) + * -1:permission denied + * 12001:system not support + * 12010:system internal error */ errCode : number, /** @@ -32,59 +61,58 @@ export type OnUserCaptureScreenResult = { * 错误的详细信息 */ errMsg : string, - /** - * 截屏文件路径(仅Android返回) - */ - path : string | null } +/** + * uni.setUserCaptureScreen成功回调函数定义 + */ +export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuccess) => void + +/** + * uni.setUserCaptureScreen失败回调函数定义 + */ +export type SetUserCaptureScreenFailCallback = (res : SetUserCaptureScreenFail) => void + +/** + * uni.setUserCaptureScreen完成回调函数定义 + */ +export type SetUserCaptureScreenCompleteCallback = (res : any) => void + +/** + * uni.setUserCaptureScreen参数 + */ + export type SetUserCaptureScreenOptions = { /** - * true: 允许用户截屏 false: 不允许用户截屏,防止用户截屏到应用页面内容 - */ + * true: 允许用户截屏 false: 不允许用户截屏,防止用户截屏到应用页面内容 + */ enable : boolean; /** - * 接口调用成功的回调函数 - */ - success ?: (res : UserCaptureScreenResult) => void, + * 接口调用成功的回调函数 + */ + // success : SetUserCaptureScreenSuccessCallback | null, + success ?: SetUserCaptureScreenSuccessCallback, /** - * 接口调用失败的回调函数 - */ - fail ?: (res : UserCaptureScreenResult) => void, + * 接口调用失败的回调函数 + */ + // fail : SetUserCaptureScreenFailCallback | null, + fail ?: SetUserCaptureScreenFailCallback, /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - */ - complete ?: (res : UserCaptureScreenResult) => void + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + // complete : SetUserCaptureScreenSuccessCallback | SetUserCaptureScreenFailCallback | null + complete ?: SetUserCaptureScreenCompleteCallback } -export type UserCaptureScreenCallback = (res : OnUserCaptureScreenResult) => void - -/** - * 开启截屏监听 - * - * @param {UserCaptureScreenCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen - * @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 - * @since 3.6.8 - */ -export type OnUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void -/** - * 关闭截屏监听 - * - * @param {UserCaptureScreenCallback} callback - * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen - * @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 - * @since 3.6.8 - */ -export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void +/** + * * uni.setUserCaptureScreen函数定义 -/** * 设置防截屏 * * @param {SetUserCaptureScreenOptions} options * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen - * @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 + * @platforms APP-IOS = ^13.0,APP-ANDROID = ^19 * @since 3.7.3 */ export type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void @@ -93,5 +121,4 @@ interface uni { onUserCaptureScreen : OnUserCaptureScreen, offUserCaptureScreen : OffUserCaptureScreen, setUserCaptureScreen : SetUserCaptureScreen -} - +} \ No newline at end of file