feat: 优化自动更新逻辑,移除单程票购票并升级版本至1.0.18
升级package.json版本至1.0.18;重构update_gate.lua和update_machine.lua,支持--silent静默运行参数,统一日志输出逻辑;优化ticketmachine.lua和gate.lua的自动更新触发逻辑,新增设备空闲检测,避免打断用户操作,仅在空闲时执行静默更新后重启设备;修复ticketmachine.lua中state变量重复声明的问题;移除Web端ticket-order相关的单程票购票UI与业务逻辑,简化购票流程;将gate.lua中的版本检查间隔从5秒调整为60秒,优化设备ID显示格式。
This commit is contained in:
+21
-10
@@ -1,6 +1,7 @@
|
||||
local CURRENT_STATION_CODE = 'Ticket-Machine'
|
||||
local API_BASE = 'http://ticket.fse-media.group/api'
|
||||
local VERSION = 'v1.5.12'
|
||||
local UPDATE_CHECK_INTERVAL = 60
|
||||
|
||||
-- ###########################
|
||||
-- Core HTTP & JSON Utilities
|
||||
@@ -13,6 +14,8 @@ end
|
||||
|
||||
local serverConnected = nil
|
||||
local versionMismatch = nil
|
||||
local pendingMachineUpdate = false
|
||||
local state
|
||||
|
||||
local function normalizeVersionTag(v)
|
||||
local s = tostring(v or ''):gsub('^%s+', ''):gsub('%s+$', '')
|
||||
@@ -652,19 +655,27 @@ local function clickSound() end
|
||||
-- ###########################
|
||||
-- Background Tasks
|
||||
-- ###########################
|
||||
local function runSilentMachineUpdate()
|
||||
local baseEnv = (getfenv and getfenv()) or _ENV or _G
|
||||
local env = setmetatable({ AUTO_UPDATE_SILENT = true }, { __index = baseEnv })
|
||||
return os.run(env, 'update_machine.lua', '--silent')
|
||||
end
|
||||
|
||||
local function backgroundSyncTask()
|
||||
while true do
|
||||
sleep(5)
|
||||
sleep(UPDATE_CHECK_INTERVAL)
|
||||
pcall(refreshConfigOnce)
|
||||
if versionMismatch == true then
|
||||
pcall(function()
|
||||
if shell and type(shell.run) == "function" then
|
||||
shell.run("update_machine.lua")
|
||||
else
|
||||
os.run(getfenv and getfenv() or _ENV, "update_machine.lua")
|
||||
end
|
||||
end)
|
||||
-- Removed os.reboot() to prevent interrupting user unexpectedly
|
||||
pendingMachineUpdate = true
|
||||
elseif versionMismatch == false then
|
||||
pendingMachineUpdate = false
|
||||
end
|
||||
if pendingMachineUpdate and state and tostring(state.page or 'home') == 'home' then
|
||||
local ok, updated = pcall(runSilentMachineUpdate)
|
||||
if ok and updated then
|
||||
os.reboot()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -966,7 +977,7 @@ end
|
||||
-- ###########################
|
||||
-- Pages & Navigation
|
||||
-- ###########################
|
||||
local state = {
|
||||
state = {
|
||||
page = 'home',
|
||||
stationName = (CFG.current_station and (CFG.current_station.en_name or CFG.current_station.name)) or 'Station',
|
||||
stationCode = (CFG.current_station and CFG.current_station.code) or CURRENT_STATION_CODE,
|
||||
|
||||
Reference in New Issue
Block a user