js:锄地一条龙 (#1312)

优化拾取时滚轮移动和日志输出(不会捡一个输出一串日志了)
This commit is contained in:
mno
2025-07-09 16:26:56 +08:00
committed by GitHub
parent a22460f155
commit c68787bf23
2 changed files with 6 additions and 4 deletions

View File

@@ -10,7 +10,7 @@
"type": 6,
"mouseX": 0,
"mouseY": 0,
"time": 100
"time": 50
}
],
"info": {

View File

@@ -1,6 +1,6 @@
//拾取时上下滑动的时间
const timeMoveUp = 600;
const timeMoveDown = 1200;
const timeMoveUp = 500;
const timeMoveDown = 1000;
(async function () {
//自定义配置处理
@@ -380,6 +380,7 @@ async function runPathWithOcr(pathFilePath, targetTexts, blacklistKeywords) {
let lastMoveDown = 0;
let lastPickupTime = new Date();
let lastPickupItem = "";
// 定义状态变量
let state = { completed: false, cancelRequested: false };
// 定义图像路径和目标文本列表
@@ -533,9 +534,10 @@ async function runPathWithOcr(pathFilePath, targetTexts, blacklistKeywords) {
continue;
}
if ((new Date() - lastPickupTime) > 200) {
if ((new Date() - lastPickupTime) > 1000 || ocrResult.text != lastPickupItem) {
log.info(`交互或拾取:"${ocrResult.text}"`);
lastPickupTime = new Date();
lastPickupItem = ocrResult.text;
}
// 计算目标文本的中心Y坐标