fix: 相对位置互换未命中时给互不包含综合诊断, 不再误导为尺寸错误

This commit is contained in:
yu 2026-11-03 15:07:40 +08:00
parent f0fca2ebfe
commit 58ea001e7d

View File

@ -226,8 +226,13 @@ register("Image_RelativePosition", async (ctx, node, args) => {
}
}
if (!hit) {
if (firstError) throw firstError;
throw new RuntimeError("not_found", "查找目标未出现在被搜索图像中", { nodeId: node.id, componentId: node.componentId, recommendation: "「查找目标」应是被搜索图里出现的小图案(按钮/图标/文字块);两张图互不包含时无法匹配" });
// 互换也没命中:两张图内容互不包含(或真的不存在),给出综合诊断而不是误导性的尺寸错误
throw new RuntimeError("not_found", "查找目标未出现在被搜索图像中(已自动尝试反向查找仍未命中,两张图内容互不包含)", {
nodeId: node.id,
componentId: node.componentId,
detail: firstError instanceof Error ? firstError.message : String(firstError ?? ""),
recommendation: "「被搜索图像」应是较大的底图(如整屏/整窗截图),「查找目标」应是底图中实际出现的小图案(按钮/图标/文字块)的截图;两张完全无关的图无法匹配"
});
}
return hit;
});