index.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. <template>
  2. <div class="page-container">
  3. <!-- 搜索表单 -->
  4. <div class="search-form">
  5. <el-form :model="searchForm" inline>
  6. <el-form-item :label="t('关键词')">
  7. <el-input
  8. v-model.trim="searchForm.keyword"
  9. placeholder="搜索名称/流水号"
  10. clearable
  11. @keyup.enter="handleSearch"
  12. />
  13. </el-form-item>
  14. <el-form-item :label="t('状态')">
  15. <el-select v-model="searchForm.enabled" placeholder="全部" clearable style="width: 120px">
  16. <el-option :label="t('启用')" :value="true" />
  17. <el-option :label="t('禁用')" :value="false" />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" :icon="Search" @click="handleSearch">{{ t('查询') }}</el-button>
  22. <el-button :icon="RefreshRight" @click="handleReset">{{ t('重置') }}</el-button>
  23. <el-button type="primary" :icon="Plus" @click="handleAdd">{{ t('新增') }}</el-button>
  24. </el-form-item>
  25. </el-form>
  26. </div>
  27. <!-- 数据表格 -->
  28. <div class="table-wrapper">
  29. <el-table
  30. ref="tableRef"
  31. v-loading="loading"
  32. :data="streamList"
  33. stripe
  34. size="default"
  35. height="100%"
  36. @sort-change="handleSortChange"
  37. >
  38. <el-table-column prop="streamSn" :label="t('stream sn')" width="220" show-overflow-tooltip>
  39. <template #default="{ row }">
  40. <el-link type="primary" @click="handleEdit(row)">{{ row.streamSn }}</el-link>
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="name" :label="t('名称')" show-overflow-tooltip>
  44. <template #default="{ row }">
  45. <span>{{ row.name }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="lssId" :label="t('LSS')" width="160" show-overflow-tooltip>
  49. <template #default="{ row }">
  50. <span>{{ row.lssId || '-' }}</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="cameraId" :label="t('设备ID')" width="120" show-overflow-tooltip>
  54. <template #default="{ row }">
  55. <span>{{ row.cameraId || '-' }}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column prop="pushMethod" :label="t('推流方式')" width="120" align="center">
  59. <template #default="{ row }">
  60. <el-tag size="small">{{ row.pushMethod || 'ffmpeg' }}</el-tag>
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="commandTemplate" :label="t('命令模板')" width="100" align="center">
  64. <template #default="{ row }">
  65. <el-link type="primary" @click="openCommandDialog(row)">{{ t('查看') }}</el-link>
  66. </template>
  67. </el-table-column>
  68. <el-table-column :label="t('推流控制')" width="100" align="center">
  69. <template #default="{ row }">
  70. <el-switch
  71. :model-value="row.status === '1'"
  72. :loading="row._starting || row._stopping"
  73. :active-text="t('开启')"
  74. :inactive-text="t('关闭')"
  75. inline-prompt
  76. @change="(val: boolean) => handleToggleStream(row, val)"
  77. />
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="pushMethod" :label="t('推流方式')" width="100" align="center">
  81. <template #default="{ row }">
  82. <el-tag size="small">{{ row.pushMethod || 'ffmpeg' }}</el-tag>
  83. </template>
  84. </el-table-column>
  85. <el-table-column prop="status" :label="t('推流状态')" width="100" align="center">
  86. <template #default="{ row }">
  87. <el-tag size="small" :type="getStatusTagType(row.status)">
  88. {{ getStatusLabel(row.status) }}
  89. </el-tag>
  90. </template>
  91. </el-table-column>
  92. <el-table-column prop="enabled" :label="t('启用')" width="80" align="center">
  93. <template #default="{ row }">
  94. <el-tag size="small" :type="row.enabled ? 'success' : 'danger'">
  95. {{ row.enabled ? t('是') : t('否') }}
  96. </el-tag>
  97. </template>
  98. </el-table-column>
  99. <el-table-column prop="createdAt" :label="t('创建时间')" width="160" align="center">
  100. <template #default="{ row }">
  101. {{ formatDateTime(row.createdAt) }}
  102. </template>
  103. </el-table-column>
  104. <el-table-column :label="t('操作')" width="200" align="center" fixed="right">
  105. <template #default="{ row }">
  106. <el-button :icon="VideoPlay" type="primary" link @click="handleViewCloudflare(row)">
  107. {{ t('流媒体') }}
  108. </el-button>
  109. <el-button type="primary" link @click="handleEdit(row)">{{ t('编辑') }}</el-button>
  110. <el-button type="danger" link @click="handleDelete(row)">{{ t('删除') }}</el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. </div>
  115. <!-- 分页 -->
  116. <div class="pagination-container">
  117. <el-pagination
  118. v-model:current-page="currentPage"
  119. v-model:page-size="pageSize"
  120. :page-sizes="[10, 20, 50, 100]"
  121. :total="total"
  122. layout="total, sizes, prev, pager, next, jumper"
  123. background
  124. @size-change="handleSizeChange"
  125. @current-change="handleCurrentChange"
  126. />
  127. </div>
  128. <!-- 新增/编辑抽屉 -->
  129. <el-drawer
  130. v-model="drawerVisible"
  131. direction="rtl"
  132. size="550px"
  133. :with-header="false"
  134. destroy-on-close
  135. class="stream-drawer"
  136. >
  137. <div class="drawer-content">
  138. <div class="drawer-header">{{ drawerTitle }}</div>
  139. <div class="drawer-body">
  140. <el-form ref="formRef" :model="form" :rules="rules" label-width="auto" class="stream-form">
  141. <el-form-item label="名称:" prop="name">
  142. <el-input v-model="form.name" placeholder="例如: 测试推流-001" style="width: 300px" />
  143. </el-form-item>
  144. <el-form-item label="LSS 节点:" prop="lssId">
  145. <el-select v-model="form.lssId" placeholder="请选择 LSS 节点" clearable filterable style="width: 300px">
  146. <el-option
  147. v-for="lss in lssOptions"
  148. :key="lss.lssId"
  149. :label="`${lss.lssId} - ${lss.lssName}`"
  150. :value="lss.lssId"
  151. />
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="摄像头:" prop="cameraId">
  155. <el-select v-model="form.cameraId" placeholder="请选择摄像头" clearable filterable style="width: 300px">
  156. <el-option
  157. v-for="camera in cameraOptions"
  158. :key="camera.cameraId"
  159. :label="`${camera.cameraId} - ${camera.name}`"
  160. :value="camera.cameraId"
  161. />
  162. </el-select>
  163. </el-form-item>
  164. <el-form-item label="推流方式:" prop="pushMethod">
  165. <el-select disabled v-model="form.pushMethod" placeholder="请选择" style="width: 300px">
  166. <el-option label="ffmpeg" value="ffmpeg" />
  167. </el-select>
  168. </el-form-item>
  169. <!-- <el-form-item label="超时时间:" prop="timeoutSeconds">
  170. <el-input-number v-model="form.timeoutSeconds" :min="1" :max="300" placeholder="秒" style="width: 150px" />
  171. <span style="margin-left: 8px; color: #909399">秒</span>
  172. </el-form-item> -->
  173. <el-form-item label="命令模板:" prop="commandTemplate">
  174. <div class="textarea-wrapper">
  175. <el-input
  176. v-model="form.commandTemplate"
  177. type="textarea"
  178. :rows="6"
  179. placeholder="FFmpeg 命令模板,可使用 {RTSP_URL} 等变量"
  180. maxlength="2000"
  181. show-word-limit
  182. />
  183. </div>
  184. </el-form-item>
  185. <!-- <el-form-item label="备注:" prop="remark">
  186. <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="备注信息" maxlength="500"
  187. style="width: 300px" />
  188. </el-form-item> -->
  189. <el-form-item v-if="isEdit" label="启用状态:" prop="enabled">
  190. <el-switch v-model="form.enabled" />
  191. </el-form-item>
  192. </el-form>
  193. </div>
  194. <div class="drawer-footer">
  195. <el-button @click="drawerVisible = false">{{ t('取消') }}</el-button>
  196. <el-button type="primary" :loading="submitLoading" @click="handleSubmit">
  197. {{ isEdit ? t('更新') : t('添加') }}
  198. </el-button>
  199. </div>
  200. </div>
  201. </el-drawer>
  202. <!-- 命令模板查看/编辑弹窗 -->
  203. <el-dialog v-model="commandDialogVisible" :title="t('命令模板')" width="700px" destroy-on-close>
  204. <div class="command-content">
  205. <JsonEditor v-model="currentCommandTemplate" height="400px" />
  206. </div>
  207. <template #footer>
  208. <el-button @click="commandDialogVisible = false">{{ t('关闭') }}</el-button>
  209. <el-button type="primary" :loading="commandUpdateLoading" @click="handleUpdateCommandTemplate">
  210. {{ t('更新') }}
  211. </el-button>
  212. </template>
  213. </el-dialog>
  214. <!-- 流媒体播放抽屉 -->
  215. <el-drawer
  216. v-model="mediaDrawerVisible"
  217. direction="rtl"
  218. size="95%"
  219. :with-header="false"
  220. destroy-on-close
  221. class="media-drawer"
  222. >
  223. <div class="media-drawer-content">
  224. <!-- 左侧:视频播放区域 -->
  225. <div class="video-area">
  226. <div class="video-header">
  227. <span class="title">{{ currentMediaStream?.name || t('流媒体播放') }}</span>
  228. <el-tag v-if="playbackInfo.isLive" type="success" size="small">{{ t('直播中') }}</el-tag>
  229. <el-tag v-else type="info" size="small">{{ t('离线') }}</el-tag>
  230. </div>
  231. <div class="player-container">
  232. <div v-if="!playbackInfo.videoId" class="player-placeholder">
  233. <el-icon :size="80" color="#666">
  234. <VideoPlay />
  235. </el-icon>
  236. <p>{{ t('暂无视频流') }}</p>
  237. </div>
  238. <VideoPlayer
  239. v-else
  240. ref="playerRef"
  241. player-type="cloudflare"
  242. :video-id="playbackInfo.videoId"
  243. :customer-domain="playbackInfo.customerDomain"
  244. :use-iframe="true"
  245. :autoplay="playConfig.autoplay"
  246. :muted="playConfig.muted"
  247. :controls="true"
  248. />
  249. </div>
  250. <!-- 底部播放控制 -->
  251. <div class="player-controls">
  252. <el-button type="primary" size="small" @click="handlePlay">{{ t('播放') }}</el-button>
  253. <el-button size="small" @click="handlePause">{{ t('暂停') }}</el-button>
  254. <el-button type="danger" size="small" @click="handlePlayerStop">{{ t('停止') }}</el-button>
  255. <el-button size="small" @click="handleScreenshot">{{ t('截图') }}</el-button>
  256. <el-button size="small" @click="handleFullscreen">{{ t('全屏') }}</el-button>
  257. <el-switch
  258. v-model="playConfig.muted"
  259. :active-text="t('静音')"
  260. :inactive-text="t('有声')"
  261. style="margin-left: 16px"
  262. />
  263. </div>
  264. </div>
  265. <!-- 右侧:PTZ 控制面板 -->
  266. <div class="control-panel">
  267. <!-- PTZ 方向控制 -->
  268. <div class="panel-section">
  269. <div class="section-title">{{ t('PTZ') }}</div>
  270. <div class="ptz-grid">
  271. <div
  272. class="ptz-btn"
  273. @mousedown="handlePTZ('UP_LEFT')"
  274. @mouseup="handlePTZStop"
  275. @mouseleave="handlePTZStop"
  276. >
  277. <el-icon>
  278. <TopLeft />
  279. </el-icon>
  280. </div>
  281. <div class="ptz-btn" @mousedown="handlePTZ('UP')" @mouseup="handlePTZStop" @mouseleave="handlePTZStop">
  282. <el-icon>
  283. <Top />
  284. </el-icon>
  285. </div>
  286. <div
  287. class="ptz-btn"
  288. @mousedown="handlePTZ('UP_RIGHT')"
  289. @mouseup="handlePTZStop"
  290. @mouseleave="handlePTZStop"
  291. >
  292. <el-icon>
  293. <TopRight />
  294. </el-icon>
  295. </div>
  296. <div class="ptz-btn" @mousedown="handlePTZ('LEFT')" @mouseup="handlePTZStop" @mouseleave="handlePTZStop">
  297. <el-icon>
  298. <Back />
  299. </el-icon>
  300. </div>
  301. <div class="ptz-btn ptz-center" @click="handlePTZStop">
  302. <el-icon>
  303. <Refresh />
  304. </el-icon>
  305. </div>
  306. <div class="ptz-btn" @mousedown="handlePTZ('RIGHT')" @mouseup="handlePTZStop" @mouseleave="handlePTZStop">
  307. <el-icon>
  308. <Right />
  309. </el-icon>
  310. </div>
  311. <div
  312. class="ptz-btn"
  313. @mousedown="handlePTZ('DOWN_LEFT')"
  314. @mouseup="handlePTZStop"
  315. @mouseleave="handlePTZStop"
  316. >
  317. <el-icon>
  318. <BottomLeft />
  319. </el-icon>
  320. </div>
  321. <div class="ptz-btn" @mousedown="handlePTZ('DOWN')" @mouseup="handlePTZStop" @mouseleave="handlePTZStop">
  322. <el-icon>
  323. <Bottom />
  324. </el-icon>
  325. </div>
  326. <div
  327. class="ptz-btn"
  328. @mousedown="handlePTZ('DOWN_RIGHT')"
  329. @mouseup="handlePTZStop"
  330. @mouseleave="handlePTZStop"
  331. >
  332. <el-icon>
  333. <BottomRight />
  334. </el-icon>
  335. </div>
  336. </div>
  337. <!-- 缩放按钮 -->
  338. <div class="zoom-buttons">
  339. <el-button size="small" @mousedown="handleZoomIn" @mouseup="handlePTZStop" @mouseleave="handlePTZStop">
  340. <el-icon>
  341. <ZoomIn />
  342. </el-icon>
  343. </el-button>
  344. <el-button size="small" @mousedown="handleZoomOut" @mouseup="handlePTZStop" @mouseleave="handlePTZStop">
  345. <el-icon>
  346. <ZoomOut />
  347. </el-icon>
  348. </el-button>
  349. </div>
  350. <!-- 速度滑块 -->
  351. <div class="speed-slider">
  352. <span class="label">{{ t('速度') }}</span>
  353. <el-slider v-model="ptzSpeed" :min="10" :max="100" :step="10" size="small" />
  354. <span class="value">{{ ptzSpeed }}</span>
  355. </div>
  356. </div>
  357. <!-- 预置位列表 -->
  358. <div class="panel-section preset-section">
  359. <div class="section-title">
  360. <span>{{ t('预置位') }}</span>
  361. <el-button type="primary" link size="small" @click="loadPresets" :loading="presetsLoading">
  362. <el-icon>
  363. <Refresh />
  364. </el-icon>
  365. </el-button>
  366. </div>
  367. <div class="preset-list" v-loading="presetsLoading">
  368. <div
  369. v-for="preset in presetList"
  370. :key="preset.token"
  371. :class="['preset-item', { active: activePresetToken === preset.token }]"
  372. @click="handleGotoPreset(preset)"
  373. >
  374. <span class="preset-index">{{ preset.token }}</span>
  375. <span class="preset-name">{{ preset.name || `Preset ${preset.token}` }}</span>
  376. </div>
  377. <el-empty
  378. v-if="!presetsLoading && presetList.length === 0"
  379. :description="t('暂无预置位')"
  380. :image-size="60"
  381. />
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. </el-drawer>
  387. </div>
  388. </template>
  389. <script setup lang="ts">
  390. import { ref, reactive, onMounted, computed, watch } from 'vue'
  391. import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
  392. import {
  393. Search,
  394. RefreshRight,
  395. Plus,
  396. VideoPlay,
  397. Top,
  398. Bottom,
  399. Back,
  400. Right,
  401. TopLeft,
  402. TopRight,
  403. BottomLeft,
  404. BottomRight,
  405. Refresh,
  406. ZoomIn,
  407. ZoomOut
  408. } from '@element-plus/icons-vue'
  409. import { listLiveStreams, addLiveStream, updateLiveStream, deleteLiveStream } from '@/api/live-stream'
  410. import { listAllLssNodes } from '@/api/lss'
  411. import { adminListCameras } from '@/api/camera'
  412. import { listAllStreamChannels } from '@/api/stream-channel'
  413. import { startStreamTask, stopStreamTask, getStreamPlayback } from '@/api/stream-push'
  414. import VideoPlayer from '@/components/VideoPlayer.vue'
  415. import { ptzStart, ptzStop, getPresets, gotoPreset, type PresetInfo } from '@/api/camera'
  416. import JsonEditor from '@/components/JsonEditor.vue'
  417. import type { LiveStreamDTO, LiveStreamStatus, LssNodeDTO, CameraInfoDTO, StreamChannelDTO } from '@/types'
  418. import dayjs from 'dayjs'
  419. import { useI18n } from 'vue-i18n'
  420. const { t } = useI18n({ useScope: 'global' })
  421. // 格式化时间
  422. function formatDateTime(dateStr: string | undefined): string {
  423. if (!dateStr) return '-'
  424. return dayjs(dateStr).format('YYYY-MM-DD HH:mm:ss')
  425. }
  426. // 获取状态标签颜色
  427. function getStatusTagType(status?: LiveStreamStatus): 'success' | 'warning' | 'danger' | 'info' {
  428. switch (status) {
  429. case 'streaming':
  430. return 'success'
  431. case 'idle':
  432. return 'info'
  433. default:
  434. return 'info'
  435. }
  436. }
  437. // 获取状态标签文本
  438. function getStatusLabel(status?: LiveStreamStatus): string {
  439. switch (status) {
  440. case 'STREAMING':
  441. return t('推流中')
  442. case 'IDLE':
  443. return t('空闲')
  444. case 'STOPPED':
  445. return t('已停止')
  446. case 'ERROR':
  447. return t('错误')
  448. default:
  449. return '-'
  450. }
  451. }
  452. const loading = ref(false)
  453. const submitLoading = ref(false)
  454. const streamList = ref<LiveStreamDTO[]>([])
  455. const drawerVisible = ref(false)
  456. const formRef = ref<FormInstance>()
  457. // 命令模板弹窗
  458. const commandDialogVisible = ref(false)
  459. const currentCommandTemplate = ref('')
  460. const currentStreamId = ref<number | null>(null)
  461. const commandUpdateLoading = ref(false)
  462. // 流媒体播放抽屉
  463. const mediaDrawerVisible = ref(false)
  464. const currentMediaStream = ref<LiveStreamDTO | null>(null)
  465. const playerRef = ref<InstanceType<typeof VideoPlayer>>()
  466. const playbackInfo = ref<{
  467. videoId: string
  468. customerDomain: string
  469. hlsUrl?: string
  470. whepUrl?: string
  471. isLive: boolean
  472. }>({
  473. videoId: '',
  474. customerDomain: '',
  475. isLive: false
  476. })
  477. const playConfig = reactive({
  478. autoplay: true,
  479. muted: true
  480. })
  481. // PTZ 控制
  482. const ptzSpeed = ref(50)
  483. const zoomValue = ref(0)
  484. // 预置位
  485. const presetList = ref<PresetInfo[]>([])
  486. const presetsLoading = ref(false)
  487. const activePresetToken = ref<string | null>(null)
  488. // 下拉选项
  489. const lssOptions = ref<LssNodeDTO[]>([])
  490. const cameraOptions = ref<CameraInfoDTO[]>([])
  491. const channelOptions = ref<StreamChannelDTO[]>([])
  492. // 排序状态
  493. const sortState = reactive<{
  494. prop: string
  495. order: 'ascending' | 'descending' | null
  496. }>({
  497. prop: '',
  498. order: null
  499. })
  500. // 搜索表单
  501. const searchForm = reactive<{
  502. keyword: string
  503. enabled: boolean | null
  504. }>({
  505. keyword: '',
  506. enabled: null
  507. })
  508. // 分页相关
  509. const currentPage = ref(1)
  510. const pageSize = ref(20)
  511. const total = ref(0)
  512. // 表单数据
  513. const form = reactive<{
  514. id?: number
  515. name: string
  516. lssId: string
  517. cameraId: string
  518. channelId?: number
  519. pushMethod: string
  520. commandTemplate: string
  521. timeoutSeconds: number
  522. remark: string
  523. enabled: boolean
  524. }>({
  525. name: '',
  526. lssId: '',
  527. cameraId: '',
  528. channelId: undefined,
  529. pushMethod: 'ffmpeg',
  530. commandTemplate: '',
  531. timeoutSeconds: 30,
  532. remark: '',
  533. enabled: true
  534. })
  535. const isEdit = computed(() => !!form.id)
  536. const drawerTitle = computed(() => (isEdit.value ? t('编辑 Live Stream') : t('新增 Live Stream')))
  537. const rules: FormRules = {
  538. name: [{ required: true, message: t('请输入名称'), trigger: 'blur' }],
  539. lssId: [{ required: true, message: t('请选择 LSS 节点'), trigger: 'change' }]
  540. }
  541. async function getList() {
  542. loading.value = true
  543. try {
  544. const params: Record<string, any> = {
  545. page: currentPage.value,
  546. size: pageSize.value
  547. }
  548. if (searchForm.keyword) {
  549. params.keyword = searchForm.keyword
  550. }
  551. if (searchForm.enabled !== null) {
  552. params.enabled = searchForm.enabled
  553. }
  554. if (sortState.prop && sortState.order) {
  555. params.sortBy = sortState.prop
  556. params.sortDir = sortState.order === 'ascending' ? 'ASC' : 'DESC'
  557. }
  558. const res = await listLiveStreams(params)
  559. if (res.success) {
  560. streamList.value = res.data.list
  561. total.value = res.data.total || 0
  562. }
  563. } finally {
  564. loading.value = false
  565. }
  566. }
  567. async function loadOptions() {
  568. try {
  569. // 获取 LSS 节点列表
  570. const lssRes = await listAllLssNodes()
  571. if (lssRes.success && lssRes.data) {
  572. lssOptions.value = lssRes.data || []
  573. }
  574. } catch (error) {
  575. console.error('加载选项失败', error)
  576. }
  577. }
  578. // 监听 LSS 节点变化,加载对应的摄像头列表
  579. watch(
  580. () => form.lssId,
  581. async (newLssId) => {
  582. // 清空当前选中的摄像头
  583. form.cameraId = ''
  584. cameraOptions.value = []
  585. if (newLssId) {
  586. try {
  587. const res = await adminListCameras({ lssId: newLssId, size: 1000 })
  588. if (res.success && res.data) {
  589. cameraOptions.value = res.data.list || []
  590. }
  591. } catch (error) {
  592. console.error('加载摄像头列表失败', error)
  593. }
  594. }
  595. }
  596. )
  597. function handleSearch() {
  598. currentPage.value = 1
  599. getList()
  600. }
  601. function handleReset() {
  602. searchForm.keyword = ''
  603. searchForm.enabled = null
  604. currentPage.value = 1
  605. sortState.prop = ''
  606. sortState.order = null
  607. getList()
  608. }
  609. function handleSortChange({ prop, order }: { prop: string; order: 'ascending' | 'descending' | null }) {
  610. sortState.prop = prop || ''
  611. sortState.order = order
  612. getList()
  613. }
  614. function handleAdd() {
  615. Object.assign(form, {
  616. id: undefined,
  617. name: '',
  618. lssId: '',
  619. cameraId: '',
  620. channelId: undefined,
  621. pushMethod: 'ffmpeg',
  622. commandTemplate: '',
  623. timeoutSeconds: 30,
  624. remark: '',
  625. enabled: true
  626. })
  627. drawerVisible.value = true
  628. }
  629. function handleEdit(row: LiveStreamDTO) {
  630. Object.assign(form, {
  631. id: row.id,
  632. name: row.name,
  633. lssId: row.lssId || '',
  634. cameraId: row.cameraId || '',
  635. channelId: row.channelId,
  636. pushMethod: row.pushMethod || 'ffmpeg',
  637. commandTemplate: row.commandTemplate || '',
  638. timeoutSeconds: row.timeoutSeconds || 30,
  639. remark: row.remark || '',
  640. enabled: row.enabled
  641. })
  642. drawerVisible.value = true
  643. }
  644. async function handleDelete(row: LiveStreamDTO) {
  645. try {
  646. await ElMessageBox.confirm(t('确定要删除该 Live Stream 吗?'), t('提示'), {
  647. type: 'warning',
  648. confirmButtonText: t('确定'),
  649. cancelButtonText: t('取消')
  650. })
  651. const res = await deleteLiveStream(row.id)
  652. if (res.success) {
  653. ElMessage.success(t('删除成功'))
  654. getList()
  655. } else {
  656. ElMessage.error(res.errMessage || t('删除失败'))
  657. }
  658. } catch {
  659. // 用户取消
  660. }
  661. }
  662. async function handleSubmit() {
  663. if (!formRef.value) return
  664. await formRef.value.validate(async (valid) => {
  665. if (valid) {
  666. submitLoading.value = true
  667. try {
  668. if (isEdit.value) {
  669. const res = await updateLiveStream({
  670. id: form.id!,
  671. name: form.name,
  672. lssId: form.lssId || undefined,
  673. cameraId: form.cameraId || undefined,
  674. channelId: form.channelId,
  675. pushMethod: form.pushMethod || undefined,
  676. commandTemplate: form.commandTemplate || undefined,
  677. timeoutSeconds: form.timeoutSeconds,
  678. remark: form.remark || undefined,
  679. enabled: form.enabled
  680. })
  681. if (res.success) {
  682. ElMessage.success(t('修改成功'))
  683. drawerVisible.value = false
  684. getList()
  685. } else {
  686. ElMessage.error(res.errMessage || t('修改失败'))
  687. }
  688. } else {
  689. const res = await addLiveStream({
  690. name: form.name,
  691. lssId: form.lssId,
  692. cameraId: form.cameraId || undefined,
  693. channelId: form.channelId,
  694. pushMethod: form.pushMethod || undefined,
  695. commandTemplate: form.commandTemplate || undefined,
  696. timeoutSeconds: form.timeoutSeconds,
  697. remark: form.remark || undefined
  698. })
  699. if (res.success) {
  700. ElMessage.success(t('新增成功'))
  701. drawerVisible.value = false
  702. getList()
  703. } else {
  704. ElMessage.error(res.errMessage || t('新增失败'))
  705. }
  706. }
  707. } finally {
  708. submitLoading.value = false
  709. }
  710. }
  711. })
  712. }
  713. // 打开命令模板弹窗
  714. function openCommandDialog(row: LiveStreamDTO) {
  715. currentStreamId.value = row.id
  716. currentCommandTemplate.value = row.commandTemplate || ''
  717. commandDialogVisible.value = true
  718. }
  719. // 更新命令模板
  720. async function handleUpdateCommandTemplate() {
  721. if (!currentStreamId.value) return
  722. commandUpdateLoading.value = true
  723. try {
  724. const res = await updateLiveStream({
  725. id: currentStreamId.value,
  726. commandTemplate: currentCommandTemplate.value
  727. })
  728. if (res.success) {
  729. ElMessage.success(t('更新成功'))
  730. commandDialogVisible.value = false
  731. getList()
  732. } else {
  733. ElMessage.error(res.errMessage || t('更新失败'))
  734. }
  735. } catch (error) {
  736. console.error('更新命令模板失败', error)
  737. ElMessage.error(t('更新失败'))
  738. } finally {
  739. commandUpdateLoading.value = false
  740. }
  741. }
  742. // 切换推流状态
  743. async function handleToggleStream(row: LiveStreamDTO, val: boolean) {
  744. if (val) {
  745. await handleStartStream(row)
  746. } else {
  747. await handleStopStream(row)
  748. }
  749. }
  750. // 启动推流
  751. async function handleStartStream(row: LiveStreamDTO) {
  752. if (!row.cameraId) {
  753. ElMessage.warning(t('请先配置摄像头'))
  754. return
  755. }
  756. row._starting = true
  757. try {
  758. const res = await startStreamTask({
  759. name: row.name,
  760. lssId: row.lssId,
  761. cameraId: row.cameraId
  762. })
  763. if (res.success) {
  764. ElMessage.success(t('推流任务已启动'))
  765. getList()
  766. } else {
  767. ElMessage.error(res.errMessage || t('启动失败'))
  768. }
  769. } catch (error) {
  770. console.error('启动推流失败', error)
  771. ElMessage.error(t('启动推流失败'))
  772. } finally {
  773. row._starting = false
  774. }
  775. }
  776. // 停止推流
  777. async function handleStopStream(row: LiveStreamDTO) {
  778. try {
  779. await ElMessageBox.confirm(t('确定要停止该推流任务吗?'), t('提示'), {
  780. type: 'warning',
  781. confirmButtonText: t('确定'),
  782. cancelButtonText: t('取消')
  783. })
  784. row._stopping = true
  785. const res = await stopStreamTask({ taskId: row.taskStreamSn, lssId: row.lssId })
  786. if (res.success) {
  787. ElMessage.success(t('推流任务已停止'))
  788. getList()
  789. } else {
  790. ElMessage.error(res.errMessage || t('停止失败'))
  791. }
  792. } catch (error) {
  793. if (error !== 'cancel') {
  794. console.error('停止推流失败', error)
  795. ElMessage.error(t('停止推流失败'))
  796. }
  797. } finally {
  798. row._stopping = false
  799. }
  800. }
  801. // 从 playbackUrl 解析 videoId 和 customerDomain
  802. function parsePlaybackUrl(playbackUrl: string): { videoId: string; customerDomain: string } | null {
  803. try {
  804. const url = new URL(playbackUrl)
  805. const customerDomain = url.hostname
  806. // URL 格式: https://domain/{videoId}/webRTC/play 或 https://domain/{videoId}/iframe
  807. const pathParts = url.pathname.split('/').filter(Boolean)
  808. if (pathParts.length > 0) {
  809. return { videoId: pathParts[0], customerDomain }
  810. }
  811. } catch (e) {
  812. console.error('解析 playbackUrl 失败', e)
  813. }
  814. return null
  815. }
  816. // 查看流媒体
  817. async function handleViewCloudflare(row: LiveStreamDTO) {
  818. currentMediaStream.value = row
  819. // 默认值
  820. let videoId = ''
  821. let customerDomain = 'customer-pj89kn2ke2tcuh19.cloudflarestream.com'
  822. // 优先从 playbackUrl 解析
  823. if (row.playbackUrl) {
  824. const parsed = parsePlaybackUrl(row.playbackUrl)
  825. if (parsed) {
  826. videoId = parsed.videoId
  827. customerDomain = parsed.customerDomain
  828. }
  829. }
  830. // 尝试获取播放信息
  831. if (row.streamSn) {
  832. try {
  833. const res = await getStreamPlayback(row.streamSn)
  834. if (res.success && res.data) {
  835. playbackInfo.value = {
  836. videoId: videoId || row.streamSn,
  837. customerDomain,
  838. hlsUrl: res.data.hlsUrl,
  839. whepUrl: res.data.whepUrl,
  840. isLive: res.data.isLive
  841. }
  842. } else {
  843. playbackInfo.value = {
  844. videoId: videoId || row.streamSn,
  845. customerDomain,
  846. isLive: false
  847. }
  848. }
  849. } catch (error) {
  850. console.error('获取播放信息失败', error)
  851. playbackInfo.value = {
  852. videoId: videoId || row.streamSn,
  853. customerDomain,
  854. isLive: false
  855. }
  856. }
  857. } else if (videoId) {
  858. playbackInfo.value = {
  859. videoId,
  860. customerDomain,
  861. isLive: false
  862. }
  863. }
  864. mediaDrawerVisible.value = true
  865. }
  866. // 播放控制
  867. function handlePlay() {
  868. playerRef.value?.play()
  869. }
  870. function handlePause() {
  871. playerRef.value?.pause()
  872. }
  873. function handlePlayerStop() {
  874. playerRef.value?.stop()
  875. }
  876. function handleScreenshot() {
  877. playerRef.value?.screenshot()
  878. }
  879. function handleFullscreen() {
  880. playerRef.value?.fullscreen()
  881. }
  882. // PTZ 控制
  883. async function handlePTZ(direction: string) {
  884. if (!currentMediaStream.value?.cameraId) {
  885. ElMessage.warning(t('未配置摄像头'))
  886. return
  887. }
  888. try {
  889. const actionMap: Record<string, string> = {
  890. UP: 'up',
  891. DOWN: 'down',
  892. LEFT: 'left',
  893. RIGHT: 'right',
  894. UP_LEFT: 'up',
  895. UP_RIGHT: 'up',
  896. DOWN_LEFT: 'down',
  897. DOWN_RIGHT: 'down'
  898. }
  899. const action = actionMap[direction] || 'stop'
  900. await ptzStart(currentMediaStream.value.cameraId, action as any, ptzSpeed.value)
  901. } catch (error) {
  902. console.error('PTZ 控制失败', error)
  903. }
  904. }
  905. async function handlePTZStop() {
  906. if (!currentMediaStream.value?.cameraId) return
  907. try {
  908. await ptzStop(currentMediaStream.value.cameraId)
  909. } catch (error) {
  910. console.error('PTZ 停止失败', error)
  911. }
  912. }
  913. // 缩放控制
  914. function formatZoomTooltip(val: number) {
  915. if (val === 0) return t('停止')
  916. return val > 0 ? `${t('放大')} ${val}` : `${t('缩小')} ${Math.abs(val)}`
  917. }
  918. async function handleZoomChange(val: number) {
  919. if (!currentMediaStream.value?.cameraId) return
  920. if (val === 0) {
  921. await ptzStop(currentMediaStream.value.cameraId)
  922. return
  923. }
  924. const action = val > 0 ? 'zoom_in' : 'zoom_out'
  925. await ptzStart(currentMediaStream.value.cameraId, action as any, Math.abs(val))
  926. }
  927. async function handleZoomRelease() {
  928. zoomValue.value = 0
  929. if (!currentMediaStream.value?.cameraId) return
  930. await ptzStop(currentMediaStream.value.cameraId)
  931. }
  932. // 缩放按钮控制
  933. async function handleZoomIn() {
  934. if (!currentMediaStream.value?.cameraId) {
  935. ElMessage.warning(t('未配置摄像头'))
  936. return
  937. }
  938. try {
  939. await ptzStart(currentMediaStream.value.cameraId, 'zoom_in' as any, ptzSpeed.value)
  940. } catch (error) {
  941. console.error('Zoom in 失败', error)
  942. }
  943. }
  944. async function handleZoomOut() {
  945. if (!currentMediaStream.value?.cameraId) {
  946. ElMessage.warning(t('未配置摄像头'))
  947. return
  948. }
  949. try {
  950. await ptzStart(currentMediaStream.value.cameraId, 'zoom_out' as any, ptzSpeed.value)
  951. } catch (error) {
  952. console.error('Zoom out 失败', error)
  953. }
  954. }
  955. // 加载预置位列表
  956. async function loadPresets() {
  957. if (!currentMediaStream.value?.cameraId) {
  958. ElMessage.warning(t('未配置摄像头'))
  959. return
  960. }
  961. presetsLoading.value = true
  962. try {
  963. const res = await getPresets(currentMediaStream.value.cameraId)
  964. if (res.success && res.data) {
  965. presetList.value = res.data
  966. } else {
  967. presetList.value = []
  968. }
  969. } catch (error) {
  970. console.error('加载预置位失败', error)
  971. presetList.value = []
  972. } finally {
  973. presetsLoading.value = false
  974. }
  975. }
  976. // 跳转到预置位
  977. async function handleGotoPreset(preset: PresetInfo) {
  978. if (!currentMediaStream.value?.cameraId) {
  979. ElMessage.warning(t('未配置摄像头'))
  980. return
  981. }
  982. try {
  983. activePresetToken.value = preset.token
  984. const res = await gotoPreset(currentMediaStream.value.cameraId, preset.token)
  985. if (res.success) {
  986. ElMessage.success(t('已跳转到预置位') + `: ${preset.name || preset.token}`)
  987. } else {
  988. ElMessage.error(res.errMessage || t('跳转失败'))
  989. }
  990. } catch (error) {
  991. console.error('跳转预置位失败', error)
  992. ElMessage.error(t('跳转失败'))
  993. }
  994. }
  995. function handleSizeChange(val: number) {
  996. pageSize.value = val
  997. currentPage.value = 1
  998. getList()
  999. }
  1000. function handleCurrentChange(val: number) {
  1001. currentPage.value = val
  1002. getList()
  1003. }
  1004. onMounted(() => {
  1005. getList()
  1006. loadOptions()
  1007. })
  1008. </script>
  1009. <style lang="scss" scoped>
  1010. .page-container {
  1011. display: flex;
  1012. flex-direction: column;
  1013. box-sizing: border-box;
  1014. }
  1015. .search-form {
  1016. flex-shrink: 0;
  1017. margin-bottom: 16px;
  1018. padding: 16px 16px 4px 16px;
  1019. background: #f5f7fa;
  1020. :deep(.el-form-item) {
  1021. margin-bottom: 12px;
  1022. margin-right: 16px;
  1023. }
  1024. :deep(.el-input),
  1025. :deep(.el-select) {
  1026. width: 180px;
  1027. }
  1028. :deep(.el-button--primary) {
  1029. background-color: #4f46e5;
  1030. border-color: #4f46e5;
  1031. &:hover,
  1032. &:focus {
  1033. background-color: #6366f1;
  1034. border-color: #6366f1;
  1035. }
  1036. }
  1037. }
  1038. .table-wrapper {
  1039. flex: 1;
  1040. min-height: 0;
  1041. overflow: hidden;
  1042. }
  1043. .pagination-container {
  1044. flex-shrink: 0;
  1045. display: flex;
  1046. justify-content: flex-end;
  1047. padding-top: 16px;
  1048. :deep(.el-pagination) {
  1049. .el-pager li.is-active {
  1050. background-color: #4f46e5;
  1051. color: #fff;
  1052. }
  1053. .el-pager li:not(.is-active):hover {
  1054. color: #4f46e5;
  1055. }
  1056. .btn-prev:hover,
  1057. .btn-next:hover {
  1058. color: #4f46e5;
  1059. }
  1060. }
  1061. }
  1062. :deep(.el-table) {
  1063. --el-table-row-hover-bg-color: #f0f0ff;
  1064. .el-table__row--striped td.el-table__cell {
  1065. background-color: #f8f9fc;
  1066. }
  1067. .el-table__header th {
  1068. background-color: #f5f7fa;
  1069. color: #333;
  1070. font-weight: 600;
  1071. }
  1072. .el-link--primary {
  1073. color: #4f46e5;
  1074. &:hover {
  1075. color: #6366f1;
  1076. }
  1077. }
  1078. .el-button--primary.is-link {
  1079. color: #4f46e5;
  1080. &:hover {
  1081. color: #6366f1;
  1082. }
  1083. }
  1084. }
  1085. // 抽屉样式
  1086. .stream-drawer {
  1087. :deep(.el-drawer__body) {
  1088. padding: 0;
  1089. display: flex;
  1090. flex-direction: column;
  1091. height: 100%;
  1092. }
  1093. }
  1094. .drawer-content {
  1095. display: flex;
  1096. flex-direction: column;
  1097. height: 100%;
  1098. }
  1099. .drawer-header {
  1100. flex-shrink: 0;
  1101. padding: 16px 20px;
  1102. font-size: 16px;
  1103. font-weight: 500;
  1104. color: #303133;
  1105. border-bottom: 1px solid #e5e7eb;
  1106. }
  1107. .drawer-body {
  1108. flex: 1;
  1109. overflow-y: auto;
  1110. padding: 20px;
  1111. }
  1112. .stream-form {
  1113. :deep(.el-form-item) {
  1114. margin-bottom: 18px;
  1115. }
  1116. :deep(.el-form-item__label) {
  1117. color: #606266;
  1118. font-size: 14px;
  1119. }
  1120. .textarea-wrapper {
  1121. width: 100%;
  1122. :deep(.el-textarea__inner) {
  1123. font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  1124. font-size: 13px;
  1125. background-color: #fafafa;
  1126. border: 1px solid #dcdfe6;
  1127. &:focus {
  1128. border-color: #4f46e5;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. .drawer-footer {
  1134. flex-shrink: 0;
  1135. display: flex;
  1136. justify-content: flex-end;
  1137. padding: 12px 20px;
  1138. border-top: 1px solid #e5e7eb;
  1139. gap: 12px;
  1140. .el-button--primary {
  1141. background-color: #4f46e5;
  1142. border-color: #4f46e5;
  1143. &:hover,
  1144. &:focus {
  1145. background-color: #6366f1;
  1146. border-color: #6366f1;
  1147. }
  1148. }
  1149. }
  1150. // 命令模板弹窗样式
  1151. .command-content {
  1152. :deep(.el-textarea__inner) {
  1153. font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  1154. font-size: 13px;
  1155. line-height: 1.6;
  1156. background-color: #1e1e1e;
  1157. color: #d4d4d4;
  1158. border-radius: 6px;
  1159. &:focus {
  1160. border-color: #4f46e5;
  1161. }
  1162. }
  1163. }
  1164. // 流媒体播放抽屉样式
  1165. .media-drawer {
  1166. :deep(.el-drawer__body) {
  1167. padding: 0;
  1168. display: flex;
  1169. flex-direction: column;
  1170. height: 100%;
  1171. background-color: #1a1a2e;
  1172. }
  1173. }
  1174. .media-drawer-content {
  1175. display: flex;
  1176. height: 100%;
  1177. padding: 16px;
  1178. gap: 16px;
  1179. overflow: hidden;
  1180. }
  1181. // 左侧视频区域
  1182. .video-area {
  1183. flex: 1;
  1184. display: flex;
  1185. flex-direction: column;
  1186. min-width: 0;
  1187. background-color: #16213e;
  1188. border-radius: 8px;
  1189. overflow: hidden;
  1190. .video-header {
  1191. display: flex;
  1192. align-items: center;
  1193. gap: 12px;
  1194. padding: 12px 16px;
  1195. background-color: #0f3460;
  1196. .title {
  1197. font-size: 16px;
  1198. font-weight: 600;
  1199. color: #fff;
  1200. }
  1201. }
  1202. .player-container {
  1203. flex: 1;
  1204. min-height: 0;
  1205. background-color: #000;
  1206. display: flex;
  1207. align-items: center;
  1208. justify-content: center;
  1209. .player-placeholder {
  1210. display: flex;
  1211. flex-direction: column;
  1212. align-items: center;
  1213. justify-content: center;
  1214. color: #666;
  1215. p {
  1216. margin-top: 15px;
  1217. font-size: 14px;
  1218. }
  1219. }
  1220. }
  1221. .player-controls {
  1222. display: flex;
  1223. align-items: center;
  1224. gap: 8px;
  1225. padding: 12px 16px;
  1226. background-color: #0f3460;
  1227. }
  1228. }
  1229. // 右侧控制面板
  1230. .control-panel {
  1231. width: 280px;
  1232. flex-shrink: 0;
  1233. display: flex;
  1234. flex-direction: column;
  1235. gap: 16px;
  1236. overflow-y: auto;
  1237. .panel-section {
  1238. background-color: #16213e;
  1239. border-radius: 8px;
  1240. padding: 16px;
  1241. .section-title {
  1242. display: flex;
  1243. align-items: center;
  1244. justify-content: space-between;
  1245. font-size: 14px;
  1246. font-weight: 600;
  1247. color: #fff;
  1248. margin-bottom: 12px;
  1249. padding-bottom: 8px;
  1250. border-bottom: 1px solid #0f3460;
  1251. }
  1252. }
  1253. }
  1254. // PTZ 方向控制网格
  1255. .ptz-grid {
  1256. display: grid;
  1257. grid-template-columns: repeat(3, 1fr);
  1258. gap: 6px;
  1259. margin-bottom: 12px;
  1260. }
  1261. .ptz-btn {
  1262. aspect-ratio: 1;
  1263. display: flex;
  1264. align-items: center;
  1265. justify-content: center;
  1266. background-color: #0f3460;
  1267. border: 1px solid #1a4a7a;
  1268. border-radius: 6px;
  1269. cursor: pointer;
  1270. transition: all 0.2s;
  1271. color: #94a3b8;
  1272. &:hover {
  1273. background-color: #1a4a7a;
  1274. border-color: #3b82f6;
  1275. color: #3b82f6;
  1276. }
  1277. &:active {
  1278. background-color: #3b82f6;
  1279. color: #fff;
  1280. }
  1281. .el-icon {
  1282. font-size: 18px;
  1283. }
  1284. &.ptz-center {
  1285. background-color: #1a4a7a;
  1286. &:hover {
  1287. background-color: #2563eb;
  1288. color: #fff;
  1289. }
  1290. }
  1291. }
  1292. // 缩放按钮
  1293. .zoom-buttons {
  1294. display: flex;
  1295. justify-content: center;
  1296. gap: 12px;
  1297. margin-bottom: 12px;
  1298. .el-button {
  1299. background-color: #0f3460;
  1300. border-color: #1a4a7a;
  1301. color: #94a3b8;
  1302. &:hover {
  1303. background-color: #1a4a7a;
  1304. border-color: #3b82f6;
  1305. color: #3b82f6;
  1306. }
  1307. }
  1308. }
  1309. // 速度滑块
  1310. .speed-slider {
  1311. display: flex;
  1312. align-items: center;
  1313. gap: 12px;
  1314. .label {
  1315. font-size: 12px;
  1316. color: #94a3b8;
  1317. flex-shrink: 0;
  1318. }
  1319. .value {
  1320. font-size: 12px;
  1321. color: #3b82f6;
  1322. width: 30px;
  1323. text-align: right;
  1324. }
  1325. :deep(.el-slider) {
  1326. flex: 1;
  1327. .el-slider__runway {
  1328. background-color: #0f3460;
  1329. }
  1330. .el-slider__bar {
  1331. background-color: #3b82f6;
  1332. }
  1333. .el-slider__button {
  1334. border-color: #3b82f6;
  1335. }
  1336. }
  1337. }
  1338. // 预置位区域
  1339. .preset-section {
  1340. flex: 1;
  1341. min-height: 0;
  1342. display: flex;
  1343. flex-direction: column;
  1344. .preset-list {
  1345. flex: 1;
  1346. overflow-y: auto;
  1347. display: flex;
  1348. flex-direction: column;
  1349. gap: 6px;
  1350. max-height: 300px;
  1351. }
  1352. .preset-item {
  1353. display: flex;
  1354. align-items: center;
  1355. gap: 10px;
  1356. padding: 10px 12px;
  1357. background-color: #0f3460;
  1358. border: 1px solid #1a4a7a;
  1359. border-radius: 6px;
  1360. cursor: pointer;
  1361. transition: all 0.2s;
  1362. &:hover {
  1363. background-color: #1a4a7a;
  1364. border-color: #3b82f6;
  1365. }
  1366. &.active {
  1367. background-color: #3b82f6;
  1368. border-color: #3b82f6;
  1369. .preset-index,
  1370. .preset-name {
  1371. color: #fff;
  1372. }
  1373. }
  1374. .preset-index {
  1375. width: 28px;
  1376. height: 28px;
  1377. display: flex;
  1378. align-items: center;
  1379. justify-content: center;
  1380. background-color: #1a4a7a;
  1381. border-radius: 4px;
  1382. font-size: 12px;
  1383. font-weight: 600;
  1384. color: #3b82f6;
  1385. }
  1386. .preset-name {
  1387. flex: 1;
  1388. font-size: 13px;
  1389. color: #94a3b8;
  1390. overflow: hidden;
  1391. text-overflow: ellipsis;
  1392. white-space: nowrap;
  1393. }
  1394. }
  1395. :deep(.el-empty) {
  1396. padding: 20px 0;
  1397. .el-empty__description {
  1398. color: #64748b;
  1399. }
  1400. }
  1401. }
  1402. </style>