From e82229193cdc0b9f08297f36f6e51cf5af5c3fc1 Mon Sep 17 00:00:00 2001
From: Cranyozen <61766249+Cranyozen@users.noreply.github.com>
Date: Thu, 21 May 2026 18:00:55 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=A7=86=E8=A7=92?=
=?UTF-8?q?=E5=88=87=E6=8D=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E7=BA=A2=E6=96=B9=E5=92=8C=E8=93=9D=E6=96=B9=E6=9C=BA=E5=99=A8?=
=?UTF-8?q?=E4=BA=BA=E8=A7=86=E8=A7=92=EF=BC=8C=E6=9B=B4=E6=96=B0=E7=9B=B8?=
=?UTF-8?q?=E5=85=B3=E6=A0=B7=E5=BC=8F=E5=92=8C=E6=B5=8B=E8=AF=95=E7=94=A8?=
=?UTF-8?q?=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mock/rm-live.mock.ts | 24 ++
src/api/rmApi.ts | 9 +-
src/components/layout/LiveStage.vue | 11 +
src/components/live/LivePlayer.vue | 115 ++++++---
src/components/live/PerspectiveSwitcher.vue | 273 ++++++++++++++++++++
src/styles/primevue-theme.css | 40 +++
src/utils/__tests__/rmStreamView.test.ts | 30 ++-
src/utils/rmStreamView.ts | 4 +-
8 files changed, 466 insertions(+), 40 deletions(-)
create mode 100644 src/components/live/PerspectiveSwitcher.vue
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