fix(station_broadcast): 修复 Utils 为 nil 导致启动崩溃的前向引用问题
- 原因: Lua local 变量按声明顺序起作用域,Peripherals.init() 在 L96 定义(体内 L188 引用 Utils.log),而 local Utils={} 原本在 L195 才声明,导致函数体内引用成 _G.Utils(全局,nil)
- 修复: 在文件 L71 附近集中前向声明所有顶层模块(Peripherals / Utils / Display / Audio / Network / Main),删除各章节头部重复的 local Module = {},保证 Lua 解析时能正确捕获 local 上值
- APP_VERSION_TEXT bump 到 v1.0.108
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
-- 1. Configuration & Constants
|
||||
local APP_VERSION_TEXT = "v1.0.107"
|
||||
local APP_VERSION_TEXT = "v1.0.108"
|
||||
|
||||
local CONFIG = {
|
||||
CLOUD_URL = "ws://stabadmin.fse-media.group",
|
||||
@@ -69,6 +69,11 @@ local State = {
|
||||
-- 3. Peripherals Setup
|
||||
|
||||
local Peripherals = {}
|
||||
local Utils = {}
|
||||
local Display = {}
|
||||
local Audio = {}
|
||||
local Network = {}
|
||||
local Main = {}
|
||||
|
||||
function Peripherals.isTrainStationPeripheral(name)
|
||||
if not name then
|
||||
@@ -190,7 +195,6 @@ end
|
||||
|
||||
-- 4. Utility Functions
|
||||
|
||||
local Utils = {}
|
||||
|
||||
function Utils.log(level, message)
|
||||
if level == "DEBUG" and not CONFIG.DEBUG then return end
|
||||
@@ -1106,7 +1110,6 @@ end
|
||||
|
||||
-- 5. Audio System
|
||||
|
||||
local Audio = {}
|
||||
|
||||
function Audio.createStream()
|
||||
local chunks = {}
|
||||
@@ -2718,7 +2721,6 @@ end
|
||||
-- ============================================================================
|
||||
-- 6. Network System
|
||||
-- ============================================================================
|
||||
local Network = {}
|
||||
|
||||
function Network.connect()
|
||||
if State.ws then return end
|
||||
@@ -3080,7 +3082,6 @@ end
|
||||
|
||||
-- 7. Display System
|
||||
|
||||
local Display = {}
|
||||
|
||||
function Display.render()
|
||||
local mon = Peripherals.primaryMonitor
|
||||
@@ -3490,7 +3491,7 @@ end
|
||||
|
||||
-- 8. Main Logic
|
||||
|
||||
local Main = {}
|
||||
|
||||
State.announcedApproaching = {}
|
||||
State.announcedAlerts = {}
|
||||
State.pendingAlerts = {}
|
||||
|
||||
Reference in New Issue
Block a user