diff --git a/mock/rm-live.mock.ts b/mock/rm-live.mock.ts index bd04277..5a856fa 100644 --- a/mock/rm-live.mock.ts +++ b/mock/rm-live.mock.ts @@ -22,6 +22,30 @@ const liveGameInfo = { src: TEST_HLS, }, ], + fpvData: [ + { + role: '红方机器人视角', + headimg: '', + sources: [ + { + label: '720p', + res: 'high', + src: TEST_HLS, + }, + ], + }, + { + role: '蓝方机器人视角', + headimg: '', + sources: [ + { + label: '720p', + res: 'high', + src: TEST_HLS, + }, + ], + }, + ], }, ], }; diff --git a/src/api/rmApi.ts b/src/api/rmApi.ts index 8f03fa3..e8dd99c 100644 --- a/src/api/rmApi.ts +++ b/src/api/rmApi.ts @@ -273,11 +273,18 @@ export function extractLiveZones(data: LiveGameInfo | null): LiveZoneOption[] { const qualities = source .map((item, qualityIndex) => toQualityOption(item, qualityIndex)) .filter((item): item is LiveQualityOption => item !== null); + const firstFpvHeadimg = + Array.isArray(zone.fpvData) && + zone.fpvData.length > 0 && + typeof zone.fpvData[0].headimg === 'string' && + zone.fpvData[0].headimg.trim() + ? zone.fpvData[0].headimg.trim() + : null; const perspectives: LivePerspectiveOption[] = [ { key: 'main', label: '主视角', - headimg: null, + headimg: firstFpvHeadimg, qualities, }, ]; diff --git a/src/components/layout/LiveStage.vue b/src/components/layout/LiveStage.vue index f5935d0..0befde3 100644 --- a/src/components/layout/LiveStage.vue +++ b/src/components/layout/LiveStage.vue @@ -7,6 +7,7 @@ import Splitter from 'primevue/splitter'; import SplitterPanel from 'primevue/splitterpanel'; import { computed, defineAsyncComponent } from 'vue'; import LivePlayer from '../live/LivePlayer.vue'; +import PerspectiveSwitcher from '../live/PerspectiveSwitcher.vue'; import type { DanmuMessage } from '../../types/api'; const dataStore = useRmDataStore(); @@ -68,6 +69,11 @@ function onDanmuReset() {