diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 3b0fbd78..0331588d 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -2,6 +2,9 @@ "$data": { "v6.6.3": { "released_date": "2025/04/19", + "feature": [ + "timers.keepAlive 方法 (已全局化), 用于保持脚本活跃状态" + ], "fix": [ "主页文档标签显示在线文档时部分内容被系统导航栏遮挡的问题", "部分设备代码编辑器空行显示方框字符的问题", diff --git a/app/src/main/java/org/autojs/autojs/core/image/ColorTable.kt b/app/src/main/java/org/autojs/autojs/core/image/ColorTable.kt index 8ebd7d4b..99320cf8 100644 --- a/app/src/main/java/org/autojs/autojs/core/image/ColorTable.kt +++ b/app/src/main/java/org/autojs/autojs/core/image/ColorTable.kt @@ -698,6 +698,16 @@ class ColorTable { const val GREY_700 = -0x9e9e9f const val GREY_800 = -0xbdbdbe const val GREY_900 = -0xdededf + const val GRAY_50 = -0x50506 + const val GRAY_100 = -0xa0a0b + const val GRAY_200 = -0x111112 + const val GRAY_300 = -0x1f1f20 + const val GRAY_400 = -0x424243 + const val GRAY_500 = -0x616162 + const val GRAY_600 = -0x8a8a8b + const val GRAY_700 = -0x9e9e9f + const val GRAY_800 = -0xbdbdbe + const val GRAY_900 = -0xdededf const val BLACK_1000 = -0x1000000 const val WHITE_1000 = -0x1 const val BLUE_GREY_50 = -0x13100f @@ -710,6 +720,16 @@ class ColorTable { const val BLUE_GREY_700 = -0xbaa59c const val BLUE_GREY_800 = -0xc8b8b1 const val BLUE_GREY_900 = -0xd9cdc8 + const val BLUE_GRAY_50 = -0x13100f + const val BLUE_GRAY_100 = -0x302724 + const val BLUE_GRAY_200 = -0x4f443b + const val BLUE_GRAY_300 = -0x6f5b52 + const val BLUE_GRAY_400 = -0x876f64 + const val BLUE_GRAY_500 = -0x9f8275 + const val BLUE_GRAY_600 = -0xab9186 + const val BLUE_GRAY_700 = -0xbaa59c + const val BLUE_GRAY_800 = -0xc8b8b1 + const val BLUE_GRAY_900 = -0xd9cdc8 const val RED = RED_500 const val PINK = PINK_500 @@ -729,7 +749,9 @@ class ColorTable { const val DEEP_ORANGE = DEEP_ORANGE_500 const val BROWN = BROWN_500 const val GREY = GREY_500 + const val GRAY = GREY_500 const val BLUE_GREY = BLUE_GREY_500 + const val BLUE_GRAY = BLUE_GREY_500 const val BLACK = BLACK_1000 const val WHITE = WHITE_1000 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 2ee571fc..b381e1af 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 @@ -20,6 +20,7 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { override val selfAssignmentFunctions = listOf( ::setIntervalExt.name, + ::keepAlive.name, ) override val globalAssignmentFunctions = listOf( @@ -30,13 +31,14 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { ::clearInterval.name, ::clearImmediate.name, ::loop.name, + ::keepAlive.name, ) companion object : FlexibleArray() { @JvmStatic @RhinoRuntimeFunctionInterface - fun setTimeout(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsAtLeast(args, 1) { + fun setTimeout(scriptRuntime: ScriptRuntime, args: Array): Double = ensureArgumentsAtLeast(args, 1) { val (callbackArg, intervalArg) = it val callback = coerceFunction(callbackArg) val interval = coerceLongNumber(intervalArg, 1L) @@ -49,13 +51,13 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { @JvmStatic @RhinoRuntimeFunctionInterface - fun clearTimeout(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsOnlyOne(args) { + fun clearTimeout(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsOnlyOne(args) { scriptRuntime.timers.clearTimeout(coerceNumber(it)) } @JvmStatic @RhinoRuntimeFunctionInterface - fun setInterval(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsAtLeast(args, 1) { + fun setInterval(scriptRuntime: ScriptRuntime, args: Array): Double = ensureArgumentsAtLeast(args, 1) { val (callbackArg, intervalArg) = it val callback = coerceFunction(callbackArg) val interval = coerceLongNumber(intervalArg, 1L) @@ -68,13 +70,13 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { @JvmStatic @RhinoRuntimeFunctionInterface - fun clearInterval(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsOnlyOne(args) { + fun clearInterval(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsOnlyOne(args) { scriptRuntime.timers.clearInterval(coerceNumber(it)) } @JvmStatic @RhinoRuntimeFunctionInterface - fun setImmediate(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsAtLeast(args, 1) { + fun setImmediate(scriptRuntime: ScriptRuntime, args: Array): Double = ensureArgumentsAtLeast(args, 1) { val (callbackArg) = it val callback = coerceFunction(callbackArg) when (it.size) { @@ -85,7 +87,7 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { @JvmStatic @RhinoRuntimeFunctionInterface - fun clearImmediate(scriptRuntime: ScriptRuntime, args: Array) = ensureArgumentsOnlyOne(args) { + fun clearImmediate(scriptRuntime: ScriptRuntime, args: Array): Boolean = ensureArgumentsOnlyOne(args) { scriptRuntime.timers.clearImmediate(coerceNumber(it)) } @@ -98,6 +100,13 @@ open class Timers(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) { UNDEFINED } + @JvmStatic + @RhinoRuntimeFunctionInterface + fun keepAlive(scriptRuntime: ScriptRuntime, args: Array): Double = ensureArgumentsAtMost(args, 1) { + val (internal) = it + setInterval(scriptRuntime, arrayOf(BaseFunction(), coerceNumber(internal, 10_000))) + } + @JvmStatic @RhinoRuntimeFunctionInterface fun setIntervalExt(scriptRuntime: ScriptRuntime, args: Array): Double = ensureArgumentsLengthInRange(args, 1..4) { diff --git a/version.properties b/version.properties index 52001e99..47deb89c 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Sat Apr 19 02:00:10 CST 2025 -BUILD_TIME=1744999210778 +#Sat Apr 19 16:35:05 CST 2025 +BUILD_TIME=1745051705674 COMPILE_SDK_VERSION=35 JAVA_VERSION=23 JAVA_VERSION_MIN_RADICAL=0 @@ -17,6 +17,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=3150 +VERSION_BUILD=3152 VERSION_NAME=6.6.3 Alpha VSCODE_EXT_REQUIRED_VERSION=1.0.8