From 9accc4e2970856e967079830e3fa14977c21a88c Mon Sep 17 00:00:00 2001 From: OvOAuto <44537598+OvOAuto@users.noreply.github.com> Date: Tue, 24 Feb 2026 21:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=BF=AE=E6=94=B9=E7=94=BB?= =?UTF-8?q?=E8=B4=A8=E4=B8=8E=E9=9F=B3=E9=87=8Fv1.2.1=20(#2922)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add JS AutoSwitchGraphicsSettings * fix: 修复manifest.json版本号 * 修复若干问题 * fix: 识别结果是undefined时跳过此选项 --- repo/js/AutoSwitchGraphicsSettings/main.js | 15 +++++++++++++-- repo/js/AutoSwitchGraphicsSettings/manifest.json | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/repo/js/AutoSwitchGraphicsSettings/main.js b/repo/js/AutoSwitchGraphicsSettings/main.js index 8629a1891..e090b7bb3 100644 --- a/repo/js/AutoSwitchGraphicsSettings/main.js +++ b/repo/js/AutoSwitchGraphicsSettings/main.js @@ -62,9 +62,16 @@ const findOption = async (optionName) => { let gameRegion = captureGameRegion(); let ocrList = gameRegion.findMulti(RecognitionObject.ocrThis); gameRegion.Dispose(); - for(let i = 0;i < ocrList.count; i++) - if(ocrList[i].Text === optionName) + if(!ocrList || ocrList.count === 0) { + log.error("未能找到选项:{name}", optionName); + return null; + } + for (let i = 0; i < ocrList.count; i++) { + if (ocrList[i].Text === optionName) return ocrList[i]; + } + log.error("未能找到选项:{name}", optionName); + return null; }; // 普通模式点击选项 @@ -72,6 +79,8 @@ const chooseOption = async (optionName, order) => { if(order === 0) return; // 默认选项,跳过 let res = await findOption(optionName); + if(!res) + return; // 未找到此选项 let x = res.x, y = res.y; click(x + 1000, y + 25); // 点击选项的下拉栏,依赖选项名称的相对位置 await sleep(100); @@ -111,6 +120,8 @@ const dragOption = async (optionName, size) => { if(Number.isNaN(size) || size < 0 || size > 10) return; // 音量大小不合法,跳过 let res = await findOption(optionName); + if(!res) + return; // 未找到此选项 let x = res.x, y = res.y; for(let i = 25;i <= 39;++i) // 鲁棒性 click(x + 955 + 32 * size, y + i); diff --git a/repo/js/AutoSwitchGraphicsSettings/manifest.json b/repo/js/AutoSwitchGraphicsSettings/manifest.json index 2cd4f2743..8daa5aac5 100644 --- a/repo/js/AutoSwitchGraphicsSettings/manifest.json +++ b/repo/js/AutoSwitchGraphicsSettings/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "自动修改画质与音量", - "version": "1.2", + "version": "1.2.1", "bgi_version": "0.57.0", "description": "自动调整画质和音量,用于便捷切换锄地省电画质和游戏体验画质",