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

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

真机验证:长按歌曲 -> 新建 "TL" -> 数据库 playlists/playlist_songs 均有记录。
测试:新增 playlist_summary 4 个用例,累计 29 个全绿。
2026-10-31 22:43:55 +08:00

34 lines
909 B
Dart

// lib/models/playlist_summary.dart
/// 歌单列表用的轻量摘要(不加载歌单内全部歌曲)
class PlaylistSummary {
final String id;
final String name;
final int songCount;
/// 封面:取歌单里第一首有封面的歌
final String? coverPath;
final int updatedAt;
const PlaylistSummary({
required this.id,
required this.name,
this.songCount = 0,
this.coverPath,
this.updatedAt = 0,
});
factory PlaylistSummary.fromRow(Map<String, dynamic> row) {
final cover = (row['cover_path'] as String?)?.trim() ?? '';
return PlaylistSummary(
id: row['id'] as String? ?? '',
name: (row['name'] as String?)?.trim() ?? '',
songCount: (row['song_count'] as num?)?.toInt() ?? 0,
coverPath: cover.isEmpty ? null : cover,
updatedAt: (row['updated_at'] as num?)?.toInt() ?? 0,
);
}
bool get isEmpty => songCount == 0;
}