6.7.0 - Alpha5 - 修复 timers.keepAlive 方法 timeout 参数功能无效的问题

This commit is contained in:
SuperMonster003
2025-09-12 14:29:52 +08:00
parent c5d02b399f
commit 335e12fd12
3 changed files with 17 additions and 5 deletions

View File

@@ -11,6 +11,7 @@
],
"fix": [
"isJavaClass/isJavaPackage 等全局方法无效的问题",
"timers.keepAlive 方法 timeout 参数功能无效的问题",
"使用 XML 语法将 JavaScript 表达式作为属性值时, this 对象可能出现指向错误的问题",
"canvas 元素控件 setMaxFps 方法内部帧率计算错误",
"images.concat 方法纵向拼接时宽度值计算错误",

View File

@@ -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<out Any?>): 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

View File

@@ -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