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