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:
+24
-13
@@ -1,5 +1,12 @@
|
||||
|
||||
local URL_GATE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/gate.lua"
|
||||
local args = { ... }
|
||||
local silent = AUTO_UPDATE_SILENT == true or args[1] == "--silent"
|
||||
|
||||
local function log(msg)
|
||||
if not silent then
|
||||
print(msg)
|
||||
end
|
||||
end
|
||||
|
||||
local function writeFile(path, content, binary)
|
||||
local mode = binary and "wb" or "w"
|
||||
@@ -54,25 +61,29 @@ local function httpGet(url)
|
||||
end
|
||||
end
|
||||
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
print("Ticket Gate Updater")
|
||||
print("")
|
||||
print("Downloading gate program...")
|
||||
if not silent then
|
||||
term.clear()
|
||||
term.setCursorPos(1, 1)
|
||||
log("Ticket Gate Updater")
|
||||
log("")
|
||||
end
|
||||
log("Downloading gate program...")
|
||||
|
||||
local ok, code = httpGet(URL_GATE)
|
||||
if not ok or type(code) ~= "string" or #code == 0 then
|
||||
print("Download failed: " .. tostring(code or ""))
|
||||
return
|
||||
error("Download failed: " .. tostring(code or ""))
|
||||
end
|
||||
|
||||
if not atomicWrite("startup.lua", code, false) then
|
||||
print("Write failed: startup.lua")
|
||||
return
|
||||
error("Write failed: startup.lua")
|
||||
end
|
||||
atomicWrite("startup", code, false)
|
||||
if fs.exists("gate.lua") then atomicWrite("gate.lua", code, false) end
|
||||
|
||||
print("")
|
||||
print("Done.")
|
||||
print("Reboot the computer to apply the update.")
|
||||
if not silent then
|
||||
log("")
|
||||
log("Done.")
|
||||
log("Reboot the computer to apply the update.")
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user