Skip to content

Commit 16637e7

Browse files
authored
Merge pull request #977 from WorldSansha/fix/podcast-fullplayer-nav
🐞 fix: 修复播客电台跳转失败并优化播客信息展示
2 parents 49dbce6 + 4c5454b commit 16637e7

5 files changed

Lines changed: 47 additions & 8 deletions

File tree

src/components/Player/MainPlayer.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
<!-- 歌手 -->
9898
<div v-else class="artists">
9999
<TextContainer :speed="0.5" class="artists-container">
100-
<n-text v-if="musicStore.playSong.type === 'radio'" class="ar-item">
101-
播客电台
100+
<n-text v-if="musicStore.playSong.type === 'radio'" class="ar-item" @click="showCreatorTip">
101+
{{ musicStore.playSong.dj?.creator || "未知艺术家" }}
102102
</n-text>
103103
<template v-else-if="Array.isArray(musicStore.playSong.artists)">
104104
<n-text
@@ -424,6 +424,9 @@ const instantLyrics = computed(() => {
424424
? `${contentStr}( ${content?.translatedLyric} )`
425425
: contentStr || "";
426426
});
427+
428+
// 暂不支持查看主播主页
429+
const showCreatorTip = () => window.$message.info("暂不支持查看主播主页");
427430
</script>
428431

429432
<style lang="scss" scoped>

src/components/Player/PlayerMeta/PlayerData.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@
106106
<div v-else class="artists">
107107
<SvgIcon :depth="3" name="Artist" size="20" />
108108
<div class="ar-list">
109-
<span class="ar">{{ musicStore.playSong.dj?.creator || "未知艺术家" }}</span>
109+
<span class="ar" @click="showCreatorTip">
110+
{{ musicStore.playSong.dj?.creator || "未知艺术家" }}
111+
</span>
110112
</div>
111113
</div>
112114
<!-- 专辑 -->
@@ -135,7 +137,7 @@
135137
<div
136138
v-if="musicStore.playSong.type === 'radio'"
137139
class="dj"
138-
@click="jumpPage({ name: 'dj', query: { id: musicStore.playSong.dj?.id } })"
140+
@click="jumpToRadio"
139141
>
140142
<SvgIcon :depth="3" name="Podcast" size="20" />
141143
<span class="name-text text-hidden">{{ musicStore.playSong.dj?.name || "播客电台" }}</span>
@@ -152,6 +154,7 @@ import { removeBrackets } from "@/utils/format";
152154
import { SongUnlockServer } from "@/core/player/SongManager";
153155
import { useLyricManager } from "@/core/player/LyricManager";
154156
import { usePlayerController } from "@/core/player/PlayerController";
157+
import { radioProgramDetail } from "@/api/radio";
155158
const props = defineProps<{
156159
/** 数据居中 */
157160
center?: boolean;
@@ -253,6 +256,36 @@ const jumpPage = debounce(
253256
trailing: false,
254257
},
255258
);
259+
260+
// 暂不支持查看主播主页
261+
const showCreatorTip = () => window.$message.info("暂不支持查看主播主页");
262+
263+
// 跳转到播客电台页面
264+
const jumpToRadio = debounce(
265+
async () => {
266+
const song = musicStore.playSong;
267+
let radioId = song.dj?.radioId;
268+
// 兼容旧数据:通过节目详情 API 获取电台 ID
269+
if (!radioId && song.id) {
270+
try {
271+
const res = await radioProgramDetail(song.id);
272+
radioId = res.program?.radio?.id;
273+
// 回写避免重复请求
274+
if (radioId && song.dj) song.dj.radioId = radioId;
275+
} catch (_e) {
276+
// ignore
277+
}
278+
}
279+
if (!radioId) return;
280+
statusStore.showFullPlayer = false;
281+
router.push({ name: "radio", query: { id: radioId } });
282+
},
283+
300,
284+
{
285+
leading: true,
286+
trailing: false,
287+
},
288+
);
256289
</script>
257290

258291
<style lang="scss" scoped>

src/core/player/MediaSessionManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ class MediaSessionManager {
235235
return {
236236
title: song!.name,
237237
artist: isRadio
238-
? "播客电台"
238+
? song!.dj?.creator || "未知播客"
239239
: Array.isArray(song!.artists)
240240
? song!.artists.map((a) => a.name).join("/")
241241
: String(song!.artists),
242242
album: isRadio
243-
? "播客电台"
243+
? song!.dj?.name || "未知播客"
244244
: typeof song!.album === "object"
245245
? song!.album.name
246246
: String(song!.album),

src/types/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export type MetaData = {
99

1010
export type DjData = {
1111
id: number;
12+
/** 所属电台 ID */
13+
radioId?: number;
1214
name: string;
1315
creator?: string;
1416
};

src/utils/format.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const formatSongsList = (data: any[]): SongType[] => {
8484
dj: item.dj
8585
? {
8686
id: item.mainTrackId || item.id,
87+
radioId: item.radio?.id,
8788
name: item.dj?.brand,
8889
creator: item.dj?.nickname,
8990
}
@@ -358,15 +359,15 @@ export const getPlayerInfoObj = (
358359
// 歌手
359360
const artist =
360361
playSongData.type === "radio"
361-
? "播客电台"
362+
? playSongData.dj?.creator || "未知播客"
362363
: Array.isArray(playSongData.artists)
363364
? playSongData.artists.map((artists: { name: string }) => artists.name).join(sep)
364365
: String(playSongData?.artists || "未知歌手");
365366

366367
// 专辑
367368
const album =
368369
playSongData.type === "radio"
369-
? "播客电台"
370+
? playSongData.dj?.name || "未知播客"
370371
: typeof playSongData.album === "object"
371372
? playSongData.album.name
372373
: String(playSongData.album || "未知专辑");

0 commit comments

Comments
 (0)