refactor: maintain natural log order in API response and enhance log loading logic

- Updated the API to return logs in their natural order (oldest to newest).
- Modified the loadLogs function in Logs.vue to support incremental updates and maintain scroll position based on user preferences.
- Introduced a hash function to track the last loaded log for efficient updates.
This commit is contained in:
Omar Sánchez Pizarro
2026-01-19 22:54:50 +01:00
parent 2d71f46149
commit 9702edb4de
2 changed files with 84 additions and 25 deletions

View File

@@ -475,10 +475,9 @@ app.get('/api/logs', (req, res) => {
const lines = logs.split('\n').filter(l => l.trim());
const limit = parseInt(req.query.limit) || 100;
const lastLines = lines.slice(-limit);
// Invertir orden para mostrar los más recientes primero
const reversedLines = lastLines.reverse();
// Mantener orden natural: más antiguo a más reciente
res.json({ logs: reversedLines });
res.json({ logs: lastLines });
} catch (error) {
res.status(500).json({ error: error.message });
}