From 6398146ee6d04cd0e7e33da296bf80af3def8757 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Tue, 4 Aug 2026 07:37:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(client):=20=E4=BC=98=E5=8C=96=E5=81=9C?= =?UTF-8?q?=E7=AB=99=E9=A2=84=E5=91=8A=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=BD=BB=E5=BA=95=E8=A7=A3=E5=86=B3=E5=81=9C=E7=AB=99?= =?UTF-8?q?=E5=80=92=E7=A7=92=E9=87=8D=E5=A4=8D=E6=92=AD=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复由于列车时刻表中的目的站字符串与 NBT 或显示器获取到的目的地字符串不完全匹配,导致 `isAtStation` 判断失败的问题。 现在判断列车是否在站(`isAtStation`)主要依据 `trainName` 与 `State.currentTrain.id` 是否匹配。 对于未命名列车(如 ??? 或 Unknown),会额外通过模糊匹配或基础名称匹配目的地,从而保证当任何一列车在站台停留期间,系统正确识别它已停站,并忽略它因为离站倒数带来的 `etaSeconds > 0` 从而错误触发进站预告。 --- station_broadcast.lua | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/station_broadcast.lua b/station_broadcast.lua index 8306c97..f30caf4 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.56" +local APP_VERSION_TEXT = "v1.0.57" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group", @@ -2725,7 +2725,20 @@ function Main.loop() end end - local isAtStation = State.currentTrain and State.currentTrain.id == trainName and State.currentTrain.dest == destination + local isAtStation = false + if State.currentTrain then + if State.currentTrain.id == trainName then + if trainName == "???" or trainName == "Unknown" or trainName == "" then + local currentDest = Utils.getBaseName(State.currentTrain.dest) + local nbtDest = Utils.getBaseName(destination) + if currentDest == nbtDest or currentDest:find(nbtDest, 1, true) or nbtDest:find(currentDest, 1, true) then + isAtStation = true + end + else + isAtStation = true + end + end + end if not isAtStation and etaSeconds > 0 and etaSeconds <= 45 then if not seenApproachKeys[announceKey] then seenApproachKeys[announceKey] = true @@ -2863,7 +2876,20 @@ function Main.loop() end end - local isAtStation = State.currentTrain and State.currentTrain.id == tName and State.currentTrain.dest == dest + local isAtStation = false + if State.currentTrain then + if State.currentTrain.id == tName then + if tName == "???" or tName == "Unknown" or tName == "" then + local currentDest = Utils.getBaseName(State.currentTrain.dest) + local nbtDest = Utils.getBaseName(dest) + if currentDest == nbtDest or currentDest:find(nbtDest, 1, true) or nbtDest:find(currentDest, 1, true) then + isAtStation = true + end + else + isAtStation = true + end + end + end if not isAtStation and etaSeconds > 0 and etaSeconds <= 45 then if not seenApproachKeys[announceKey] then seenApproachKeys[announceKey] = true