From 228077a49c68989043931e4029d79b9cb4452681 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Sat, 15 Aug 2026 19:25:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(gate):=20=E4=BF=AE=E5=A4=8D=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E7=9A=84=20splitDisplayLines=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=BC=E8=87=B4=E7=9A=84=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 splitDisplayLines 函数,用于按换行符拆分多行显示文本 - 处理 nil 输入、空字符串及无换行场景的边界情况 - 版本号从 v1.5.30 升级至 v1.5.31 --- gate.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gate.lua b/gate.lua index 3de6b07..2a5ed3c 100644 --- a/gate.lua +++ b/gate.lua @@ -1,7 +1,7 @@ local DEFAULT_SERVER_BASE = "https://ticket.fse-media.group" local DEFAULT_SERVER_PATH = "/api/tickets/check" local GATE_OPEN_SECONDS = 2 -local VERSION = "v1.5.30" +local VERSION = "v1.5.31" local VERSION_CHECK_INTERVAL = 5 local PERIPHERAL_WAIT_INTERVAL = 0.5 local PERIPHERAL_WAIT_MAX_RETRIES = 40 @@ -440,6 +440,18 @@ end local _cachedDrawArgHash = nil +local function splitDisplayLines(s) + if s == nil then return {} end + local str = tostring(s) + if #trim(str) == 0 then return {} end + local lines = {} + for line in str:gmatch("[^\n]+") do + table.insert(lines, line) + end + if #lines == 0 then table.insert(lines, str) end + return lines +end + local function draw(statusLine1, statusLine2, statusColor) clear() if not termDev then return end