--[[ @module tsb_log_page @summary 本机日志页面 @version 1.0 @date 2026.03.04 @author 李一玮 @usage 本文件是设备日志页面,展示设备的日志信息。 ]] local tsb_log_page = {} -- 页面UI元素 local main_container = nil local common_ui = require("tsb_common_page") -- 创建UI function tsb_log_page.create_ui() main_container = airui.container({ x = 0, y = 0, w = 480, h = 320, color = 0xF5F5F5, }) --------------------- 标题栏 ------------------------ local title_bar = airui.container({ parent = main_container, x = 0, y = 0, w = 480, h = 30, color = 0xFFCCBC, }) airui.label({ parent = title_bar, text = "本机日志", x = 190, y = 8, w = 200, h = 20, font_size = 16, color = 0xFFFFFF, }) -- 标题栏公共信息展示 common_ui.add_battery_display(title_bar) common_ui.create_back_button(title_bar, tsb_log_page.cleanup) --------------------------------------------------- -- 滚动容器 local scroll_container = airui.container({ parent = main_container, x = 0, y = 30, w = 480, h = 270, color = 0xFFFFFF, }) --------------------- 设备日志显示 ------------------------ local log_container = airui.container({ parent = scroll_container, x = 0, y = 50, w = 480, h = 215, color = 0xFFFFFF, }) -- 日志内容显示 local log_content = airui.textarea({ parent = log_container, x = 5, y = 5, w = 470, h = 205, max_len = 10000, text = "[2024-07-02 09:30:46] app start\n" .. "[2024-07-02 09:30:47] init done\n" .. "[2024-07-02 09:30:48] connect success\n" .. "[2024-07-02 09:30:50] start monitor\n" .. "[2024-07-02 09:31:00] detect device 1\n" .. "[2024-07-02 09:31:10] detect device 2\n" .. "[2024-07-02 09:31:20] upload success\n" .. "[2024-07-02 09:31:30] system running\n" .. "[2024-07-02 09:31:30] system status: normal\n", }) --------------------- 控制按钮 ------------------------ -- 开始检测按钮 local start_btn = airui.button({ parent = scroll_container, x = 10, y = 10, w = 120, h = 35, text = "查看本机日志", --stype = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 }, on_click = function(self) log.info("devlog", "开始检测按钮被点击") end }) -- 清空按钮 -- local clear_btn = airui.button({ -- parent = scroll_container, -- x = 120, -- y = 10, -- w = 80, -- h = 35, -- text = "清空", -- on_click = function(self) -- log.info("devlog", "清空按钮被点击") -- -- 清空日志内容 -- log_content:set_text(" ") -- end -- }) --------------------------------------------------- --------------------------------------------------- -- 底部信息 common_ui.create_status_bar(main_container) end -- 初始化页面 function tsb_log_page.init(params) tsb_log_page.create_ui() end -- 清理页面 function tsb_log_page.cleanup() if main_container then main_container:destroy() main_container = nil end end return tsb_log_page