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() {
+
+
= [];
- const perspectiveOptions = props.perspectiveOptions ?? [];
- if (perspectiveOptions.length > 1) {
- const selectedPerspective =
- perspectiveOptions.find((item) => item.value === props.selectedPerspectiveKey) ?? perspectiveOptions[0];
- settings.push({
- name: 'perspective',
- html: '视角',
- tooltip: selectedPerspective?.label ?? '主视角',
- icon: '',
- selector: perspectiveOptions.map((item) => ({
- html: item.label,
- value: item.value,
- default: item.value === selectedPerspective?.value,
- })),
- onSelect(item) {
- const value = typeof item.value === 'string' ? item.value : '';
- if (value) {
- emit('perspectiveChange', value);
- }
- return item.html;
- },
- });
- }
-
if (danmuEnabledAtLoad) {
settings.push({
html: filterActive.value ? `过滤 ${activeFilterCount.value}` : '过滤',
@@ -770,24 +747,81 @@ function buildPlayerSettings() {
return settings;
}
-function updatePerspectiveSetting() {
+const PERSPECTIVE_ICON_VIDEO = ``;
+const PERSPECTIVE_ICON_CAMERA = ``;
+
+function buildPerspectiveIconHtml(item: { value: string; headimg: string | null }): string {
+ if (item.headimg) {
+ return `
`;
+ }
+ return item.value === 'main' ? PERSPECTIVE_ICON_VIDEO : PERSPECTIVE_ICON_CAMERA;
+}
+
+function getPerspectiveColor(label: string): string {
+ if (label.includes('红')) return 'rgba(252,165,165,0.95)';
+ if (label.includes('蓝')) return 'rgba(147,197,253,0.95)';
+ return '';
+}
+
+function trimPerspectiveLabel(label: string): string {
+ return label.replace(/第.视角/g, '').trim();
+}
+
+function updatePerspectiveControl() {
if (!player || !playerReady) {
return;
}
- const perspectiveSetting = buildPlayerSettings().find((item) => item.name === 'perspective');
+ const perspectiveOptions = props.perspectiveOptions ?? [];
const p = player as Artplayer & {
- setting?: { update?: (option: NonNullable