fix: 确保在站列车(包括终点站列车)始终显示在预测列表中
- 当 State.currentTrain 存在时,手动将其信息插入 upcomingTrains 列表头部 - 解决终点站列车被 CRN 导航系统从 TrainStops 提前移除导致预测区无显示的问题 - 使用 normalizeUpcomingKey 去重,避免重复条目 - 版本号 v1.0.68 -> v1.0.69
This commit is contained in:
+29
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
-- 1. Configuration & Constants
|
||||
local APP_VERSION_TEXT = "v1.0.68"
|
||||
local APP_VERSION_TEXT = "v1.0.69"
|
||||
|
||||
local CONFIG = {
|
||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||
@@ -3480,6 +3480,34 @@ function Main.loop()
|
||||
State.currentTrain = nil
|
||||
end
|
||||
end
|
||||
|
||||
if State.currentTrain then
|
||||
local ctKey = normalizeUpcomingKey(State.currentTrain.id, State.currentTrain.dest)
|
||||
local alreadyInUpcoming = false
|
||||
for _, ut in ipairs(State.upcomingTrains) do
|
||||
local utKey = normalizeUpcomingKey(ut.trainName, ut.dest)
|
||||
if utKey == ctKey then
|
||||
alreadyInUpcoming = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not alreadyInUpcoming then
|
||||
local nowSec = os.epoch("utc") / 1000
|
||||
local remaining = State.currentTrain.departureTime and math.max(0, State.currentTrain.departureTime - nowSec) or 0
|
||||
table.insert(State.upcomingTrains, 1, {
|
||||
trainName = State.currentTrain.id,
|
||||
dest = State.currentTrain.dest,
|
||||
platform = State.currentTrain.platform or State.stationPlatform or "1",
|
||||
eta = 0,
|
||||
etaLabel = buildEtaLabel(0, nil),
|
||||
delay = 0,
|
||||
cancelled = false,
|
||||
reason = nil,
|
||||
_atStation = true,
|
||||
_departingIn = remaining
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
Display.render()
|
||||
Display.renderTerminal()
|
||||
|
||||
Reference in New Issue
Block a user