perf: 校验实时选择器

This commit is contained in:
lisonge 2024-01-18 21:36:47 +08:00
parent 25d3c64630
commit b7a1b30f15

View File

@ -503,12 +503,12 @@ class GkdAbService : CompositionAbService({
fun execAction(gkdAction: GkdAction): ActionResult {
val serviceVal = service ?: throw RpcError("无障碍没有运行")
val selector = try {
Selector.parse(gkdAction.selector)
} catch (e: Exception) {
throw RpcError("非法选择器")
val selector = Selector.parseOrNull(gkdAction.selector) ?: throw RpcError("非法选择器")
selector.propertyNames.forEach { n ->
if (!allowPropertyNames.contains(n)) {
throw RpcError("未知属性名:$n")
}
}
val targetNode =
serviceVal.safeActiveWindow?.querySelector(selector, gkdAction.quickFind)
?: throw RpcError("没有选择到节点")