From cd22b1ca3ec4412c0b3a55e8de55861844d99bc8 Mon Sep 17 00:00:00 2001 From: HenryDu8133 <813367384@qq.com> Date: Fri, 31 Jul 2026 20:02:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AE=BF=E9=97=AE=E7=AB=AF=E7=82=B9=E5=B9=B6?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=97=A7=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 服务器新增/list.txt接口提供列表文件访问,客户端优先请求该路径,失败时回退到原/uploads/list.txt路径 --- CloudServer/server.js | 12 ++++++++++++ station_broadcast.lua | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CloudServer/server.js b/CloudServer/server.js index e5fa564..ccf795b 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -82,6 +82,18 @@ app.use((req, res, next) => { else if (req.path.endsWith('.ts')) res.type('video/mp2t'); next(); }); + +function sendListFile(res) { + if (!fs.existsSync(listFilePath)) { + return res.status(404).send('list.txt not found'); + } + res.type('text/plain; charset=utf-8'); + res.send(fs.readFileSync(listFilePath, 'utf8')); +} + +app.get('/list.txt', (req, res) => sendListFile(res)); +app.get('/uploads/list.txt', (req, res) => sendListFile(res)); + app.use(express.static(path.join(__dirname, 'public'))); app.set('view engine', 'ejs'); diff --git a/station_broadcast.lua b/station_broadcast.lua index e94ff54..e0df46b 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1012,7 +1012,10 @@ end function Network.syncFiles() -- Sync only config file (list.txt) periodically while true do - local resp = http.get(CONFIG.API_URL .. "/uploads/list.txt") + local resp = http.get(CONFIG.API_URL .. "/list.txt") + if not resp then + resp = http.get(CONFIG.API_URL .. "/uploads/list.txt") + end if resp then local content = resp.readAll() resp.close()