|
|
@@ -15,7 +15,10 @@
|
|
|
<text class="cover-icon">🎵</text>
|
|
|
</view>
|
|
|
<text class="title">{{ audio?.title || '未知标题' }}</text>
|
|
|
- <text class="meta">{{ formatDuration(audio?.audioDuration || 0) }} · {{ audio?.wordCount || 0 }}字</text>
|
|
|
+ <text class="meta">
|
|
|
+ {{ albumName || '默认专辑' }}
|
|
|
+ <text v-if="playlist.length > 1"> · {{ currentIndex + 1 }}/{{ playlist.length }}</text>
|
|
|
+ </text>
|
|
|
</view>
|
|
|
|
|
|
<!-- 文本预览 -->
|
|
|
@@ -235,6 +238,7 @@ const audioStore = useAudioStore();
|
|
|
// 状态
|
|
|
const audioId = ref('');
|
|
|
const audio = ref<AudioItem | null>(null);
|
|
|
+const albumName = ref(''); // 专辑名称
|
|
|
const showRatePicker = ref(false);
|
|
|
const showTimerPicker = ref(false);
|
|
|
const showSharePanel = ref(false);
|
|
|
@@ -416,6 +420,18 @@ async function fetchAudio() {
|
|
|
const result = await get<AudioItem>(`/audio/${audioId.value}`);
|
|
|
audio.value = result;
|
|
|
|
|
|
+ // 获取专辑信息
|
|
|
+ if (result.albumId) {
|
|
|
+ try {
|
|
|
+ const album = await get<any>(`/albums/${result.albumId}`);
|
|
|
+ albumName.value = album.name || '默认专辑';
|
|
|
+ } catch {
|
|
|
+ albumName.value = '默认专辑';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ albumName.value = '默认专辑';
|
|
|
+ }
|
|
|
+
|
|
|
// 开始播放(store 中已初始化 audioContext)
|
|
|
audioStore.play(result);
|
|
|
} catch (error: any) {
|
|
|
@@ -431,11 +447,15 @@ async function fetchPlaylist() {
|
|
|
page: 1,
|
|
|
pageSize: 100,
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 设置播放列表(不自动播放,因为已经在 fetchAudio 中播放了当前音频)
|
|
|
- const index = result.list.findIndex(item => (item.id || item._id) === audioId.value);
|
|
|
+ const audioIdNum = parseInt(audioId.value);
|
|
|
+ const index = result.list.findIndex(item => (item.id || item._id) === audioIdNum);
|
|
|
if (index >= 0) {
|
|
|
audioStore.setPlaylist(result.list, index, false);
|
|
|
+ } else if (result.list.length > 0) {
|
|
|
+ // 如果没找到匹配的,使用第一个
|
|
|
+ audioStore.setPlaylist(result.list, 0, false);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('获取播放列表失败:', error);
|