feat(ui): WebDAV 文件列表改用元数据标题/艺术家显示

之前列表只显示文件名,即使 DB 里已经有标签。
- SongDatabase 新增 getSongsByPaths():一次批量按路径查(分块 400,避开变量上限)
- WebDAVFileListPage:
  * 加载目录后批量取元数据,title/artist 有值就替换文件名
  * 副标题显示 "艺术家 · 大小",没有标签时仍显示大小
  * 监听 AudioService,正在播放的歌补全元数据后立即刷新对应行
  * 没有标签的新歌自然回退文件名,不影响使用
This commit is contained in:
2026-10-24 20:41:21 +08:00
parent 18308d9d4e
commit 0a1ebfa5df
2 changed files with 90 additions and 2 deletions
+27
View File
@@ -256,6 +256,33 @@ class SongDatabase {
return result.isNotEmpty ? result.first : null;
}
/// 批量按路径查元数据,返回 path -> row。
/// 文件列表页一次要显示几十上百首,逐条查会太慢。
Future<Map<String, Map<String, dynamic>>> getSongsByPaths(
List<String> paths) async {
final result = <String, Map<String, dynamic>>{};
if (paths.isEmpty) return result;
final db = await database;
const chunkSize = 400; // 避免 SQLite 变量数量上限
for (var i = 0; i < paths.length; i += chunkSize) {
final end = (i + chunkSize) > paths.length ? paths.length : i + chunkSize;
final slice = paths.sublist(i, end);
final placeholders = List.filled(slice.length, '?').join(',');
final rows = await db.query(
'songs',
where: 'remote_path IN ($placeholders)',
whereArgs: slice,
);
for (final row in rows) {
final path = row['remote_path'] as String?;
if (path != null) result[path] = row;
}
}
_logQuery('songs', 'getByPaths', args: {'count': result.length});
return result;
}
Future<Map<String, dynamic>?> getSongByHash(String contentHash) async {
_logQuery('songs', 'getByHash', args: {'content_hash': contentHash});
final db = await database;