feat: 新增列表文件访问端点并兼容旧路径

服务器新增/list.txt接口提供列表文件访问,客户端优先请求该路径,失败时回退到原/uploads/list.txt路径
This commit is contained in:
2026-07-31 20:02:24 +08:00
parent fcf6970e90
commit cd22b1ca3e
2 changed files with 16 additions and 1 deletions
+12
View File
@@ -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');
+4 -1
View File
@@ -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()