| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- --[[
- @module tsb_devlog_page
- @summary 设备日志页面
- @version 1.0
- @date 2026.03.04
- @author 李一玮
- @usage
- 本文件是设备日志页面,展示设备的日志信息。
- ]]
- local tsb_devlog_page = {}
- -- 页面UI元素
- local main_container = nil
- local common_ui = require("tsb_common_page")
- -- 创建UI
- function tsb_devlog_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 = 0x82B1FF,
- })
- 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_devlog_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 = 100,
- 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_devlog_page.init(params)
- tsb_devlog_page.create_ui()
- end
- -- 清理页面
- function tsb_devlog_page.cleanup()
- if main_container then
- main_container:destroy()
- main_container = nil
- end
- end
- return tsb_devlog_page
|