mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-01 20:42:50 +08:00
fix: add play mode toggle, wire play history API, add back navigation buttons
- Add play mode cycle button (seq/loop/random/rloop) to Player bar - Wire GET /api/player/:botId/history to query database instead of returning empty array - Pass database instance from server.ts to createPlayerRouter - Add back navigation button to Playlist, Lyrics, History, Search, and Settings views - SongCard already had dblclick-to-play (no change needed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9dce883384
commit
ee5a75ab5e
8 files changed
+141
-4
No files matched your search
+20
-3
@@ -1,11 +1,13 @@
|
||||
import { Router } from "express";
|
||||
import type { BotManager } from "../../bot/manager.js";
|
||||
import type { BotDatabase } from "../../data/database.js";
|
||||
import type { Logger } from "../../logger.js";
|
||||
import { parseCommand } from "../../bot/commands.js";
|
||||
|
||||
export function createPlayerRouter(
|
||||
botManager: BotManager,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
database?: BotDatabase
|
||||
): Router {
|
||||
const router = Router();
|
||||
|
||||
@@ -132,8 +134,23 @@ export function createPlayerRouter(
|
||||
});
|
||||
|
||||
router.get("/:botId/history", (req, res) => {
|
||||
// Will be wired when database access is available through bot
|
||||
res.json({ history: [] });
|
||||
if (!database) {
|
||||
res.json({ history: [] });
|
||||
return;
|
||||
}
|
||||
const limit = parseInt(req.query.limit as string) || 50;
|
||||
const records = database.getPlayHistory(req.params.botId, limit);
|
||||
const history = records.map((r) => ({
|
||||
id: r.songId,
|
||||
name: r.songName,
|
||||
artist: r.artist,
|
||||
album: r.album,
|
||||
duration: 0,
|
||||
coverUrl: r.coverUrl,
|
||||
platform: r.platform,
|
||||
playedAt: r.playedAt,
|
||||
}));
|
||||
res.json({ history });
|
||||
});
|
||||
|
||||
return router;
|
||||
|
||||
Reference in new issue
Block a user