fix: 修复更新逻辑,调整版本显示并同步版本号

- 新增失败更新版本跟踪变量,避免重复触发同一失败版本的更新
- 调整版本指示器的绘制逻辑,优化标记文本的显示效果
- 修复强制更新的触发校验条件,完善整体更新流程
- 初始化缺失的state变量并同步两个文件的程序版本号
This commit is contained in:
2026-07-10 23:55:47 +08:00
parent 565f0008dd
commit f0b8db1662
2 changed files with 29 additions and 18 deletions
+13 -7
View File
@@ -1,7 +1,7 @@
local DEFAULT_SERVER_BASE = "http://ticket.fse-media.group"
local DEFAULT_SERVER_PATH = "/api/tickets/check"
local GATE_OPEN_SECONDS = 2
local VERSION = "v1.5.12"
local VERSION = "v1.5.13"
local VERSION_CHECK_INTERVAL = 5
local CONFIG_PATH = "gate_config.json"
@@ -90,6 +90,8 @@ local inspection = peripheral.find("ticket_inspection_machine")
local serverConnected = nil
local versionMismatch = nil
local expectedGateVersion = nil
local failedUpdateVersion = nil
local pendingGateUpdate = false
local remoteForceUpdate = false
local isUpdating = false
@@ -163,23 +165,23 @@ local function drawVersionIndicator(w)
if #s == 0 then return end
if w < #s then return end
local markerColor = colors.yellow
local markerText = "*"
local markerText = "* "
if isUpdating then
markerColor = colors.yellow
markerText = "^ing"
elseif versionMismatch == true then
markerColor = colors.red
markerText = "* "
elseif versionMismatch == false then
markerColor = colors.lime
markerText = " "
end
termDev.setBackgroundColor(colors.black)
termDev.setTextColor(colors.gray)
termDev.setCursorPos(1, 1)
termDev.write(s)
if w >= (#s + #markerText) then
termDev.setTextColor(markerColor)
termDev.write(markerText)
end
termDev.setTextColor(markerColor)
termDev.write(markerText)
termDev.setTextColor(colors.white)
end
@@ -405,6 +407,7 @@ local function refreshRemoteLuaVersion(serverBase)
return true
end
local function inferStationCodeFromName(name)
local key = normKey(name or "")
if #key == 0 then return "" end
@@ -1428,7 +1431,9 @@ while true do
refreshRemoteLuaVersion(guessBaseFromStatusURL(serverURL))
end)
if remoteForceUpdate and versionMismatch == true then
pendingGateUpdate = true
if expectedGateVersion ~= failedUpdateVersion then
pendingGateUpdate = true
end
end
if pendingGateUpdate and isGateIdleForUpdate() then
@@ -1442,6 +1447,7 @@ while true do
end
isUpdating = false
pendingGateUpdate = false
failedUpdateVersion = expectedGateVersion
end
drawReadyScreen()
versionTimer = os.startTimer(VERSION_CHECK_INTERVAL)