Kaynağa Gözat

feat(cockpit): 实施方案B监控面板与视频呈现控制

关联监控规格实施票12:八向云台及镜头速度布局常驻灰态,摄像机最新指标由监控面板入口承接,保留传感器真实错误。统一FLV调音和surface全屏,修复原生源清理、异步解码器容器归属与全屏焦点。离线视频回归68项通过,静态SFC和CSS校验通过;依项目规则未执行build/debug/browser,视觉验收待明确授权。
ChenJZ 4 saat önce
ebeveyn
işleme
518c749443

+ 38 - 0
docs/cockpit-video-panel-design-b.md

@@ -0,0 +1,38 @@
+# 监控面板方案 B:结构与验证边界
+
+## 设计落地
+
+- 色板:深蓝底 #062b3f / #0a3a52,青蓝强调 #35d6e8;画面内部不加发光、蒙版或装饰动画。
+- 设备信息:标题与六项业务字段在顶栏;长编码、位置自动换行,主键不充当业务编码。
+- 桌面:220px 左侧云台面板 + 右侧 16:9 画面。八向圆形控制盘、中心停止、STEP 预设速度、变倍 ±、聚焦 ± 常驻。
+- 工具条:与画面放在同一个 surface,模式、当前模式状态、静音、音量、全屏在画面下方。历史暂停/继续/五种倍速/跳转也在 surface 内。
+- 历史:查询区与最多 180px 高的录像清单在右侧工具条下方,清单内部滚动,不无限推走画面。UTC+8 文本查询,选择片段才建流。
+- 跳转滑杆表示用户选择的秒偏移,不冒充来自设备的实时播放进度;输入与滑杆共同受所选录像时长限制,最终仍通过既有会话层校验。
+- 小屏:640px 以下改为纵向,云台布局压缩但不隐藏;900px 以下收紧两栏间距。模态整体可滚动。
+- 可访问性:控件语义名称、禁用原因、可见焦点、包含输入/结果区的焦点循环,Escape 关闭;减少动画偏好下关闭圆盘呼吸光。
+
+## 入口与指标分区
+
+“监控面板入口”放在既有最新指标卡片内部,使用相同色板与摄像机标识,状态“可查看”只描述视频入口能力,不假装设备在线。
+
+摄像机类型由当前设备档案 type=20 或同业务编码的已加载 typeCode=20 确认;采集记录失败/不可用不再显示为摄像机的指标错误,改中性说明。视频能力查询本身失败、未绑定或实时能力未开放仍显示真实原因。非摄像机的错误、记录和值照旧。
+
+## 呈现控制与安全
+
+沿用捆绑 Jessibuca 3.3.27,不更换 SDK。FLV 启用音频解码但默认静音,静音/音量只调用 mute、audioResume、setVolume,不重新建会话或重播;真实声音仍取决于流包含音轨及浏览器音频许可。全屏目标为整个 surface(画面及工具条),关闭 SDK 自带重复控制栏;不支持/拒绝全屏仅报呈现错误。
+
+SDK 每代独占一个内部 div;异步销毁及过期事件不得破坏后续容器。原生分支清理后恢复当前 src,仍默认静音,不提供原生暂停/seek/下载入口。
+
+父规格明确本期云台仅 UI,所有物理动作保持禁用,包括能力标记为 true 但没有完整命令与停止接缝时。不能以布尔开关把无动作按钮伪装成真实控制;后续物控另行实施与确证。
+
+## 验证边界
+
+本轮运行的是既有视频旅程、三宿主与会话/传输/重连/回放离线回归,不是实际媒体解码或浏览器版式验收。Vue SFC 由离线测试接缝解析;未安装独立 vue-tsc/typecheck 命令,不声称完整类型检查通过。
+
+遵照 [AGENTS.md](<../AGENTS.md>),本轮不运行应用 build/dev/server,也不执行浏览器调试或截图。以下实景核对尚待明确授权或票 13 验收:
+
+- [ ] 在既有 localhost:8000 检查桌面/窄屏版式,长设备名、编码和 17+ 条录像清单。
+- [ ] 真实实时与已有录像出画,画面不变形,工具条全屏后仍可操作。
+- [ ] 有音轨的流取消静音与音量实际生效;无音轨或权限限制不伪称可听见。
+- [ ] 无云台设备圆盘与镜头组全部禁用、无物理命令。
+- [ ] 监控入口文案与摄像机中性指标提示,非摄像机真实错误不被隐藏。

+ 21 - 3
src/modules/cockpit/components/EquipmentDetailSections.vue

@@ -59,6 +59,7 @@
                 v-for="panel in activePanels"
                 :key="panel.name"
                 class="equipment-section"
+                :class="{ 'equipment-section--video': panel.kind === 'metrics' && isCamera }"
                 :data-equipment-section="panel.name"
                 :data-panel-state="panel.section.state || 'empty'"
                 :data-panel-retained="panel.section.retained ? 'true' : 'false'"
@@ -109,8 +110,12 @@
                 <!-- 采集记录:最近50行;分页后只合并当前页相同采集时间。 -->
                 <div v-else-if="panel.kind === 'metrics'" class="equipment-section__list" data-collection-records>
                     <!-- 监控入口属于最新指标卡片本身,不再与指标框并列(维护者 2026-11-18)。 -->
-                    <VideoMonitorEntry :device-code="deviceCode" :monitor-source="monitorSource" />
-                    <!-- A failed section keeps its own honest wording; only a genuinely empty one is neutral here. -->
+                    <p v-if="isCamera" class="equipment-section__hint" data-video-metrics-note>
+                        视频监控通过下方入口查看实时画面与已有录像
+                    </p>
+                    <VideoMonitorEntry :device-code="deviceCode" :monitor-source="monitorSource" @device-resolved="videoDevice = $event" />
+                    <!-- 仅已确认的摄像机不呈现数值采集记录;其它设备保留独立分区的真实状态。 -->
+                    <template v-if="!isCamera">
                     <p v-if="panel.section.state === 'failed'" class="equipment-section__hint" data-metrics-failed>
                         该分区加载失败(其它分区不受影响)
                     </p>
@@ -118,7 +123,7 @@
                         该分区数据不可用(其它分区不受影响)
                     </p>
                     <p v-else-if="!recordTableOf(panel).total" class="equipment-section__hint" data-metrics-empty>
-                        暂无采集记录,可继续查看监控画面
+                        暂无采集记录
                     </p>
                     <template v-else>
                     <p class="equipment-section__note">采集记录(最近50条)</p>
@@ -190,6 +195,7 @@
                         @page="(target) => gotoPage(panel, target)"
                     />
                     </template>
+                    </template>
                 </div>
 
                 <!--
@@ -435,6 +441,13 @@ const props = defineProps({
 
 const sectionsRoot = ref(null)
 const panels = computed(() => equipmentPanels(props.aggregate))
+const videoDevice = ref(null)
+// 档案 type 是 deviceType 的领域字段;只认当前设备的摄像机正证据,不以能力查询失败推断传感器。
+const isCamera = computed(() => {
+    const archive = panels.value.find((panel) => panel.kind === 'archive')?.section.data
+    return String(archive?.type ?? '').trim() === '20'
+        || (videoDevice.value?.deviceCode === props.deviceCode && videoDevice.value?.typeCode === '20')
+})
 
 // ---- 票 46 返工第 1 条:标签页切换(弃用六块竖排的长滚动)----
 
@@ -932,6 +945,11 @@ function isPlaceholder(text) {
     border-color: rgba(255, 59, 82, 0.4);
 }
 
+.equipment-section--video[data-panel-state='failed'],
+.equipment-section--video[data-panel-state='unavailable'] {
+    border-color: rgba(1, 171, 234, 0.24);
+}
+
 .equipment-section[data-panel-state='stale'] {
     border-color: rgba(255, 176, 32, 0.45);
 }

+ 58 - 10
src/modules/cockpit/components/VideoMonitorEntry.vue

@@ -2,19 +2,35 @@
     <div v-if="loading || error || device?.typeCode === '20' || video.state.cleanupError" class="video-entry" data-video-entry>
         <p v-if="loading" class="video-entry__hint">正在确认视频能力…</p>
         <template v-else-if="device?.typeCode === '20'">
-            <button type="button" data-video-open :disabled="device.bound !== true || device.capabilities?.live !== true || Boolean(video.state.cleanupError)" @click="video.open(device, monitorSource)">监控</button>
-            <span v-if="!device.capabilities?.live" class="video-entry__hint">{{ device.unavailableReason || '实时视频能力尚未确认' }}</span>
+            <button type="button" class="video-entry__open" data-video-open aria-label="监控面板入口"
+                :disabled="entryDisabled" :title="disabledReason || '查看实时画面与已有录像'" @click="video.open(device, monitorSource)">
+                <span class="video-entry__camera" aria-hidden="true">
+                    <svg viewBox="0 0 32 32" fill="none"><rect x="4" y="9" width="17" height="14" rx="3" /><path d="m21 13 7-4v14l-7-4M9 5h8" /></svg>
+                </span>
+                <span class="video-entry__copy"><strong>监控面板入口</strong><span>实时画面 · 已有录像</span></span>
+                <span class="video-entry__status" data-video-entry-status><i aria-hidden="true"></i>{{ entryDisabled ? '暂不可用' : '可查看' }}</span>
+                <svg class="video-entry__arrow" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M4 12h15m-6-6 6 6-6 6" /></svg>
+            </button>
+            <span v-if="disabledReason && !video.state.cleanupError" class="video-entry__hint" data-video-unavailable>{{ disabledReason }}</span>
         </template>
-        <p v-if="error" class="video-entry__hint" role="status">{{ error }} <button type="button" @click="load">重查视频能力</button></p>
-        <p v-if="video.state.cleanupError" class="video-entry__hint" role="alert">{{ video.state.cleanupError }} <button type="button" @click="video.retryCleanup">重试清理</button></p>
+        <p v-if="error" class="video-entry__hint" role="status">{{ error }} <button type="button" class="video-entry__retry" @click="load">重查视频能力</button></p>
+        <p v-if="video.state.cleanupError" class="video-entry__hint" role="alert">{{ video.state.cleanupError }} <button type="button" class="video-entry__retry" @click="video.retryCleanup">重试清理</button></p>
     </div>
 </template>
 <script setup>
-import { ref, watch, onBeforeUnmount } from 'vue'
+import { computed, ref, watch, onBeforeUnmount } from 'vue'
 import { useVideoStore } from '../stores/videoStore.js'
 const props = defineProps({ deviceCode: { type: String, required: true }, monitorSource: { type: String, default: 'detail' } })
+const emit = defineEmits(['device-resolved'])
 const video = useVideoStore()
 const device = ref(null), loading = ref(false), error = ref('')
+const entryDisabled = computed(() => device.value?.bound !== true || device.value?.capabilities?.live !== true || Boolean(video.state.cleanupError))
+const disabledReason = computed(() => {
+    if (video.state.cleanupError) return video.state.cleanupError
+    if (device.value?.bound !== true) return device.value?.unavailableReason || '视频设备尚未完成有效绑定'
+    if (device.value?.capabilities?.live !== true) return device.value?.unavailableReason || '实时视频能力尚未确认'
+    return ''
+})
 let generation = 0
 async function load() {
     const version = ++generation
@@ -22,7 +38,10 @@ async function load() {
     if (!props.deviceCode) return
     try {
         const result = await video.loadDevice(props.deviceCode)
-        if (version === generation) device.value = result
+        if (version === generation) {
+            device.value = result
+            emit('device-resolved', result)
+        }
     } catch (failure) { if (version === generation) error.value = failure.message || '视频能力暂不可用' }
     finally { if (version === generation) loading.value = false }
 }
@@ -30,8 +49,37 @@ watch(() => props.deviceCode, load, { immediate: true })
 onBeforeUnmount(() => { generation += 1 })
 </script>
 <style scoped>
-.video-entry { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 10px 0 14px; }
-.video-entry button { color: #c6f7ff; background: #0b5264; border: 1px solid #39879a; border-radius: 4px; padding: 6px 16px; cursor: pointer; }
-.video-entry button:disabled { color: #82949c; background: #243841; border-color: #45616a; cursor: not-allowed; }
-.video-entry__hint { margin: 0; color: #a7bdc7; font-size: 0.85em; }
+.video-entry { display: grid; gap: calc(6 * var(--u, 1px)); min-width: 0; padding: calc(4 * var(--u, 1px)) 0; }
+.video-entry__open {
+    display: grid;
+    grid-template-columns: auto minmax(0, 1fr) auto auto;
+    align-items: center;
+    gap: calc(8 * var(--u, 1px));
+    width: 100%;
+    padding: calc(10 * var(--u, 1px));
+    color: #d9f9ff;
+    background: linear-gradient(110deg, #062b3f, #0a3a52);
+    border: 1px solid #35d6e8;
+    border-radius: calc(6 * var(--u, 1px));
+    text-align: left;
+    font: inherit;
+    cursor: pointer;
+    transition: border-color .15s, box-shadow .15s;
+}
+.video-entry__open:hover:not(:disabled) { border-color: #9ef4ff; box-shadow: inset 0 0 18px #35d6e820; }
+.video-entry__open:focus-visible, .video-entry__retry:focus-visible { outline: 2px solid #35d6e8; outline-offset: 3px; }
+.video-entry__camera { display: grid; place-items: center; width: calc(34 * var(--u, 1px)); height: calc(34 * var(--u, 1px)); border-radius: calc(5 * var(--u, 1px)); color: #35d6e8; background: #35d6e81a; }
+.video-entry__camera svg { width: 80%; height: 80%; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
+.video-entry__copy { display: grid; gap: calc(3 * var(--u, 1px)); min-width: 0; }
+.video-entry__copy strong { font-size: var(--fs-body, 13px); }
+.video-entry__copy > span { color: #a7c9d6; font-size: var(--fs-caption, 10.5px); }
+.video-entry__status { display: inline-flex; align-items: center; gap: calc(4 * var(--u, 1px)); color: #35d6e8; font-size: var(--fs-caption, 10.5px); white-space: nowrap; }
+.video-entry__status i { width: calc(5 * var(--u, 1px)); height: calc(5 * var(--u, 1px)); border-radius: 50%; background: currentColor; }
+.video-entry__arrow { width: calc(20 * var(--u, 1px)); height: calc(20 * var(--u, 1px)); color: #35d6e8; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
+.video-entry__open:disabled { color: #82949c; background: #062b3f; border-color: #45616a; cursor: not-allowed; }
+.video-entry__open:disabled .video-entry__camera { background: #82949c14; }
+.video-entry__open:disabled .video-entry__camera, .video-entry__open:disabled .video-entry__status, .video-entry__open:disabled .video-entry__arrow, .video-entry__open:disabled .video-entry__copy > span { color: #82949c; }
+.video-entry__retry { color: #c6f7ff; background: #0a3a52; border: 1px solid #35d6e8; border-radius: 4px; padding: 4px 10px; font: inherit; cursor: pointer; }
+.video-entry__hint { margin: 0; color: #a7bdc7; font-size: 0.85em; overflow-wrap: anywhere; }
+@media (prefers-reduced-motion: reduce) { .video-entry__open { transition: none; } }
 </style>

+ 134 - 139
src/modules/cockpit/components/VideoMonitorPanel.vue

@@ -1,97 +1,101 @@
 <template>
     <Teleport to="body">
         <div v-if="state.open" class="video-monitor-backdrop">
-            <section class="video-monitor" role="dialog" aria-modal="true" aria-labelledby="video-monitor-title" data-video-monitor>
-                <header>
-                    <div>
-                        <h2 id="video-monitor-title">{{ state.device?.deviceName || '视频监控设备' }}</h2>
-                        <!-- The six fields the operator checks on a monitor device (维护者 2026-11-18). -->
-                        <dl class="video-monitor__meta" data-video-meta>
-                            <div><dt>设备名称</dt><dd data-video-meta-field="deviceName">{{ state.device?.deviceName || '—' }}</dd></div>
-                            <div><dt>业务设备编码</dt><dd data-video-meta-field="businessCode">{{ state.device?.businessCode || state.device?.deviceCode || '—' }}</dd></div>
-                            <div><dt>接入方式</dt><dd data-video-meta-field="accessType">{{ accessTypeText }}</dd></div>
-                            <div><dt>国标设备 / 通道</dt><dd data-video-meta-field="gb">{{ gbText }}</dd></div>
-                            <div><dt>安装位置</dt><dd data-video-meta-field="location">{{ state.device?.location || '—' }}</dd></div>
-                            <div><dt>厂商</dt><dd data-video-meta-field="manufacturer">{{ state.device?.manufacturer || '—' }}</dd></div>
-                        </dl>
-                    </div>
-                    <button type="button" aria-label="关闭监控" @click="video.close">关闭</button>
+            <section class="video-monitor" role="dialog" aria-modal="true" aria-labelledby="video-monitor-title"
+                     data-video-monitor data-video-design="dahua-cockpit-b">
+                <header class="video-monitor__header">
+                    <div><span class="video-monitor__eyebrow">VIDEO / 现场监控</span><h2 id="video-monitor-title">{{ state.device?.deviceName || '视频监控设备' }}</h2></div>
+                    <button type="button" class="video-monitor__close" aria-label="关闭监控" @click="video.close">关闭 <span aria-hidden="true">×</span></button>
                 </header>
-                <div class="video-monitor__tabs">
-                    <button type="button" :aria-pressed="mode === 'live'" @click="switchMode('live')">实时视频</button>
-                    <button type="button" :aria-pressed="mode === 'history'" :disabled="!state.device?.capabilities?.records"
-                            :title="state.device?.capabilities?.records ? '' : '此设备未确认录像能力'" @click="switchMode('history')">历史录像</button>
-                </div>
-                <template v-if="mode === 'history'">
-                    <div class="video-monitor__range">
-                        <label>开始 <input v-model="range.startTime" type="text" placeholder="yyyy-MM-dd HH:mm:ss" /></label>
-                        <label>结束 <input v-model="range.endTime" type="text" placeholder="yyyy-MM-dd HH:mm:ss" /></label>
-                        <button type="button" :disabled="state.historyPhase === 'querying'" @click="video.queryHistory(range.startTime, range.endTime)">查询录像</button>
-                    </div>
-                    <p v-if="state.historyPhase === 'querying'">正在查询录像…</p>
-                    <p v-else-if="state.historyError" role="alert">{{ state.historyError }}</p>
-                    <p v-else-if="state.historyPhase === 'listed' && state.empty">该时间段没有录像(查询范围不代表留存期限)</p>
-                    <ul v-else-if="state.records?.length" class="video-monitor__records">
-                        <li v-for="(record, index) in state.records" :key="index">
-                            <span>{{ record.name || '录像' }}{{ record.type ? ` · ${record.type}` : '' }} {{ record.startTime }} ~ {{ record.endTime }}</span>
-                            <button type="button" @click="playRecord(record)">播放</button>
-                        </li>
-                    </ul>
-                    <!-- Volume and fullscreen are not device capabilities, so they stay usable here;
-                         the native bar was removed only to stop pause/seek bypassing the grey gate. -->
-                    <div v-if="state.playbackMedia" class="video-monitor__playback-controls" data-playback-surface>
-                        <button type="button" data-playback-mute :aria-pressed="playbackMuted"
-                                @click="togglePlaybackMute">{{ playbackMuted ? '取消静音' : '静音' }}</button>
-                        <button type="button" data-playback-fullscreen @click="enterPlaybackFullscreen">全屏</button>
-                        <label v-if="state.playbackControls?.seek" class="video-monitor__seek">
-                            跳到 <input v-model="playbackPosition" type="number" min="0" step="1"
-                                       :max="playbackDuration" data-playback-position /> 秒
-                            <span v-if="playbackDuration" class="video-monitor__seek-max">(本段共 {{ playbackDuration }} 秒)</span>
-                        </label>
-                    </div>
-                    <!-- Unconfirmed playback controls stay visible but grey, each stating why. -->
-                    <div v-if="state.playbackMedia" class="video-monitor__playback-controls">
-                        <button v-for="control in playbackControls" :key="control.key" type="button"
-                                :data-playback-control="control.key" :disabled="!control.enabled"
-                                :title="control.enabled ? '' : control.reason" @click="runControl(control)">{{ control.label }}</button>
-                    </div>
-                </template>
-                <p class="video-monitor__status" role="status">{{ labels[state.phase] || '未播放' }}</p>
-                <p v-if="retryNote" class="video-monitor__status" role="status">{{ retryNote }}</p>
+                <dl class="video-monitor__meta" data-video-meta>
+                    <div><dt>设备名称</dt><dd data-video-meta-field="deviceName">{{ state.device?.deviceName || '—' }}</dd></div>
+                    <div><dt>业务设备编码</dt><dd data-video-meta-field="businessCode">{{ state.device?.businessCode || state.device?.deviceCode || '—' }}</dd></div>
+                    <div><dt>接入方式</dt><dd data-video-meta-field="accessType">{{ accessTypeText }}</dd></div>
+                    <div><dt>国标设备 / 通道</dt><dd data-video-meta-field="gb">{{ gbText }}</dd></div>
+                    <div><dt>安装位置</dt><dd data-video-meta-field="location">{{ state.device?.location || '—' }}</dd></div>
+                    <div><dt>厂商</dt><dd data-video-meta-field="manufacturer">{{ state.device?.manufacturer || '—' }}</dd></div>
+                </dl>
                 <div class="video-monitor__body">
-                    <aside data-ptz-panel>
-                        <h3>云台控制</h3>
-                        <!-- Buttons always exist; an absent capability or permission only greys them (维护者 2026-11-18). -->
-                        <div class="video-monitor__ptz" role="group" aria-label="云台控制">
+                    <aside class="video-monitor__ptz-panel" data-ptz-panel aria-label="云台界面预留">
+                        <div class="video-monitor__section-head"><h3>云台控制</h3><span class="video-monitor__badge">界面预留</span></div>
+                        <div class="video-monitor__ptz-pad" data-ptz-pad role="group" aria-label="八向云台方向盘">
                             <button v-for="key in PTZ_DIRECTIONS" :key="key" type="button" :data-ptz-direction="key"
-                                    :disabled="!ptzEnabled" :title="ptzEnabled ? '' : ptzReason">{{ ptzLabel(key) }}</button>
+                                    :class="'video-monitor__direction--' + key" disabled :title="ptzReason" :aria-label="'云台' + PTZ_LABELS[key]">
+                                <span aria-hidden="true">{{ PTZ_ARROWS[key] }}</span>
+                            </button>
+                            <button type="button" class="video-monitor__ptz-stop" data-ptz-stop disabled :title="ptzReason" aria-label="云台停止"><span aria-hidden="true">■</span><small>停止</small></button>
                         </div>
-                        <div class="video-monitor__ptz" role="group" aria-label="云台变倍">
-                            <button type="button" data-ptz-zoom="in" :disabled="!ptzEnabled" :title="ptzEnabled ? '' : ptzReason">放大</button>
-                            <button type="button" data-ptz-zoom="out" :disabled="!ptzEnabled" :title="ptzEnabled ? '' : ptzReason">缩小</button>
+                        <label class="video-monitor__speed">速度 <span>STEP {{ ptzSpeed }}</span><input v-model="ptzSpeed" type="range" min="1" max="8" step="1" disabled :title="ptzReason" aria-label="云台速度" data-ptz-speed /></label>
+                        <div class="video-monitor__lens" role="group" aria-label="云台镜头控制">
+                            <span>变倍</span><button type="button" data-ptz-zoom="out" disabled :title="ptzReason" aria-label="云台缩小">−</button><button type="button" data-ptz-zoom="in" disabled :title="ptzReason" aria-label="云台放大">+</button>
+                            <span>聚焦</span><button type="button" data-ptz-focus="far" disabled :title="ptzReason" aria-label="云台远焦">−</button><button type="button" data-ptz-focus="near" disabled :title="ptzReason" aria-label="云台近焦">+</button>
                         </div>
-                        <button type="button" data-ptz-stop :disabled="!ptzEnabled" :title="ptzEnabled ? '' : ptzReason">停止</button>
-                        <p v-if="!ptzEnabled" data-ptz-hint>{{ ptzReason }}</p>
+                        <p class="video-monitor__ptz-hint" data-ptz-hint>{{ ptzReason }}</p>
+                        <p class="video-monitor__note">本期仅呈现控制布局,不发送物理控制命令。</p>
                     </aside>
-                    <div class="video-monitor__screen">
-                        <VideoPlayer v-if="state.media" :media="state.media" @ready="video.ready" @error="video.fail" />
-                        <!-- Live and playback share one Jessibuca FLV player; native controls would
-                             also bypass the grey gate, so playback turns them off. -->
-                        <VideoPlayer v-else-if="state.playbackMedia" :media="state.playbackMedia"
-                                     label="历史录像画面" :controls="false"
-                                     @ready="video.readyPlayback" @error="video.failPlayback" />
-                        <p v-else-if="state.phase === 'retrying'">等待自动重连…</p>
-                        <p v-else>{{ state.error || '等待视频连接' }}</p>
+                    <div class="video-monitor__viewer">
+                        <div ref="surface" class="video-monitor__surface" data-video-surface>
+                            <div class="video-monitor__screen">
+                                <VideoPlayer v-if="mode === 'live' && state.media" key="live" :media="state.media" :controls="false"
+                                             :muted="playbackMuted" :volume="volume / 100" @ready="video.ready" @error="video.fail" @presentation-error="presentationError = $event" />
+                                <VideoPlayer v-else-if="mode === 'history' && state.playbackMedia" key="history" :media="state.playbackMedia" :controls="false"
+                                             label="历史录像画面" :muted="playbackMuted" :volume="volume / 100" @ready="video.readyPlayback" @error="video.failPlayback" @presentation-error="presentationError = $event" />
+                                <div v-else class="video-monitor__placeholder"><span aria-hidden="true">▷</span><p>{{ mode === 'history' ? (state.historyError || '请选择已有录像开始回放') : (state.error || '等待视频连接') }}</p></div>
+                            </div>
+                            <div class="video-monitor__toolbar" data-video-toolbar :data-playback-surface="mode === 'history' ? '' : undefined">
+                                <div class="video-monitor__tabs" role="group" aria-label="视频模式">
+                                    <button type="button" :aria-pressed="mode === 'live'" :disabled="switching" @click="switchMode('live')">实时视频</button>
+                                    <button type="button" :aria-pressed="mode === 'history'" :disabled="switching || !state.device?.capabilities?.records"
+                                            :title="state.device?.capabilities?.records ? '' : '此设备未提供录像查询能力'" @click="switchMode('history')">历史录像</button>
+                                </div>
+                                <span class="video-monitor__status" role="status" :data-video-phase="mode === 'live' ? state.phase : state.historyPhase">{{ statusText }}</span>
+                                <div class="video-monitor__presentation">
+                                    <button type="button" data-video-mute :data-playback-mute="mode === 'history' ? '' : undefined" :disabled="!activeMedia" :aria-pressed="playbackMuted"
+                                            :aria-label="playbackMuted ? '取消静音' : '静音'" @click="togglePlaybackMute">{{ playbackMuted ? '取消静音' : '静音' }}</button>
+                                    <label>音量<input v-model="volume" type="range" min="0" max="100" step="1" :disabled="!activeMedia" aria-label="视频音量" data-video-volume /></label>
+                                    <button type="button" data-video-fullscreen :data-playback-fullscreen="mode === 'history' ? '' : undefined" :disabled="!activeMedia" aria-label="视频画面全屏" @click="enterPlaybackFullscreen">全屏</button>
+                                </div>
+                            </div>
+                            <template v-if="mode === 'history' && state.playbackMedia">
+                                <div class="video-monitor__playback-controls" role="group" aria-label="录像回放控制">
+                                    <button v-for="control in playbackControls" :key="control.key" type="button" :data-playback-control="control.key" :disabled="!control.enabled"
+                                            :title="control.enabled ? '' : control.reason" :aria-label="control.label" @click="runControl(control)">{{ control.label }}</button>
+                                </div>
+                                <label v-if="state.playbackControls?.seek" class="video-monitor__seek">跳转位置
+                                    <input v-model="playbackPosition" type="number" min="0" :max="playbackDuration" step="1" aria-label="录像跳转秒数" data-playback-position />
+                                    <span>/ {{ playbackDuration }} 秒</span>
+                                    <input v-model="playbackPosition" type="range" min="0" :max="playbackDuration" step="1" aria-label="选择录像跳转位置" data-playback-seek-slider />
+                                </label>
+                            </template>
+                            <p v-if="presentationError" class="video-monitor__warning" role="alert" data-video-presentation-error>{{ presentationError }}</p>
+                        </div>
+                        <div v-if="mode === 'history'" class="video-monitor__history" data-video-history>
+                            <div class="video-monitor__range">
+                                <label>开始(UTC+8)<input v-model="range.startTime" type="text" placeholder="yyyy-MM-dd HH:mm:ss" aria-label="录像查询开始时间" /></label>
+                                <label>结束(UTC+8)<input v-model="range.endTime" type="text" placeholder="yyyy-MM-dd HH:mm:ss" aria-label="录像查询结束时间" /></label>
+                                <button type="button" :disabled="state.historyPhase === 'querying'" @click="video.queryHistory(range.startTime, range.endTime)">查询录像</button>
+                            </div>
+                            <div class="video-monitor__records-scroll" tabindex="0" aria-label="录像查询结果" data-video-records-region>
+                                <p v-if="state.historyPhase === 'querying'">正在查询录像…</p>
+                                <p v-else-if="state.historyError" role="alert">{{ state.historyError }}</p>
+                                <p v-else-if="state.empty">该时间段没有录像(查询范围不代表留存期限)</p>
+                                <ul v-else-if="state.records?.length" class="video-monitor__records">
+                                    <li v-for="(record, index) in state.records" :key="index" :class="{ 'is-selected': selectedRecord === record }">
+                                        <span><b>{{ record.name || '录像' }}</b><small>{{ record.type || '录像片段' }} · {{ record.startTime }} ~ {{ record.endTime }}</small></span>
+                                        <button type="button" :disabled="switching || state.historyPhase === 'starting'" :aria-label="'播放录像 ' + record.startTime" @click="playRecord(record)">播放</button>
+                                    </li>
+                                </ul>
+                            </div>
+                        </div>
                     </div>
                 </div>
-                <p v-if="state.error && state.media" role="alert">{{ state.error }}</p>
+                <p v-if="retryNote && mode === 'live'" class="video-monitor__status" role="status">{{ retryNote }}</p>
+                <p v-if="state.error && mode === 'live' && state.media" role="alert">{{ state.error }}</p>
                 <p v-if="state.cleanupError" class="video-monitor__warning" role="alert">{{ state.cleanupError }}</p>
-                <footer>
-                    <!-- Live-only: in history mode this would start a live stream beside the playback. -->
-                    <button v-if="mode === 'live' && !state.media && !['starting','connecting','retrying'].includes(state.phase)"
-                            type="button" :disabled="Boolean(state.cleanupError)" @click="video.retry">重新播放</button>
+                <footer class="video-monitor__footer">
+                    <button v-if="mode === 'live' && !state.media && !['starting','connecting','retrying'].includes(state.phase)" type="button" :disabled="Boolean(state.cleanupError)" @click="video.retry">重新播放</button>
                     <button v-if="state.cleanupError" type="button" @click="video.retryCleanup">重试清理</button>
-                    <span>默认静音 · 不提供截图、下载或录制</span>
+                    <span>默认静音 · 不提供截图、下载或录制</span><span>Jessibuca / FLV</span>
                 </footer>
             </section>
         </div>
@@ -111,17 +115,14 @@ const labels = { idle: '未播放', starting: '正在建立视频会话', connec
 // Switching tabs ends the current stream but must keep the monitor open.
 const mode = ref('live')
 const range = reactive(video.historyWindow())
-// PTZ panel: the buttons are always present; only capability/permission greys them out.
-const PTZ_DIRECTIONS = ['up', 'down', 'left', 'right', 'up-left', 'up-right', 'down-left', 'down-right']
+const switching = ref(false)
+// This release presents PTZ only; a capability flag alone must never enable physical commands.
+const PTZ_DIRECTIONS = ['up-left', 'up', 'up-right', 'left', 'right', 'down-left', 'down', 'down-right']
 const PTZ_LABELS = { up: '上', down: '下', left: '左', right: '右', 'up-left': '左上', 'up-right': '右上', 'down-left': '左下', 'down-right': '右下' }
-const ptzLabel = (key) => PTZ_LABELS[key]
-// Real device PTZ control is ticket 06; until the device confirms it, the buttons stay grey with a reason.
-const PTZ_UNCONFIRMED = '设备未确认云台能力或当前无控制权限'
-const ptzEnabled = computed(() => {
-    const device = state.value.device
-    return Boolean(device?.capabilities?.ptz) && !state.value.cleanupError
-})
-const ptzReason = computed(() => state.value.cleanupError ? '会话释放未确认,暂停控制' : PTZ_UNCONFIRMED)
+const PTZ_ARROWS = { up: '↑', down: '↓', left: '←', right: '→', 'up-left': '↖', 'up-right': '↗', 'down-left': '↙', 'down-right': '↘' }
+const ptzSpeed = ref(4)
+const ptzReason = computed(() => state.value.cleanupError ? '会话释放未确认,暂停控制'
+    : state.value.device?.capabilities?.ptz ? '云台操作尚未接入,本期仅界面预留' : '设备暂不支持云台控制')
 // Access mode and GB identifiers come straight from the binding; blanks show as a dash.
 const ACCESS_TEXT = { GB28181: '国标接入', MANUAL: '手工接入' }
 const accessTypeText = computed(() => {
@@ -134,21 +135,28 @@ const gbText = computed(() => {
         ? `${device.gbDeviceId || '—'} / ${device.gbChannelId || '—'}`
         : '—'
 })
+let modeVersion = 0
 const switchMode = async (next) => {
-    if (next === mode.value) return
-    if (next === 'history') {
-        await video.stopLive()
-        mode.value = 'history'
-        await video.queryHistory(range.startTime, range.endTime)
-    } else {
-        await video.stopPlayback()
-        mode.value = 'live'
-        await video.startLive()
-    }
+    if (next === mode.value || switching.value) return
+    const version = ++modeVersion
+    switching.value = true
+    try {
+        if (next === 'history') await video.stopLive()
+        else await video.stopPlayback()
+        // Close, selection changes and unconfirmed cleanup must not resume an old switch.
+        if (version !== modeVersion || !state.value.open || state.value.cleanupError) return
+        mode.value = next
+        if (next === 'history') await video.queryHistory(range.startTime, range.endTime)
+        else await video.startLive()
+    } finally { if (version === modeVersion) switching.value = false }
+}
+const selectedRecord = ref(null)
+const playRecord = async (record) => {
+    playbackPosition.value = ''
+    selectedRecord.value = record
+    await video.play(record.startTime, record.endTime)
 }
-const playRecord = (record) => video.play(record.startTime, record.endTime)
-// Every playback control is advertised with its real availability. Until a device is confirmed,
-// each stays grey with a stated reason instead of silently disappearing.
+// Controls describe the server operation set, not a claim of physical device support.
 const CONTROL_REASON = '服务端未开放此控制能力'
 const playbackControls = computed(() => {
     const granted = state.value.playbackControls || {}
@@ -175,16 +183,21 @@ const runControl = (control) => {
     }
     void video.controlPlayback(control.key)
 }
-// Local presentation only: the player starts muted, and neither action is a device capability.
-const playbackMuted = ref(true)
-const playbackVideo = () => document.querySelector('[data-video-monitor] video[aria-label="历史录像画面"]')
-const togglePlaybackMute = () => {
-    const element = playbackVideo()
-    if (!element) return
-    playbackMuted.value = !playbackMuted.value
-    element.muted = playbackMuted.value
+// Local presentation never creates a new business session or sends a device command.
+const surface = ref(null)
+const playbackMuted = ref(true), volume = ref(50), presentationError = ref('')
+const activeMedia = computed(() => mode.value === 'live' ? state.value.media : state.value.playbackMedia)
+const statusText = computed(() => labels[mode.value === 'live' ? state.value.phase : state.value.historyPhase] || '未播放')
+const togglePlaybackMute = () => { playbackMuted.value = !playbackMuted.value; presentationError.value = '' }
+const enterPlaybackFullscreen = async () => {
+    const target = surface.value
+    presentationError.value = ''
+    try {
+        if (!target?.requestFullscreen) throw new Error('此浏览器不支持画面全屏')
+        await target.requestFullscreen()
+    } catch (error) { presentationError.value = error?.message || '无法进入全屏,请检查浏览器权限' }
 }
-const enterPlaybackFullscreen = () => { void playbackVideo()?.requestFullscreen?.() }
+watch(activeMedia, () => { playbackMuted.value = true; presentationError.value = '' })
 const retryNote = computed(() => state.value.phase !== 'retrying' || !state.value.retryAttempt
     ? ''
     : `第 ${state.value.retryAttempt} 次自动重试,等待 ${Math.round((state.value.retryDelayMs || 0) / 1000)} 秒(剩余 ${state.value.retriesLeft ?? 0} 次)`)
@@ -195,7 +208,10 @@ watch(() => [state.value.ownerSource, detail.selection.deviceCode, enhancement.s
 }, { flush: 'sync' })
 let trigger
 watch(() => state.value.open, async (open) => {
+    modeVersion++; switching.value = false
     if (!open) { if (trigger?.isConnected) trigger.focus?.(); return }
+    mode.value = 'live'; selectedRecord.value = null; playbackPosition.value = ''; playbackMuted.value = true; volume.value = 50
+    Object.assign(range, video.historyWindow())
     trigger = document.activeElement
     await nextTick()
     if (state.value.open) document.querySelector('[data-video-monitor] [aria-label="关闭监控"]')?.focus()
@@ -204,7 +220,10 @@ const keyboard = (event) => {
     if (!state.value.open) return
     if (event.key === 'Escape') { event.preventDefault(); void video.close(); return }
     if (event.key !== 'Tab') return
-    const items = Array.from(document.querySelectorAll('[data-video-monitor] button:not(:disabled), [data-video-monitor] video'))
+    // Fullscreen hides the rest of the dialog; never wrap focus onto an invisible close button.
+    const root = document.fullscreenElement === surface.value ? surface.value : document.querySelector('[data-video-monitor]')
+    const items = Array.from(root?.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), [tabindex="0"]') || [])
+        .filter(element => !element.hidden && element.getAttribute('aria-hidden') !== 'true')
     if (!items.length) return
     const index = items.indexOf(document.activeElement)
     if (index < 0 || (event.shiftKey && index === 0) || (!event.shiftKey && index === items.length - 1)) {
@@ -216,28 +235,4 @@ const leave = () => { void video.close() }
 onMounted(() => { document.addEventListener('visibilitychange', hidden); document.addEventListener('keydown', keyboard); window.addEventListener('pagehide', leave) })
 onBeforeUnmount(() => { document.removeEventListener('visibilitychange', hidden); document.removeEventListener('keydown', keyboard); window.removeEventListener('pagehide', leave); void video.close() })
 </script>
-<style scoped>
-.video-monitor-backdrop { position: fixed; inset: 0; z-index: 15000; display: grid; place-items: center; padding: 24px; background: #0009; }
-.video-monitor { width: min(76vw, 1400px); max-height: 92vh; overflow: auto; color: #e0f6ff; background: #092635f5; border: 1px solid #3a91a5; border-radius: 8px; padding: 20px; box-shadow: 0 20px 90px #0009; font-family: sans-serif; }
-.video-monitor header { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
-.video-monitor h2, .video-monitor h3 { margin: 0 0 8px; }
-.video-monitor header p { margin: 0; color: #9dbbc8; overflow-wrap: anywhere; }
-.video-monitor button { padding: 7px 18px; color: #d8f8ff; background: #14556b; border: 1px solid #448ba0; border-radius: 4px; cursor: pointer; }
-.video-monitor button:disabled { color: #8399a3; background: #263c46; border-color: #49616b; cursor: not-allowed; }
-.video-monitor__meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; margin: 8px 0 0; }
-.video-monitor__meta div { display: flex; gap: 8px; font-size: 13px; color: #b6d4e0; }
-.video-monitor__meta dt { color: #8fb4c2; margin: 0; white-space: nowrap; }
-.video-monitor__meta dd { margin: 0; overflow-wrap: anywhere; }
-.video-monitor__ptz { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
-.video-monitor__tabs { display: flex; gap: 20px; align-items: center; margin-top: 18px; }
-.video-monitor__status { color: #a3d5e3; }
-.video-monitor__body { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; }
-.video-monitor aside { color: #a7c3d0; background: #09212c; padding: 15px; }
-.video-monitor aside p, .video-monitor footer { font-size: 13px; color: #9cb9c5; }
-.video-monitor__screen { min-height: 300px; aspect-ratio: 16 / 9; display: grid; place-items: center; background: #02090e; }
-.video-monitor__screen > :deep(*) { width: 100%; height: 100%; }
-.video-monitor__screen > p { display: grid; place-items: center; margin: 0; }
-.video-monitor__warning { color: #ffc478; }
-.video-monitor footer { display: flex; gap: 16px; align-items: center; margin-top: 15px; }
-@media (max-width: 720px) { .video-monitor { width: 100%; } .video-monitor__body { grid-template-columns: 1fr; } .video-monitor aside { display: none; } }
-</style>
+<style scoped src="./videoMonitorPanel.css"></style>

+ 77 - 62
src/modules/cockpit/components/VideoPlayer.vue

@@ -1,99 +1,114 @@
 <template>
     <div class="cockpit-video-surface">
-        <!-- Native <video> only for a direct non-FLV URL. FLV is decoded by Jessibuca, the same
-             stack the management platform uses, so the cockpit and platform share one player. -->
-        <video
-            v-if="isNative"
-            ref="video"
-            class="cockpit-video-player"
-            :src="nativeSrc"
-            :aria-label="label"
-            :controls="controls" autoplay muted playsinline
-            controlslist="nodownload noremoteplayback noplaybackrate"
-            disablepictureinpicture disableremoteplayback
-            @contextmenu.prevent
-            @playing="emit('ready')"
-            @error="emit('error', { message: '视频地址无法播放,请确认格式和网络' })"
-        />
-        <div v-else ref="decoder" class="cockpit-video-player cockpit-video-decoder" :aria-label="label" data-flv-decoder />
+        <video v-if="isNative" ref="video" class="cockpit-video-player" :aria-label="label"
+               :muted="muted" autoplay playsinline
+               controlslist="nodownload noremoteplayback noplaybackrate" disablepictureinpicture disableremoteplayback
+               @contextmenu.prevent @playing="emit('ready')" @error="emit('error', { message: '视频地址无法播放,请确认格式和网络' })" />
+        <div v-else ref="decoder" class="cockpit-video-player" :aria-label="label" data-flv-decoder />
         <p v-if="errorText" class="cockpit-video-error" role="alert">{{ errorText }}</p>
     </div>
 </template>
-
 <script setup>
 import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
-
-// Replaces the old WebRTC player with a Jessibuca FLV player (tech-stack unification).
 const props = defineProps({
-    media: { type: Object, default: null },
-    label: { type: String, default: '实时视频画面' },
-    controls: { type: Boolean, default: true },
+    media: { type: Object, default: null }, label: { type: String, default: '实时视频画面' },
+    controls: { type: Boolean, default: false }, muted: { type: Boolean, default: true }, volume: { type: Number, default: 0.5 },
 })
-const emit = defineEmits(['ready', 'error'])
-const video = shallowRef(null)
-const decoder = ref(null)
-const errorText = ref('')
+const emit = defineEmits(['ready', 'error', 'presentation-error'])
+const video = shallowRef(null), decoder = shallowRef(null), errorText = ref('')
 const isNative = computed(() => props.media?.kind === 'native' || props.media?.native === true)
-const nativeSrc = computed(() => (isNative.value ? props.media?.url : undefined))
-let player
-let generation = 0
-
+let current, nativeElement, generation = 0
 function loadSdk() {
     if (globalThis.Jessibuca) return Promise.resolve()
     if (!globalThis.__cockpitJessibuca) {
         globalThis.__cockpitJessibuca = new Promise((resolve, reject) => {
             const script = document.createElement('script')
             script.src = import.meta.env.BASE_URL + 'jessibuca/jessibuca.js'
-            script.onload = resolve
+            script.onload = () => {
+                if (globalThis.Jessibuca) resolve()
+                else { globalThis.__cockpitJessibuca = null; script.remove(); reject(new Error('视频播放器加载失败')) }
+            }
             script.onerror = () => { globalThis.__cockpitJessibuca = null; script.remove(); reject(new Error('视频播放器加载失败')) }
             document.head.appendChild(script)
         })
     }
     return globalThis.__cockpitJessibuca
 }
-
-const dispose = () => {
-    generation += 1
-    if (player) { try { player.destroy() } catch { /* already disposed */ } player = null }
-    const element = video.value
-    if (element) { element.pause(); element.removeAttribute('src'); element.load() }
+// Each SDK generation owns a different DOM container: late async destroy cannot empty its successor.
+function dispose() {
+    generation++
+    const owned = current
+    current = null
+    if (owned) {
+        owned.host.remove()
+        try { Promise.resolve(owned.player.destroy()).catch(() => {}) } catch { /* detached resource */ }
+    }
+    // Vue may already have detached the old native branch before this post-flush restart.
+    const oldNative = nativeElement
+    nativeElement = null
+    if (oldNative) { oldNative.pause(); oldNative.removeAttribute('src'); oldNative.load() }
+}
+function applyAudio() {
+    const volume = Number.isFinite(props.volume) ? Math.max(0, Math.min(1, props.volume)) : 0.5
+    try {
+        if (isNative.value && video.value) { video.value.muted = props.muted; video.value.volume = volume }
+        else if (current) {
+            if (props.muted) current.player.mute()
+            else { current.player.audioResume(); current.player.setVolume(volume) }
+        }
+    } catch (error) { emit('presentation-error', error?.message || '无法开启声音,请再次点击取消静音') }
 }
-
-const start = async () => {
+async function start() {
     dispose()
     errorText.value = ''
-    if (!props.media?.url) return
-    const version = generation
-    // Native <video> loads through :src and reports readiness via its own @playing.
-    if (isNative.value) return
+    const version = generation, media = props.media
+    if (!media?.url) return
     try {
         await nextTick()
+        if (version !== generation) return
+        if (isNative.value) {
+            // Teardown must not erase the newly selected native source without restoring it.
+            nativeElement = video.value
+            nativeElement.setAttribute('src', media.url)
+            if (props.controls) video.value.setAttribute('controls', '')
+            else video.value.removeAttribute('controls')
+            applyAudio()
+            await video.value.play()
+            return
+        }
         await loadSdk()
         if (version !== generation || !decoder.value) return
-        player = new globalThis.Jessibuca({
-            container: decoder.value,
-            decoder: import.meta.env.BASE_URL + 'jessibuca/decoder.js',
-            isResize: true, useMSE: false, useWCS: false,
-            hasAudio: false, videoBuffer: 0.2,
-            // View-only cockpit: no screenshot/download controls.
-            operateBtns: { fullscreen: true, screenshot: false, play: false, audio: false },
-            loadingText: '视频加载中',
-        })
-        player.on('error', () => { errorText.value = '视频解码或网络异常,请重试'; emit('error', { message: errorText.value }) })
-        player.on('play', () => emit('ready'))
-        await player.play(props.media.url)
-    } catch (failure) {
-        if (version === generation) { errorText.value = failure.message || '视频加载失败'; emit('error', failure) }
+        const host = document.createElement('div')
+        host.style.width = '100%'; host.style.height = '100%'
+        decoder.value.appendChild(host)
+        let player
+        try {
+            player = new globalThis.Jessibuca({ container: host,
+                decoder: import.meta.env.BASE_URL + 'jessibuca/decoder.js',
+                isResize: true, useMSE: false, useWCS: false, hasAudio: true, isNotMute: false, videoBuffer: 0.2,
+                // The enclosing surface owns fullscreen and volume; no duplicate controls or capture features.
+                operateBtns: { fullscreen: false, screenshot: false, play: false, audio: false }, loadingText: '视频加载中',
+            })
+        } catch (error) { host.remove(); throw error }
+        const owned = { player, host }
+        current = owned
+        const active = () => version === generation && current === owned
+        player.on('error', () => { if (active()) { errorText.value = '视频解码或网络异常,请重试'; emit('error', { message: errorText.value }) } })
+        player.on('play', () => { if (active()) emit('ready') })
+        applyAudio()
+        await player.play(media.url)
+    } catch (error) {
+        if (version === generation) { errorText.value = error?.message || '视频加载失败'; emit('error', error) }
     }
 }
-
 onMounted(start)
 watch(() => props.media, start, { flush: 'post' })
+// Synchronous application keeps audioResume in the real click/input activation chain, without restarting.
+watch(() => [props.muted, props.volume], applyAudio, { flush: 'sync' })
 onBeforeUnmount(dispose)
 </script>
-
 <style scoped>
-.cockpit-video-surface { position: relative; width: 100%; height: 100%; min-height: 260px; background: #060d16; }
-.cockpit-video-player { display: block; width: 100%; height: 100%; min-height: 260px; object-fit: contain; background: #060d16; }
-.cockpit-video-error { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #ffc478; }
+.cockpit-video-surface { position: relative; width: 100%; height: 100%; min-height: 0; background: #02090e; }
+.cockpit-video-player { display: block; width: 100%; height: 100%; object-fit: contain; background: #02090e; }
+.cockpit-video-error { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 16px; color: #ffc478; }
 </style>

+ 111 - 0
src/modules/cockpit/components/videoMonitorPanel.css

@@ -0,0 +1,111 @@
+/* Scheme B: chrome is luminous; the video itself stays untouched. */
+.video-monitor-backdrop { position: fixed; inset: 0; z-index: 15000; display: grid; place-items: center; padding: 20px; background: #020a14b8; }
+.video-monitor { --video-accent: #35d6e8; width: min(1360px, 95vw); max-height: 94vh; overflow: auto; color: #e0f6ff; background: linear-gradient(145deg, #062b3f, #071c2d 65%); border: 1px solid #35d6e873; border-radius: 12px; padding: 20px; box-shadow: 0 28px 90px #000a, inset 0 1px #35d6e831; font: 14px/1.45 system-ui, sans-serif; box-sizing: border-box; }
+.video-monitor *, .video-monitor *::before, .video-monitor *::after { box-sizing: border-box; }
+.video-monitor h2 { font-size: 24px; margin: 3px 0 0; }
+.video-monitor h3 { font-size: 15px; margin: 0; }
+.video-monitor p { margin: 8px 0; }
+.video-monitor button { min-height: 34px; padding: 6px 12px; color: #dbfaff; background: #0a3a52; border: 1px solid #37768a; border-radius: 5px; cursor: pointer; font: inherit; transition: background .15s, border-color .15s, box-shadow .15s; }
+.video-monitor button:hover:not(:disabled) { background: #12516c; border-color: var(--video-accent); box-shadow: 0 0 12px #35d6e82b; }
+.video-monitor button[aria-pressed="true"] { color: #e9fcff; background: #12516c; border-color: #35d6e8; }
+.video-monitor button:disabled { color: #a1b4bf; background: #162d3a; border-color: #405765; cursor: not-allowed; }
+.video-monitor :is(button, input, select, [tabindex]):focus-visible { outline: 2px solid #8aefff; outline-offset: 3px; }
+.video-monitor input { min-width: 0; color: #e0f6ff; background: #051b2b; border: 1px solid #3b6a80; border-radius: 4px; padding: 6px 8px; font: inherit; }
+.video-monitor input[type="range"] { accent-color: var(--video-accent); padding: 0; cursor: pointer; }
+.video-monitor input:disabled { opacity: .6; cursor: not-allowed; }
+.video-monitor__header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
+.video-monitor__eyebrow { color: #74d9ed; font-size: 11px; letter-spacing: .16em; }
+.video-monitor__close span { font-size: 20px; margin-left: 8px; }
+.video-monitor__meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 22px; padding: 14px 0; margin: 12px 0 18px; border-block: 1px solid #35d6e825; }
+.video-monitor__meta div { display: grid; gap: 3px; min-width: 0; }
+.video-monitor__meta dt { color: #9cbdcd; font-size: 12px; }
+.video-monitor__meta dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; }
+.video-monitor__body { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
+.video-monitor__ptz-panel { background: #082538; border: 1px solid #2c5668; border-radius: 8px; padding: 16px; }
+.video-monitor__section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
+.video-monitor__badge { color: #a1b4bf; border: 1px solid #405765; border-radius: 20px; padding: 2px 7px; font-size: 10px; white-space: nowrap; }
+.video-monitor__ptz-pad { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3px; aspect-ratio: 1; margin: 23px 0; padding: 17px; border-radius: 50%; background: radial-gradient(circle, #103b50 38%, #072134 68%); border: 1px solid #3a7484; box-shadow: inset 0 0 25px #35d6e815; }
+.video-monitor__ptz-pad::before { content: ''; position: absolute; inset: -6px; border: 1px solid #35d6e833; border-radius: 50%; pointer-events: none; animation: video-ring 4s ease-in-out infinite; }
+.video-monitor__ptz-pad button { padding: 0; min-height: 0; border-radius: 50%; font-size: 20px; background: #17313f; }
+.video-monitor__direction--up-left { grid-area: 1 / 1; }
+.video-monitor__direction--up { grid-area: 1 / 2; }
+.video-monitor__direction--up-right { grid-area: 1 / 3; }
+.video-monitor__direction--left { grid-area: 2 / 1; }
+.video-monitor__direction--right { grid-area: 2 / 3; }
+.video-monitor__direction--down-left { grid-area: 3 / 1; }
+.video-monitor__direction--down { grid-area: 3 / 2; }
+.video-monitor__direction--down-right { grid-area: 3 / 3; }
+.video-monitor__ptz-pad .video-monitor__ptz-stop { grid-area: 2 / 2; display: grid; place-content: center; font-size: 12px; }
+.video-monitor__ptz-stop small { font-size: 9px; }
+.video-monitor__speed { display: grid; grid-template-columns: 1fr auto; gap: 8px; color: #bad9e7; font-size: 12px; }
+.video-monitor__speed span { color: #8cbed0; }
+.video-monitor__speed input { grid-column: 1 / -1; width: 100%; }
+.video-monitor__lens { display: grid; grid-template-columns: 1fr 40px 40px; align-items: center; gap: 9px; margin: 20px 0; }
+.video-monitor__lens > span { color: #b3ceda; font-size: 12px; }
+.video-monitor__lens button { padding: 0; font-size: 19px; }
+.video-monitor__ptz-hint { padding: 10px; border-left: 2px solid #66818f; background: #112e3e; color: #b3c8d3; font-size: 12px; }
+.video-monitor__note { color: #99b5c7; font-size: 11px; }
+.video-monitor__viewer, .video-monitor__surface { min-width: 0; }
+.video-monitor__surface { border: 1px solid #386273; border-radius: 8px; overflow: hidden; background: #041726; }
+.video-monitor__screen { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #02090e; display: grid; grid-template-rows: minmax(0, 1fr); min-height: 0; }
+.video-monitor__screen > :deep(.cockpit-video-surface) { width: 100%; height: 100%; min-height: 0; }
+.video-monitor__placeholder { display: grid; place-content: center; text-align: center; padding: 16px; color: #a4c3d2; }
+.video-monitor__placeholder > span { font-size: 46px; color: #42748b; }
+.video-monitor__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; background: #0a2b40; border-top: 1px solid #366579; }
+.video-monitor__tabs, .video-monitor__presentation { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
+.video-monitor__presentation { margin-left: auto; }
+.video-monitor__presentation label { display: flex; align-items: center; gap: 6px; color: #b6d6e4; font-size: 12px; }
+.video-monitor__presentation input { width: 70px; }
+.video-monitor__status { color: #99e4f2; font-size: 12px; }
+.video-monitor__playback-controls { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-top: 1px solid #274d60; }
+.video-monitor__playback-controls button { min-width: 49px; }
+.video-monitor__seek { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 10px 10px; color: #aacddd; font-size: 12px; }
+.video-monitor__seek input[type="number"] { width: 85px; }
+.video-monitor__seek input[type="range"] { flex: 1; min-width: 80px; }
+.video-monitor__history { margin-top: 12px; padding: 12px; background: #09263a; border: 1px solid #2c5668; border-radius: 8px; }
+.video-monitor__range { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
+.video-monitor__range label { display: grid; gap: 4px; flex: 1; color: #a9cbd9; font-size: 12px; }
+.video-monitor__range input { width: 100%; min-width: 175px; }
+.video-monitor__records-scroll { max-height: 180px; overflow: auto; scrollbar-width: thin; scrollbar-color: #366c82 #071c2d; }
+.video-monitor__records { margin: 0; padding: 0; list-style: none; }
+.video-monitor__records li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 10px; border-bottom: 1px solid #2a4d61; }
+.video-monitor__records li.is-selected { background: #0a3a52; box-shadow: inset 2px 0 #35d6e8; }
+.video-monitor__records li > span { display: grid; min-width: 0; gap: 3px; }
+.video-monitor__records small { color: #9ebdcd; overflow-wrap: anywhere; }
+.video-monitor__warning { color: #ffc478; padding-inline: 10px; }
+.video-monitor__footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; color: #93b6c9; font-size: 11px; }
+.video-monitor__footer > span:last-child { margin-left: auto; }
+.video-monitor__surface:fullscreen { display: flex; flex-direction: column; justify-content: center; width: 100%; height: 100%; background: #02090e; border: 0; border-radius: 0; }
+.video-monitor__surface:fullscreen .video-monitor__screen { flex: 1; aspect-ratio: auto; min-height: 0; }
+.video-monitor__surface:fullscreen .video-monitor__toolbar { flex-shrink: 0; }
+@keyframes video-ring { 0%, 100% { opacity: .35; } 50% { opacity: .85; }
+}
+@media (prefers-reduced-motion: reduce) {
+.video-monitor__ptz-pad::before { animation: none; }
+.video-monitor button { transition: none; }
+}
+@media (max-width: 900px) {
+.video-monitor__body { grid-template-columns: 190px minmax(0, 1fr); gap: 12px; }
+.video-monitor__ptz-panel { padding: 12px; }
+.video-monitor__meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+.video-monitor__presentation { margin-left: 0; }
+}
+@media (max-width: 640px) {
+.video-monitor-backdrop { padding: 8px; }
+.video-monitor { width: 100%; padding: 12px; }
+.video-monitor__body { grid-template-columns: 1fr; }
+.video-monitor__ptz-panel { display: grid; grid-template-columns: 150px 1fr; gap: 10px 18px; align-items: center; }
+.video-monitor__section-head { grid-column: 1 / -1; }
+.video-monitor__ptz-pad { grid-row: 2 / 5; margin: 8px 0; }
+.video-monitor__lens { margin: 0; grid-template-columns: 1fr 34px 34px; }
+.video-monitor__ptz-hint, .video-monitor__note { grid-column: 1 / -1; }
+.video-monitor__meta { gap: 8px; }
+.video-monitor__range input { min-width: 140px; }
+}
+@media (max-width: 380px) {
+.video-monitor__ptz-panel { grid-template-columns: minmax(0, 1fr); }
+.video-monitor__ptz-pad { grid-row: auto; width: 150px; justify-self: center; }
+.video-monitor__section-head, .video-monitor__ptz-hint, .video-monitor__note { grid-column: 1; }
+.video-monitor__meta { grid-template-columns: 1fr; }
+.video-monitor__seek input[type="range"] { flex-basis: 100%; }
+}

+ 69 - 2
tests/cockpit-video/hosts.mjs

@@ -97,7 +97,7 @@ async function mountRoot({ positioned = false, underground = false } = {}) {
     const selectedCamera = { ...camera, longitude: selectedPoint.longitude, latitude: selectedPoint.latitude, coordinateValidation: location }
     const requests = [], unexpected = [], errors = []
     const server = { snapshotGate: null, pointGate: null, pointFails: false, cameraPresent: true, liveFailures: 0,
-        recordings: [], recordsFail: false, playbackBusy: false, playbackControls: undefined }
+        recordings: [], recordsFail: false, playbackBusy: false, playbackControls: undefined, playbackMedia: undefined }
     const fetchImpl = async (address, options = {}) => {
         const url = new URL(address), path = url.pathname.replace('/api/cockpit/v1', '')
         const body = options.body ? JSON.parse(options.body) : null
@@ -149,7 +149,7 @@ async function mountRoot({ positioned = false, underground = false } = {}) {
             return envelope({ deviceCode: cameraCode, deviceName: device.deviceName,
                 sessionId: 'session-pb', sessionToken: 'owner-pb', mode: 'PLAYBACK',
                 startTime: body.startTime, endTime: body.endTime,
-                media: { native: true, url: 'https://media.invalid/playback.mp4' },
+                media: server.playbackMedia || { native: true, url: 'https://media.invalid/playback.mp4' },
                 ...(server.playbackControls ? { controls: server.playbackControls } : {}) })
         }
         if (path === '/video/sessions/prepare') {
@@ -217,6 +217,34 @@ async function openMainMonitor(page) {
     return document.querySelector('[data-video-monitor]')
 }
 
+test('方案B面板:八向圆盘、速度和镜头控制常驻禁用,工具条紧随画面', async () => {
+    const page = await mountRoot()
+    try {
+        const detail = await openMainDetail(page)
+        assert.equal(detail.querySelector('[data-video-open]').getAttribute('aria-label'), '监控面板入口')
+        const dialog = await openMainMonitor(page)
+        assert.equal(dialog.getAttribute('data-video-design'), 'dahua-cockpit-b')
+        const directions = [...dialog.querySelectorAll('[data-ptz-direction]')]
+        assert.deepEqual(directions.map(b => b.getAttribute('data-ptz-direction')).sort(),
+            ['up','down','left','right','up-left','up-right','down-left','down-right'].sort())
+        assert.ok(dialog.querySelector('[data-ptz-pad] [data-ptz-stop]'), '中心停止在圆盘内')
+        const speed = dialog.querySelector('[data-ptz-speed]')
+        assert.ok(speed); assert.equal(speed.disabled, true)
+        const ptz = [...dialog.querySelectorAll('[data-ptz-panel] button')]
+        assert.ok(dialog.querySelector('[data-ptz-focus="near"]'))
+        assert.ok(dialog.querySelector('[data-ptz-focus="far"]'))
+        assert.ok(ptz.every(b => b.disabled && b.getAttribute('aria-label') && b.getAttribute('title')))
+        const before = page.requests.length
+        ptz.forEach(b => b.click()); await settle()
+        assert.equal(page.requests.length, before, '禁用云台不发送物理命令')
+        const surface = dialog.querySelector('[data-video-surface]')
+        assert.ok(surface.querySelector('[data-video-toolbar]'))
+        assert.ok(surface.querySelector('[data-video-mute]'))
+        assert.ok(surface.querySelector('[data-video-fullscreen]'))
+        assert.equal(surface.querySelector('video').getAttribute('controls'), null, '不用原生栏绕过控制门控')
+    } finally { await page.dispose() }
+})
+
 // 真root→实际Shell固定态→既有点位设备卡→Latest TAB→监控;不直接调用视频store.open。
 for (const positioned of [false, true]) test(`${positioned ? '浮动' : '无地图位置固定'}:真实台账设备详情打开唯一根监控面板`, async () => {
     const page = await mountRoot({ positioned })
@@ -402,6 +430,45 @@ test('监控面板展示六项设备基础信息,缺值显示为破折号', as
     } finally { await page.dispose() }
 })
 
+test('FLV回放工具条位于画面内,调音不重建,重新打开恢复实时与静音', async () => {
+    const players = []
+    globalThis.Jessibuca = class {
+        constructor(options) { this.options = options; this.handlers = new Map(); this.volumes = []; this.mutes = 0; players.push(this) }
+        on(type, fn) { this.handlers.set(type, fn) }
+        async play(url) { this.url = url; this.handlers.get('play')?.() }
+        mute() { this.mutes++ }
+        audioResume() {}
+        setVolume(value) { this.volumes.push(value) }
+        destroy() { this.destroyed = true }
+    }
+    let page
+    try {
+        page = await mountRoot()
+        page.server.recordings = [{ name: 'NVR', startTime: '2026-11-10 01:00:00', endTime: '2026-11-10 02:00:00' }]
+        page.server.playbackMedia = { native: false, ws_flv: 'ws://media.invalid/playback.flv' }
+        const dialog = await openMainMonitor(page)
+        ;[...dialog.querySelectorAll('button')].find(b => b.textContent.trim() === '历史录像').click(); await settle()
+        assert.equal(page.requests.filter(r => r.path.endsWith('/playback')).length, 0)
+        ;[...dialog.querySelectorAll('button')].find(b => b.textContent.trim() === '播放').click(); await settle()
+        assert.equal(players.length, 1)
+        assert.equal(players[0].url, 'ws://media.invalid/playback.flv')
+        assert.equal(dialog.querySelector('[data-video-phase]').textContent.trim(), '正在播放')
+        assert.ok(dialog.querySelector('[data-video-surface] [data-playback-mute]'))
+        assert.ok(dialog.querySelector('[data-video-surface] [data-playback-fullscreen]'))
+        const before = page.requests.length
+        dialog.querySelector('[data-playback-mute]').click(); await settle()
+        assert.equal(players[0].volumes.at(-1), 0.5)
+        assert.equal(players.length, 1)
+        assert.equal(page.requests.length, before)
+        dialog.querySelector('[aria-label="关闭监控"]').click(); await settle()
+        assert.equal(players[0].destroyed, true)
+        const reopened = await openMainMonitor(page)
+        assert.equal(reopened.querySelector('[data-video-mute]').getAttribute('aria-pressed'), 'true')
+        assert.equal(reopened.querySelector('[data-video-history]'), null, '重开不残留历史模式')
+        assert.ok(reopened.querySelector('video'))
+    } finally { await page?.dispose(); delete globalThis.Jessibuca }
+})
+
 test('历史回放占用时提示占用且不释放他人回放', async () => {
     const page = await mountRoot()
     try {

+ 138 - 5
tests/cockpit-video/journey.mjs

@@ -1,10 +1,11 @@
 import assert from 'node:assert/strict'
 import test from 'node:test'
-import { createApp, h, nextTick } from 'vue'
+import { createApp, h, nextTick, shallowRef } from 'vue'
 import { createPinia, setActivePinia } from 'pinia'
 import PointDetailCard from '../../src/modules/cockpit/components/PointDetailCard.vue'
 import VideoMonitorEntry from '../../src/modules/cockpit/components/VideoMonitorEntry.vue'
 import VideoMonitorPanel from '../../src/modules/cockpit/components/VideoMonitorPanel.vue'
+import VideoPlayer from '../../src/modules/cockpit/components/VideoPlayer.vue'
 import { useDetailStore } from '../../src/modules/cockpit/stores/detailStore.js'
 import { useVideoStore } from '../../src/modules/cockpit/stores/videoStore.js'
 import { useEnhancementDevicesStore } from '../../src/modules/cockpit/stores/enhancementDevicesStore.js'
@@ -27,7 +28,7 @@ async function mountJourney(overrides = {}) {
         const body = options.body ? JSON.parse(options.body) : null
         requests.push({ url: new URL(url), path, options, body })
         assert.equal(options.headers?.Authorization, undefined)
-        if (path.endsWith('/detail-aggregate')) return envelope(aggregate)
+        if (path.endsWith('/detail-aggregate')) return envelope(overrides.aggregate || aggregate)
         if (path.endsWith('/collection-records')) return overrides.records?.() || envelope({ deviceCode: code, state: 'EMPTY', recordView: { columns: [], rows: [] } })
         if (path.endsWith('/video/device')) {
             assert.equal(new URL(url).searchParams.get('deviceCode'), code)
@@ -179,10 +180,32 @@ test('collection-record failure does not remove the latest-tab monitoring entry'
     try {
         const dialog = await openMonitor(page)
         assert.ok(dialog.querySelector('video'))
-        assert.ok(page.host.textContent.includes('其它分区不受影响'))
+        assert.ok(page.host.querySelector('[data-video-metrics-note]'))
+        assert.equal(page.host.querySelector('[data-metrics-failed]'), null, '摄像机不渲染采集记录失败提示')
     } finally { await page.dispose() }
 })
 
+test('摄像机指标不可用用监控入口承接,传感器不可用仍如实提示', async () => {
+    for (const camera of [true, false]) {
+        const archive = { ...aggregate, archive: { state: 'SUCCESS', data: { deviceCode: code, deviceName: camera ? '摄像机' : '压力传感器', deviceType: camera ? '20' : '15' } } }
+        const page = await mountJourney({ aggregate: archive,
+            device: camera ? device : { ...device, typeCode: '15', bound: false, capabilities: { live: false } },
+            records: () => envelope({ deviceCode: code, state: 'UNAVAILABLE', recordView: { columns: [], rows: [] } }) })
+        try {
+            page.host.querySelector('[data-equipment-tab="metrics"]').click(); await settle()
+            if (camera) {
+                assert.ok(page.host.querySelector('[data-video-metrics-note]'))
+                assert.equal(page.host.querySelector('[data-metrics-unavailable]'), null)
+                assert.equal(page.host.querySelector('[data-video-open]').getAttribute('aria-label'), '监控面板入口')
+            } else {
+                assert.ok(page.host.querySelector('[data-metrics-unavailable]'))
+                assert.equal(page.host.querySelector('[data-video-metrics-note]'), null)
+                assert.equal(page.host.querySelector('[data-video-open]'), null)
+            }
+        } finally { await page.dispose() }
+    }
+})
+
 test('non-camera has no monitor button; unbound and unknown live capability stay disabled without starting', async () => {
     for (const camera of [
         { ...device, typeCode: '15', bound: false, capabilities: { live: false } },
@@ -293,6 +316,9 @@ test('latest-tab entry plays the returned FLV through Jessibuca and only Jessibu
         on(type, fn) { this.handlers.set(type, fn) }
         emit(type) { this.handlers.get(type)?.() }
         async play(url) { this.url = url; this.emit('play') }
+        mute() {}
+        setVolume() {}
+        audioResume() {}
         destroy() { this.destroyed = true }
     }
     globalThis.RTCPeerConnection = class { constructor(...args) { rtc.push(args) } }
@@ -319,6 +345,114 @@ test('latest-tab entry plays the returned FLV through Jessibuca and only Jessibu
     } finally { delete globalThis.Jessibuca; delete globalThis.RTCPeerConnection }
 })
 
+test('FLV调音和全屏只改变呈现,不重连不发送设备命令', async () => {
+    const players = []
+    globalThis.Jessibuca = class {
+        constructor(options) { this.options = options; this.handlers = new Map(); this.volumes = []; this.mutes = 0; this.resumes = 0; players.push(this) }
+        on(type, fn) { this.handlers.set(type, fn) }
+        async play(url) { this.url = url; this.handlers.get('play')?.() }
+        mute() { this.mutes++ }
+        setVolume(value) { this.volumes.push(value) }
+        audioResume() { this.resumes++ }
+        destroy() { this.destroyed = true }
+    }
+    let page
+    try {
+        page = await mountJourney({ live: () => envelope(livePayload({ flv: 'https://media.invalid/live.flv', native: false })) })
+        const dialog = await openMonitor(page)
+        assert.equal(players.length, 1)
+        assert.equal(players[0].options.hasAudio, true, '静音不能关闭音频解码')
+        assert.ok(players[0].mutes > 0, '默认静音')
+        const before = page.requests.length
+        dialog.querySelector('[data-video-mute]').click(); await settle()
+        assert.equal(players[0].volumes.at(-1), 0.5)
+        assert.ok(players[0].resumes > 0)
+        const slider = dialog.querySelector('[data-video-volume]')
+        slider.value = '25'; slider.dispatchEvent(new Event('input')); await settle()
+        assert.equal(players[0].volumes.at(-1), 0.25)
+        const surface = dialog.querySelector('[data-video-surface]')
+        let entered = null
+        surface.requestFullscreen = async function () { entered = this }
+        dialog.querySelector('[data-video-fullscreen]').click(); await settle()
+        assert.equal(entered, surface, '全屏目标包含画面与工具条,非video选择器')
+        const full = dialog.querySelector('[data-video-fullscreen]')
+        const first = surface.querySelector('button')
+        const activeDescriptor = Object.getOwnPropertyDescriptor(document, 'activeElement')
+        const fullscreenDescriptor = Object.getOwnPropertyDescriptor(document, 'fullscreenElement')
+        let focused = null
+        try {
+            Object.defineProperty(document, 'fullscreenElement', { configurable: true, value: surface })
+            Object.defineProperty(document, 'activeElement', { configurable: true, value: full })
+            first.focus = () => { focused = first }
+            const key = new Event('keydown', { bubbles: true, cancelable: true }); key.key = 'Tab'
+            document.dispatchEvent(key)
+            assert.equal(focused, first, '全屏焦点循环留在画面工具条内')
+        } finally {
+            if (activeDescriptor) Object.defineProperty(document, 'activeElement', activeDescriptor)
+            else delete document.activeElement
+            if (fullscreenDescriptor) Object.defineProperty(document, 'fullscreenElement', fullscreenDescriptor)
+            else delete document.fullscreenElement
+        }
+        surface.requestFullscreen = async () => { throw new Error('全屏权限被拒绝') }
+        dialog.querySelector('[data-video-fullscreen]').click(); await settle()
+        assert.ok(dialog.querySelector('[data-video-presentation-error]').textContent.includes('全屏权限被拒绝'))
+        assert.equal(page.requests.length, before)
+        assert.equal(players.length, 1, '调音和全屏不重建播放器')
+        assert.equal(page.video.state.phase, 'playing', '全屏失败不停止观看')
+    } finally { await page?.dispose(); delete globalThis.Jessibuca }
+})
+
+test('旧解码器迟到回调与异步销毁不能破坏重新打开的画面', async () => {
+    const players = []; let finishOldDestroy
+    globalThis.Jessibuca = class {
+        constructor(options) { this.options = options; this.handlers = new Map(); players.push(this) }
+        on(type, fn) { this.handlers.set(type, fn) }
+        async play() { this.options.container.appendChild(document.createElement('canvas')); this.handlers.get('play')?.() }
+        mute() {}
+        audioResume() {}
+        setVolume() {}
+        destroy() {
+            if (this === players[0]) return new Promise(resolve => { finishOldDestroy = () => { this.options.container.innerHTML = ''; resolve() } })
+            this.options.container.innerHTML = ''
+        }
+    }
+    let page
+    try {
+        page = await mountJourney({ live: () => envelope(livePayload({ native: false, flv: 'https://media.invalid/live.flv' })) })
+        let dialog = await openMonitor(page)
+        const old = players[0]
+        dialog.querySelector('[aria-label="关闭监控"]').click(); await settle()
+        dialog = await openMonitor(page)
+        assert.equal(players.length, 2)
+        assert.notEqual(players[1].options.container, old.options.container)
+        old.handlers.get('error')?.(); old.handlers.get('play')?.(); finishOldDestroy(); await settle()
+        assert.ok(dialog.querySelector('[data-flv-decoder] canvas'))
+        assert.equal(page.video.state.phase, 'playing')
+        assert.equal(page.video.state.error, '')
+        assert.equal(old.options.container.isConnected, false)
+    } finally { finishOldDestroy?.(); await page?.dispose(); delete globalThis.Jessibuca }
+})
+
+test('播放器源由原生切到FLV会显式释放已脱离DOM的旧原生元素', async () => {
+    const media = shallowRef({ kind: 'native', url: 'https://media.invalid/native.mp4' })
+    const host = document.createElement('div'); document.body.appendChild(host)
+    globalThis.Jessibuca = class { on() {} mute() {} audioResume() {} setVolume() {} async play() {} destroy() {} }
+    const app = createApp({ render: () => h(VideoPlayer, { media: media.value }) })
+    try {
+        app.mount(host); await settle()
+        const old = host.querySelector('video')
+        assert.equal(old.getAttribute('src'), 'https://media.invalid/native.mp4')
+        let paused = 0, unloaded = 0
+        old.pause = () => { paused++ }; old.load = () => { unloaded++ }
+        media.value = { kind: 'flv', url: 'ws://media.invalid/live.flv' }; await settle()
+        assert.equal(old.isConnected, false)
+        assert.equal(paused, 1)
+        assert.equal(unloaded, 1)
+        assert.equal(old.getAttribute('src'), null)
+        assert.ok(host.querySelector('[data-flv-decoder]'))
+    } finally { app.unmount(); host.remove(); delete globalThis.Jessibuca }
+})
+
 test('a native (non-FLV) direct URL is played by a <video> that actually carries its src', async () => {
     // Regression guard: the native branch must bind :src, otherwise MANUAL direct-URL devices never show.
     const page = await mountJourney({ live: () => envelope(livePayload({ native: true, url: 'https://media.invalid/direct.mp4' })) })
@@ -327,8 +461,7 @@ test('a native (non-FLV) direct URL is played by a <video> that actually carries
         const element = dialog.querySelector('video')
         assert.ok(element, 'native media must render a <video>')
         assert.equal(page.video.state.media.kind, 'native')
-        // linkeDOM does not reflect a bound src onto attributes/props reliably; assert the component
-        // chose the native branch with the direct URL, and that it renders a <video> (not the decoder div).
+        assert.equal(element.getAttribute('src'), 'https://media.invalid/direct.mp4', 'mounted startup must not clear the native source')
         assert.equal(page.video.state.media.url, 'https://media.invalid/direct.mp4')
         assert.equal(dialog.querySelector('[data-flv-decoder]'), null, 'native media must not use the Jessibuca decoder')
         assert.equal(page.video.state.media.kind, 'native')