feat: 在后端增加解析远程 Gitea 最新版本号的接口并展示在前端

This commit is contained in:
2026-08-16 11:40:47 +08:00
parent 298308b7f3
commit b74eb252e3
4 changed files with 34 additions and 9 deletions
+17
View File
@@ -2372,6 +2372,23 @@ function convertToDfpwm(filePath) {
}
// Routes
app.get('/api/remote-version', async (req, res) => {
try {
const response = await fetch('https://gitea.fse-media.group/Henry_Du/CC-StationBroadcast/raw/branch/main/station_broadcast.lua');
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const text = await response.text();
const match = text.match(/local\s+APP_VERSION_TEXT\s*=\s*["']([^"']+)["']/);
if (match) {
res.json({ success: true, version: String(match[1]).trim() });
} else {
res.json({ success: false, message: 'Version match failed' });
}
} catch (e) {
log('ERROR', `Failed to fetch remote version: ${e.message}`);
res.status(500).json({ success: false, message: e.message });
}
});
app.get('/api/version', (req, res) => {
res.json({ version: audioVersion });
});