fix(ui): 收藏列表文件名解码,避免显示成百分号编码串
收藏项没有元数据时回退文件名,但 path 是百分号编码的播放路径, 直接截取会显示 "13%E6%A5%BC%E7%9A%84..." 这种不可读内容。 - 展示前对文件名做 Uri.decodeComponent,解码失败才用原串 - 播放仍使用编码后的原 path,不受影响 验证:收藏 "13楼的大笨象 - 郑融" 在首页正常显示中文歌名。
This commit is contained in:
@@ -261,9 +261,20 @@ class _HomePageState extends BaseState<HomePage> {
|
||||
final title = (row?['title'] as String?)?.trim() ?? '';
|
||||
final artist = (row?['artist'] as String?)?.trim() ?? '';
|
||||
final hasTitle = title.isNotEmpty;
|
||||
|
||||
// path 是百分号编码的(播放时必须保持),显示前要解码,
|
||||
// 否则没有元数据的收藏会显示成 "13%E6%A5%BC..." 这种不可读串。
|
||||
final rawName = path.split('/').last;
|
||||
String displayName;
|
||||
try {
|
||||
displayName = Uri.decodeComponent(rawName);
|
||||
} catch (_) {
|
||||
displayName = rawName;
|
||||
}
|
||||
|
||||
items.add(SongItem(
|
||||
path: path,
|
||||
fileName: path.split('/').last,
|
||||
fileName: displayName,
|
||||
title: hasTitle ? title : null,
|
||||
artist: artist.isNotEmpty ? artist : null,
|
||||
sourceTag: '收藏',
|
||||
|
||||
Reference in New Issue
Block a user