From 5b734e04e47f31f5b9403bd5f605a85ff2e84c52 Mon Sep 17 00:00:00 2001 From: lizhongyi Date: Fri, 26 May 2023 16:08:18 +0800 Subject: [PATCH] =?UTF-8?q?update=20uni-usercapturescreen=20uni-momorywarn?= =?UTF-8?q?ing=E6=8F=92=E4=BB=B6interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-android/index.uts | 6 +- .../utssdk/app-ios/index.uts | 6 +- .../uni-memorywarning/utssdk/interface.uts | 53 +++++++++ .../utssdk/interface.uts | 101 ++++++++++++------ 4 files changed, 129 insertions(+), 37 deletions(-) create mode 100644 uni_modules/uni-memorywarning/utssdk/interface.uts diff --git a/uni_modules/uni-memorywarning/utssdk/app-android/index.uts b/uni_modules/uni-memorywarning/utssdk/app-android/index.uts index a28f12a..28bf366 100644 --- a/uni_modules/uni-memorywarning/utssdk/app-android/index.uts +++ b/uni_modules/uni-memorywarning/utssdk/app-android/index.uts @@ -1,5 +1,5 @@ import { UTSAndroid } from "io.dcloud.uts" - +import { OnMemoryWarning, OffMemoryWarning } from "../interface.uts" let listeners: UTSCallback[] = [] @@ -14,7 +14,7 @@ const onAppTrimMemoryListener = (ret: number) => { @Suppress("DEPRECATION") -export function onMemoryWarning(callback: UTSCallback) { +export const onMemoryWarning : OnMemoryWarning = function (callback: UTSCallback) { if (listeners.length == 0) { // 仅首次执行底层的实际监听 UTSAndroid.onAppTrimMemory(onAppTrimMemoryListener) @@ -28,7 +28,7 @@ export function onMemoryWarning(callback: UTSCallback) { @Suppress("DEPRECATION") -export function offMemoryWarning(callback: UTSCallback | null) { +export const offMemoryWarning : OffMemoryWarning = function (callback: UTSCallback | null) { if(callback == null){ // 清除全部回调 diff --git a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts index e4dc943..60ee47f 100644 --- a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts +++ b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts @@ -1,6 +1,7 @@ import { NotificationCenter } from 'Foundation'; import { UIApplication } from "UIKit" import { Selector } from "ObjectiveC" +import { OnMemoryWarning, OffMemoryWarning } from "../interface.uts" class MemoryWarningTool { static listeners: UTSCallback[] = [] @@ -45,12 +46,13 @@ class MemoryWarningTool { } } + // 开启监听内存警告 -export function onMemoryWarning(callback: UTSCallback) { +export const onMemoryWarning : OnMemoryWarning = function (callback: UTSCallback) { MemoryWarningTool.listenMemoryWarning(callback) } // 关闭监听内存警告 -export function offMemoryWarning(callback: UTSCallback | null) { +export const offMemoryWarning : OffMemoryWarning = function (callback: UTSCallback | null) { MemoryWarningTool.removeListen(callback) } \ No newline at end of file diff --git a/uni_modules/uni-memorywarning/utssdk/interface.uts b/uni_modules/uni-memorywarning/utssdk/interface.uts new file mode 100644 index 0000000..483c232 --- /dev/null +++ b/uni_modules/uni-memorywarning/utssdk/interface.uts @@ -0,0 +1,53 @@ + +export type OnMemoryWarning = (callback: UTSCallback) => void + +export type OffMemoryWarning = (callback : UTSCallback | null) => void + +export interface Uni { + /** + * 开启监听内存警告 + * + * @param {UTSCallback} callback + * @tutorial https://uniapp.dcloud.net.cn/api/system/memory.html#onmemorywarning + * @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版本 + */ + onMemoryWarning : OnMemoryWarning, + /** + * 取消监听内存不足告警事件 + * + * @param {UTSCallback} callback + * @tutorial https://uniapp.dcloud.net.cn/api/system/memory.html#offmemorywarning + * @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版本 + */ + offMemoryWarning : OffMemoryWarning +} \ No newline at end of file diff --git a/uni_modules/uni-usercapturescreen/utssdk/interface.uts b/uni_modules/uni-usercapturescreen/utssdk/interface.uts index 235b782..98ce4c1 100644 --- a/uni_modules/uni-usercapturescreen/utssdk/interface.uts +++ b/uni_modules/uni-usercapturescreen/utssdk/interface.uts @@ -13,26 +13,8 @@ export type OnUserCaptureScreenCallbackResult = { */ 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 = ^4.4 - * @since 3.7.7 - */ 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 = ^4.4 - * @since 3.7.7 - */ export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null) => void /** @@ -102,21 +84,76 @@ export type SetUserCaptureScreenOptions = { complete ?: SetUserCaptureScreenCompleteCallback } - -/** - * * uni.setUserCaptureScreen函数定义 - - * 设置防截屏 - * - * @param {SetUserCaptureScreenOptions} options - * @tutorial https://uniapp.dcloud.net.cn/api/system/capture-screen.html#setusercapturescreen - * @platforms APP-IOS = ^13.0,APP-ANDROID = ^4.4 - * @since 3.7.7 - */ export type SetUserCaptureScreen = (options : SetUserCaptureScreenOptions) => void -export interface Uni { - onUserCaptureScreen : OnUserCaptureScreen, - offUserCaptureScreen : OffUserCaptureScreen, +export interface Uni { + /** + * 开启截屏监听 + * + * @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版本 + */ + onUserCaptureScreen : OnUserCaptureScreen, + /** + * 关闭截屏监听 + * + * @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版本 + */ + offUserCaptureScreen : OffUserCaptureScreen, + /** + * 设置防截屏 + * + * @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 : SetUserCaptureScreen } \ No newline at end of file -- GitLab