From 335e12fd12e2521865f9ab99e12b21b77dbedfda Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Fri, 12 Sep 2025 14:29:52 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=20-=20Alpha5=20-=20=E4=BF=AE=E5=A4=8D=20t?= =?UTF-8?q?imers.keepAlive=20=E6=96=B9=E6=B3=95=20timeout=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=8A=9F=E8=83=BD=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 1 + .../autojs/runtime/api/augment/timers/Timers.kt | 15 +++++++++++++-- version.properties | 6 +++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 469b2425..adef8464 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -11,6 +11,7 @@ ], "fix": [ "isJavaClass/isJavaPackage 等全局方法无效的问题", + "timers.keepAlive 方法 timeout 参数功能无效的问题", "使用 XML 语法将 JavaScript 表达式作为属性值时, this 对象可能出现指向错误的问题", "canvas 元素控件 setMaxFps 方法内部帧率计算错误", "images.concat 方法纵向拼接时宽度值计算错误", diff --git a/app/src/main/java/org/autojs/autojs/runtime/api/augment/timers/Timers.kt b/app/src/main/java/org/autojs/autojs/runtime/api/augment/timers/Timers.kt index b381e1af..d6e488fc 100644 --- a/app/src/main/java/org/autojs/autojs/runtime/api/augment/timers/Timers.kt +++ b/app/src/main/java/org/autojs/autojs/runtime/api/augment/timers/Timers.kt @@ -4,13 +4,17 @@ import org.autojs.autojs.AutoJs import org.autojs.autojs.annotation.RhinoFunctionBody import org.autojs.autojs.annotation.RhinoRuntimeFunctionInterface import org.autojs.autojs.extension.FlexibleArray +import org.autojs.autojs.extension.FlexibleArray.Companion.component1 +import org.autojs.autojs.extension.FlexibleArray.Companion.component2 import org.autojs.autojs.runtime.ScriptRuntime import org.autojs.autojs.runtime.api.augment.Augmentable import org.autojs.autojs.runtime.exception.ShouldNeverHappenException +import org.autojs.autojs.util.RhinoUtils.NOT_CONSTRUCTABLE import org.autojs.autojs.util.RhinoUtils.UNDEFINED import org.autojs.autojs.util.RhinoUtils.coerceFunction import org.autojs.autojs.util.RhinoUtils.coerceLongNumber import org.autojs.autojs.util.RhinoUtils.coerceNumber +import org.autojs.autojs.util.RhinoUtils.newBaseFunction import org.autojs.autojs6.R import org.mozilla.javascript.BaseFunction import org.mozilla.javascript.Undefined @@ -103,8 +107,15 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { @JvmStatic @RhinoRuntimeFunctionInterface fun keepAlive(scriptRuntime: ScriptRuntime, args: Array): Double = ensureArgumentsAtMost(args, 1) { - val (internal) = it - setInterval(scriptRuntime, arrayOf(BaseFunction(), coerceNumber(internal, 10_000))) + val (timeoutRaw) = it + when (val timeout = coerceLongNumber(timeoutRaw, 0).coerceAtLeast(0)) { + 0L -> scriptRuntime.timers.setInterval(newBaseFunction("callback", { + /* Empty body. */ + }, NOT_CONSTRUCTABLE), 10_000) + else -> scriptRuntime.timers.setTimeout(newBaseFunction("callback", { + /* Empty body. */ + }, NOT_CONSTRUCTABLE), timeout) + } } @JvmStatic diff --git a/version.properties b/version.properties index 92d360d6..3ef80e07 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Wed Sep 10 17:07:27 CST 2025 -BUILD_TIME=1757495247304 +#Fri Sep 12 14:28:28 CST 2025 +BUILD_TIME=1757658508250 COMPILE_SDK_VERSION=35 IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_NDK_VERSION=26.1.10909125 @@ -24,6 +24,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13 RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3 TARGET_SDK_VERSION=35 TARGET_SDK_VERSION_INRT=29 -VERSION_BUILD=3361 +VERSION_BUILD=3362 VERSION_NAME=6.7.0 Alpha5 VSCODE_EXT_REQUIRED_VERSION=1.0.8