feat(playlist): 歌单数据层 + 加入歌单入口

数据层:
- PlaylistSummary(歌单名/歌曲数/封面),DB 用一条 SQL 取摘要,
  封面取歌单内第一首有封面的歌
- PlaylistRepository.getSummaries() / addSongs()(批量加入并去重)
- 修复 AudioService.playPlaylist:之前把文件路径直接当 URL,
  歌单播放必然失败;现在用 WebDAVService.getFileUrl 构造

入口(视觉为临时实现,等设计稿替换):
- 文件列表长按 -> "加入歌单" 底部弹层
- 可在弹层里新建歌单并直接加入

真机验证:长按歌曲 -> 新建 "TL" -> 数据库 playlists/playlist_songs 均有记录。
测试:新增 playlist_summary 4 个用例,累计 29 个全绿。
This commit is contained in:
2026-10-31 22:43:55 +08:00
parent e010a9c0d3
commit 70227afea5
7 changed files with 296 additions and 3 deletions
+4 -3
View File
@@ -296,18 +296,19 @@ class AudioService extends ChangeNotifier {
for (final id in songIds) {
final dbSong = await _db.getSongByPath(id);
if (dbSong != null) {
final path = dbSong['remote_path'] as String;
songs.add(Song(
id: dbSong['remote_path'] as String,
id: path,
title: dbSong['title'] as String? ?? '',
artist: dbSong['artist'] as String? ?? '未知艺术家',
url: dbSong['remote_path'] as String,
url: WebDAVService.instance.getFileUrl(path),
));
} else {
songs.add(Song(
id: id,
title: id.split('/').last.replaceAll(RegExp(r'\.[^.]*$'), ''),
artist: '未知艺术家',
url: id,
url: WebDAVService.instance.getFileUrl(id),
));
}
}