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:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user