提交 186ead48 编写于 作者: lizhongyi_'s avatar lizhongyi_

Merge branch 'dev' into alpha

* dev:
  Android uni-usercapturescreen 语法调整
  wifi 适配3.7.7
  fix: uni-usercapturescreen iOS 更新
  usercapturescreen统一interface.uts
  内存警告插件 去掉默认值,避免变量未使用的警告
  内存警告插件 方法参数改回 UTSCallback 类型
  内存警告先还原会 utscallback 写法
  uni-wifi interface更新
  uni-wifi新增interface
  内存监控android 按照 3.7.7语法修改
  优化iOS插件示例
  uni-usercapturescreen 插件iOS调整
  Android uni-usercapturescreen 语法调整
  电量:移除成功信息中的错误码
  电量:移除成功信息中的错误码定义
  电量:重构
  Revert "手动修复内存监控 组件 3.7.6之后编译器新语法"
  手动修复内存监控 组件 3.7.6之后编译器新语法

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