feat(ui): 收藏项无元数据时,副标题显示上级文件夹名(带括号)
之前无标签时副标题固定写"收藏",和"歌手"语义混在一起。 现在取 path 的上一级目录(解码后)显示为 "(B-未分类)" 这种形式: - 括号清楚表明是目录,不是艺术家 - 有标签时仍优先显示艺术家 - 目录层级不足或解码失败时回退为空(displaySubtitle 兜底"未知艺术家") 真机验证:收藏项显示 "13楼的大笨象 - 郑融" / "(B-未分类)"。
This commit is contained in:
@@ -35,11 +35,10 @@ class SongItem {
|
||||
: fileName.replaceAll(RegExp(r'\.[^.]*$'), '');
|
||||
|
||||
String get displaySubtitle {
|
||||
if (metadataState == 'success' && artist != null) {
|
||||
if (metadataState == 'success' && artist != null && artist!.isNotEmpty) {
|
||||
return artist!;
|
||||
} else {
|
||||
return sourceTag;
|
||||
}
|
||||
return sourceTag.isNotEmpty ? sourceTag : '未知艺术家';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,12 +271,23 @@ class _HomePageState extends BaseState<HomePage> {
|
||||
displayName = rawName;
|
||||
}
|
||||
|
||||
// 取上级目录名,作为没有标签时的副标题(加括号区分"这是文件夹")
|
||||
final segments = path.split('/').where((s) => s.isNotEmpty).toList();
|
||||
String folderName = '';
|
||||
if (segments.length >= 2) {
|
||||
try {
|
||||
folderName = Uri.decodeComponent(segments[segments.length - 2]);
|
||||
} catch (_) {
|
||||
folderName = segments[segments.length - 2];
|
||||
}
|
||||
}
|
||||
|
||||
items.add(SongItem(
|
||||
path: path,
|
||||
fileName: displayName,
|
||||
title: hasTitle ? title : null,
|
||||
artist: artist.isNotEmpty ? artist : null,
|
||||
sourceTag: '收藏',
|
||||
sourceTag: folderName.isNotEmpty ? '($folderName)' : '',
|
||||
metadataState: hasTitle ? 'success' : 'unknown',
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user