fix: 修复更新逻辑,调整版本显示并同步版本号
- 新增失败更新版本跟踪变量,避免重复触发同一失败版本的更新 - 调整版本指示器的绘制逻辑,优化标记文本的显示效果 - 修复强制更新的触发校验条件,完善整体更新流程 - 初始化缺失的state变量并同步两个文件的程序版本号
This commit is contained in:
+16
-11
@@ -1,6 +1,6 @@
|
||||
local CURRENT_STATION_CODE = 'Ticket-Machine'
|
||||
local API_BASE = 'http://ticket.fse-media.group/api'
|
||||
local VERSION = 'v1.5.13.1'
|
||||
local VERSION = 'v1.5.13'
|
||||
local UPDATE_CHECK_INTERVAL = 5
|
||||
|
||||
-- ###########################
|
||||
@@ -13,10 +13,12 @@ local function jsonDecode(str)
|
||||
end
|
||||
|
||||
local serverConnected = nil
|
||||
local expectedMachineVersion = nil
|
||||
local versionMismatch = nil
|
||||
local failedUpdateVersion = nil
|
||||
local pendingMachineUpdate = false
|
||||
local isUpdating = false
|
||||
local state
|
||||
local state = {}
|
||||
|
||||
local function normalizeVersionTag(v)
|
||||
local s = tostring(v or ''):gsub('^%s+', ''):gsub('%s+$', '')
|
||||
@@ -665,6 +667,12 @@ end
|
||||
local function backgroundSyncTask()
|
||||
pcall(refreshConfigOnce)
|
||||
while true do
|
||||
if type(CFG) == 'table' and type(CFG.force_update) == 'boolean' and CFG.force_update == true and versionMismatch == true then
|
||||
if expectedMachineVersion ~= failedUpdateVersion then
|
||||
pendingMachineUpdate = true
|
||||
end
|
||||
end
|
||||
|
||||
if pendingMachineUpdate and state and tostring(state.page or 'home') == 'home' then
|
||||
isUpdating = true
|
||||
pcall(drawVersionIndicator)
|
||||
@@ -676,14 +684,11 @@ local function backgroundSyncTask()
|
||||
end
|
||||
isUpdating = false
|
||||
pendingMachineUpdate = false
|
||||
failedUpdateVersion = expectedMachineVersion
|
||||
pcall(drawVersionIndicator)
|
||||
end
|
||||
sleep(UPDATE_CHECK_INTERVAL)
|
||||
pcall(refreshConfigOnce)
|
||||
|
||||
if type(CFG) == 'table' and type(CFG.force_update) == 'boolean' and CFG.force_update == true and versionMismatch == true then
|
||||
pendingMachineUpdate = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1110,23 +1115,23 @@ end
|
||||
local function drawVersionIndicator()
|
||||
if w < 1 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(tostring(VERSION))
|
||||
if w >= (#tostring(VERSION) + #markerText) then
|
||||
termDev.setTextColor(markerColor)
|
||||
termDev.write(markerText)
|
||||
end
|
||||
termDev.setTextColor(markerColor)
|
||||
termDev.write(markerText)
|
||||
termDev.setTextColor(colors.white)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user