mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 06:47:00 +00:00
fix(installer/updater): 修复版本显示和更新流程问题
- 在installer.lua中添加INSTALLER_VERSION常量替代_VERSION - 更新update.lua中的版本检查流程和用户提示 - 改进updater的界面显示,添加顶部名称栏 - 统一更新确认提示为小写[y/n] - 将"stage"改为更准确的"step"描述
This commit is contained in:
@@ -9,11 +9,33 @@ if not package.loaded.http then
|
||||
io.stderr:write("The HTTP API is disabled and the updater cannot continue. Please enable the HTTP API in the ComputerCraft configuration and try again.\n")
|
||||
return
|
||||
end
|
||||
term.at(1, 1).clear()
|
||||
|
||||
term.at(1,1).clear()
|
||||
-- 程序顶部名称栏
|
||||
local term = require("term")
|
||||
local colors = require("colors")
|
||||
-- 保存当前颜色设置
|
||||
local old_fg = term.getTextColor()
|
||||
local old_bg = term.getBackgroundColor()
|
||||
|
||||
-- 设置名称栏颜色并显示
|
||||
term.setTextColor(colors.white)
|
||||
term.setBackgroundColor(colors.cyan)
|
||||
term.at(1, 1).clearLine()
|
||||
term.at(1, 1).write("=== LeonOS Updater ===")
|
||||
|
||||
-- 恢复颜色设置
|
||||
term.setTextColor(old_fg)
|
||||
term.setBackgroundColor(old_bg)
|
||||
term.at(1, 2)
|
||||
-- 只清除顶栏以下的区域
|
||||
for y=2, term.getSize() do
|
||||
term.at(1, y).clearLine()
|
||||
end
|
||||
term.at(1, 2)
|
||||
|
||||
textutils.coloredPrint(colors.yellow,
|
||||
"LeonOS Updater (Stage 1)\n===========================")
|
||||
"LeonOS Updater (Step 1)\n===========================")
|
||||
|
||||
print("Checking for update...")
|
||||
|
||||
@@ -36,7 +58,7 @@ if newVersion and (oldVersion ~= newVersion) or (...) == "-f" then
|
||||
colors.red, oldVersion, colors.yellow, " -> ", colors.lime,
|
||||
newVersion or oldVersion)
|
||||
|
||||
io.write("Apply update? [y/N]: ")
|
||||
io.write("Apply update? [y/n]: ")
|
||||
if io.read() ~= "y" then
|
||||
textutils.coloredPrint(colors.red, "Not applying update.")
|
||||
return
|
||||
@@ -45,7 +67,7 @@ if newVersion and (oldVersion ~= newVersion) or (...) == "-f" then
|
||||
textutils.coloredPrint(colors.green, "Applying update.")
|
||||
local handle, err = http.get(base.."updater.lua", nil, true)
|
||||
if not handle then
|
||||
error("Failed downloading stage 2: " .. err, 0)
|
||||
error("Failed downloading step 2: " .. err, 0)
|
||||
end
|
||||
|
||||
local data = handle.readAll()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
-- LeonOS installer
|
||||
|
||||
local INSTALLER_VERSION = "0.1.1"
|
||||
local DEFAULT_ROM_DIR = "/rc"
|
||||
|
||||
print("Start loading LeonOS installer...")
|
||||
print("[Installer] Loading module 1")
|
||||
local function dl(f)
|
||||
@@ -86,7 +87,7 @@ for y=2, term.getSize() do
|
||||
end
|
||||
term.at(1, 2)
|
||||
tu.coloredPrint(colors.yellow,
|
||||
"LeonOS Installer (v".._VERSION..")\n=======================")
|
||||
"LeonOS Installer (v"..INSTALLER_VERSION..")\n=======================")
|
||||
tu.coloredPrint("You are going to install LeonOS to your computer.")
|
||||
tu.coloredPrint("This will ",colors.red,"overwrite any existing files", colors.white, " in the installation directory.")
|
||||
tu.coloredPrint(colors.yellow, "Are you sure? (y/n)")
|
||||
|
||||
Reference in New Issue
Block a user