VideoGrid.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <div class="panel-box video-grid">
  3. <div class="corner-deco tl"></div>
  4. <div class="corner-deco tr"></div>
  5. <div class="corner-deco bl"></div>
  6. <div class="corner-deco br"></div>
  7. <div class="panel-title">
  8. 实时视频监控
  9. <span class="video-count">共 {{ videoTotal }} 路</span>
  10. </div>
  11. <div class="panel-content">
  12. <div class="grid-container">
  13. <H5PlayerVideo v-for="(item,index) in videoList" :key="index" :videoProps="item"></H5PlayerVideo>
  14. <!-- <div
  15. v-for="(video, idx) in videoList"
  16. :key="video.id"
  17. class="cam-frame"
  18. :class="{ 'ai-cam': video.ai }"
  19. :style="{ animationDelay: (idx * 0.08) + 's' }"
  20. >
  21. <div class="cam-inner">
  22. <div class="cam-video-area">
  23. <i class="el-icon-video-camera cam-icon"></i>
  24. <div class="cam-scan-line"></div>
  25. </div>
  26. <div class="cam-corner tl"></div>
  27. <div class="cam-corner tr"></div>
  28. <div class="cam-corner bl"></div>
  29. <div class="cam-corner br"></div>
  30. </div>
  31. <div class="cam-label">
  32. <span class="cam-name">{{ video.name }}</span>
  33. <span v-if="video.ai" class="cam-ai-badge">AI</span>
  34. <span class="cam-status" :class="video.status">{{ video.status === 'online' ? 'REC' : 'OFF' }}</span>
  35. </div>
  36. </div> -->
  37. </div>
  38. <div class="grid-pagination">
  39. <button class="page-btn" :disabled="videoQueryParams.page <= 1" @click="changePage(-1)">
  40. <i class="el-icon-arrow-left"></i>
  41. </button>
  42. <span class="page-info">{{ videoQueryParams.page }} / {{ totalPages }}</span>
  43. <button class="page-btn" :disabled="videoQueryParams.page >= totalPages" @click="changePage(1)">
  44. <i class="el-icon-arrow-right"></i>
  45. </button>
  46. </div>
  47. </div>
  48. <fullH5PlayerVideo v-if="fullVideoType" :fullVideoProps="fullVideoProps"></fullH5PlayerVideo>
  49. </div>
  50. </template>
  51. <script>
  52. import {getVideoList} from '@/api'
  53. import H5PlayerVideo from '@/components/H5PlayerVideo/H5PlayerVideo.vue'
  54. import fullH5PlayerVideo from '@/components/fullH5PlayerVideo/fullH5PlayerVideo.vue'
  55. export default {
  56. name: 'VideoGrid',
  57. components: {H5PlayerVideo, fullH5PlayerVideo},
  58. data() {
  59. return {
  60. videoQueryParams: {
  61. page: 1,
  62. pageSize: 9,
  63. streamType: 1,
  64. source: 0,
  65. },
  66. videoType: false,
  67. videoList: [],
  68. videoTotal: 0,
  69. //全屏视频参数
  70. fullVideoProps: {},
  71. fullVideoType: false,
  72. }
  73. },
  74. computed: {
  75. totalPages() {
  76. return Math.ceil(this.videoTotal / 9) || 1
  77. }
  78. },
  79. mounted() {
  80. },
  81. methods: {
  82. //刷新视屏
  83. getVideoData(data) {
  84. let obj = {
  85. page: 1,
  86. pageSize: 9,
  87. passageway: '',
  88. protocol: window.location.href.indexOf('https') !== -1 ? 'wss' : 'ws',
  89. streamType: 1,
  90. source: 4,
  91. subIds: data,
  92. };
  93. this.$set(this, 'videoQueryParams', obj);
  94. this.$nextTick(() => {
  95. this.videoInitialize()
  96. })
  97. },
  98. async videoInitialize() {
  99. let self = this;
  100. self.$set(self, 'videoType', false);
  101. self.$set(self, 'videoList', []);
  102. try {
  103. const res = await getVideoList(this.videoQueryParams)
  104. // 假数据开始
  105. // let res = {
  106. // data: {
  107. // total: 100,
  108. // records: [
  109. // {streamUrl: '1', deviceNo: '1'},
  110. // {streamUrl: '2', deviceNo: '2'},
  111. // {streamUrl: '3', deviceNo: '3'},
  112. // {streamUrl: '4', deviceNo: '4'},
  113. // {streamUrl: '5', deviceNo: '5'},
  114. // {streamUrl: '6', deviceNo: '6'},
  115. // {streamUrl: '7', deviceNo: '7'},
  116. // {streamUrl: '8', deviceNo: '8'},
  117. // {streamUrl: '9', deviceNo: '9'},
  118. // ],
  119. // }
  120. // };
  121. // 假数据结束
  122. let list = [];
  123. for (let i = 0; i < res.data.records.length; i++) {
  124. list.push(
  125. {
  126. width: 510, //(宽度:非必传-默认600)
  127. height: 275, //(高度:非必传-默认338)
  128. url: res.data.records[i].streamUrl,
  129. cameraIndexCode: res.data.records[i].deviceNo,
  130. }
  131. )
  132. }
  133. this.$set(this, 'videoList', list)
  134. this.$set(this, 'videoTotal', res.data.total);
  135. this.$nextTick(() => {
  136. setTimeout(function () {
  137. self.$set(self, 'videoType', true);
  138. }, 1000);
  139. })
  140. } catch (e) {
  141. console.error('VideoGrid:', e)
  142. }
  143. },
  144. changePage(delta) {
  145. this.videoQueryParams.page += delta
  146. this.videoInitialize()
  147. },
  148. //全屏开启-关闭轮播
  149. stopTime(cameraIndexCode) {
  150. this.$set(this, 'fullVideoProps', {cameraIndexCode: cameraIndexCode});
  151. this.$set(this, 'fullVideoType', true);
  152. },
  153. //全屏关闭-开启轮播
  154. outFullScreen() {
  155. let self = this;
  156. this.$set(this, 'fullVideoType', false);
  157. this.$set(this, 'fullVideoProps', {});
  158. },
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .video-grid {
  164. height: 100%;
  165. display: flex;
  166. flex-direction: column;
  167. .panel-content {
  168. flex: 1;
  169. display: flex;
  170. flex-direction: column;
  171. }
  172. }
  173. .video-count {
  174. font-size: 12px;
  175. color: $text-muted;
  176. font-weight: normal;
  177. margin-left: auto;
  178. }
  179. .grid-container {
  180. flex: 1;
  181. display: grid;
  182. grid-template-columns: repeat(3, 1fr);
  183. grid-template-rows: repeat(3, 1fr);
  184. gap: 10px;
  185. }
  186. /* ---- Camera Frame ---- */
  187. .cam-frame {
  188. position: relative;
  189. display: flex;
  190. flex-direction: column;
  191. animation: camEntrance 0.5s ease-out both;
  192. }
  193. @keyframes camEntrance {
  194. from {
  195. opacity: 0;
  196. transform: scale(0.92);
  197. }
  198. to {
  199. opacity: 1;
  200. transform: scale(1);
  201. }
  202. }
  203. .cam-inner {
  204. flex: 1;
  205. position: relative;
  206. background: rgba(6, 22, 56, 0.6);
  207. clip-path: polygon(
  208. 0 8px, 8px 0, calc(100% - 8px) 0, 100% 8px,
  209. 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px)
  210. );
  211. overflow: hidden;
  212. border: 1px solid rgba(72, 215, 255, 0.15);
  213. transition: all 0.3s ease;
  214. &::before {
  215. content: '';
  216. position: absolute;
  217. inset: 0;
  218. border: 1px solid rgba(72, 215, 255, 0.12);
  219. clip-path: inherit;
  220. pointer-events: none;
  221. z-index: 2;
  222. }
  223. &::after {
  224. content: '';
  225. position: absolute;
  226. inset: -2px;
  227. background: conic-gradient(from 0deg, transparent 0%, rgba(72, 215, 255, 0.4) 10%, transparent 20%);
  228. animation: camFrameBorderFlow 6s linear infinite;
  229. clip-path: inherit;
  230. z-index: 1;
  231. opacity: 0;
  232. transition: opacity 0.3s ease;
  233. }
  234. .cam-frame:hover &::after {
  235. opacity: 1;
  236. }
  237. }
  238. @keyframes camFrameBorderFlow {
  239. from {
  240. transform: rotate(0deg);
  241. }
  242. to {
  243. transform: rotate(360deg);
  244. }
  245. }
  246. /* Camera corner accents */
  247. .cam-corner {
  248. position: absolute;
  249. width: 12px;
  250. height: 12px;
  251. z-index: 3;
  252. &::before, &::after {
  253. content: '';
  254. position: absolute;
  255. background: $accent;
  256. box-shadow: 0 0 4px $accent;
  257. }
  258. &.tl {
  259. top: 0;
  260. left: 0;
  261. &::before {
  262. top: 0;
  263. left: 0;
  264. width: 12px;
  265. height: 1px;
  266. }
  267. &::after {
  268. top: 0;
  269. left: 0;
  270. width: 1px;
  271. height: 12px;
  272. }
  273. }
  274. &.tr {
  275. top: 0;
  276. right: 0;
  277. &::before {
  278. top: 0;
  279. right: 0;
  280. width: 12px;
  281. height: 1px;
  282. }
  283. &::after {
  284. top: 0;
  285. right: 0;
  286. width: 1px;
  287. height: 12px;
  288. }
  289. }
  290. &.bl {
  291. bottom: 0;
  292. left: 0;
  293. &::before {
  294. bottom: 0;
  295. left: 0;
  296. width: 12px;
  297. height: 1px;
  298. }
  299. &::after {
  300. bottom: 0;
  301. left: 0;
  302. width: 1px;
  303. height: 12px;
  304. }
  305. }
  306. &.br {
  307. bottom: 0;
  308. right: 0;
  309. &::before {
  310. bottom: 0;
  311. right: 0;
  312. width: 12px;
  313. height: 1px;
  314. }
  315. &::after {
  316. bottom: 0;
  317. right: 0;
  318. width: 1px;
  319. height: 12px;
  320. }
  321. }
  322. }
  323. /* AI camera variant - orange accents */
  324. .ai-cam {
  325. .cam-corner::before, .cam-corner::after {
  326. background: $accent-orange;
  327. box-shadow: 0 0 4px $accent-orange;
  328. }
  329. .cam-inner {
  330. border-color: rgba(255, 176, 32, 0.2);
  331. &::after {
  332. background: conic-gradient(from 0deg, transparent 0%, rgba(255, 176, 32, 0.4) 10%, transparent 20%);
  333. }
  334. }
  335. .cam-scan-line {
  336. background: linear-gradient(180deg, transparent, rgba(255, 176, 32, 0.15), transparent);
  337. }
  338. }
  339. .cam-video-area {
  340. width: 100%;
  341. height: 100%;
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. position: relative;
  346. }
  347. .cam-icon {
  348. font-size: 30px;
  349. color: rgba(72, 215, 255, 0.12);
  350. z-index: 1;
  351. .ai-cam & {
  352. color: rgba(255, 176, 32, 0.12);
  353. }
  354. }
  355. .cam-scan-line {
  356. position: absolute;
  357. left: 0;
  358. width: 100%;
  359. height: 40%;
  360. background: linear-gradient(180deg, transparent, rgba(72, 215, 255, 0.08), transparent);
  361. animation: gridScan 4s ease-in-out infinite;
  362. pointer-events: none;
  363. z-index: 2;
  364. }
  365. @keyframes gridScan {
  366. 0% {
  367. top: -40%;
  368. }
  369. 50% {
  370. top: 100%;
  371. }
  372. 50.01% {
  373. top: -40%;
  374. }
  375. 100% {
  376. top: -40%;
  377. }
  378. }
  379. .cam-label {
  380. display: flex;
  381. align-items: center;
  382. gap: 6px;
  383. padding: 5px 8px;
  384. font-size: 12px;
  385. background: rgba(6, 22, 56, 0.8);
  386. border-top: 1px solid rgba(72, 215, 255, 0.08);
  387. flex-shrink: 0;
  388. }
  389. .cam-name {
  390. color: $text-secondary;
  391. flex: 1;
  392. overflow: hidden;
  393. text-overflow: ellipsis;
  394. white-space: nowrap;
  395. }
  396. .cam-ai-badge {
  397. font-size: 10px;
  398. padding: 1px 5px;
  399. border-radius: 3px;
  400. color: $accent-orange;
  401. background: rgba(255, 176, 32, 0.15);
  402. border: 1px solid rgba(255, 176, 32, 0.3);
  403. font-weight: 700;
  404. }
  405. .cam-status {
  406. font-size: 10px;
  407. font-weight: 600;
  408. &.online {
  409. color: $accent-green;
  410. animation: recBlink 1.5s ease-in-out infinite;
  411. }
  412. &.offline {
  413. color: $text-muted;
  414. }
  415. }
  416. @keyframes recBlink {
  417. 0%, 100% {
  418. opacity: 1;
  419. }
  420. 50% {
  421. opacity: 0.3;
  422. }
  423. }
  424. /* ---- Pagination ---- */
  425. .grid-pagination {
  426. display: flex;
  427. justify-content: center;
  428. align-items: center;
  429. gap: 14px;
  430. padding-top: 10px;
  431. flex-shrink: 0;
  432. }
  433. .page-btn {
  434. width: 30px;
  435. height: 30px;
  436. border-radius: 4px;
  437. background: rgba(72, 215, 255, 0.06);
  438. border: 1px solid rgba(72, 215, 255, 0.15);
  439. color: $text-secondary;
  440. cursor: pointer;
  441. display: flex;
  442. align-items: center;
  443. justify-content: center;
  444. transition: all 0.3s ease;
  445. &:hover:not(:disabled) {
  446. border-color: $accent;
  447. color: $accent;
  448. box-shadow: 0 0 8px rgba(72, 215, 255, 0.2);
  449. }
  450. &:disabled {
  451. opacity: 0.3;
  452. cursor: not-allowed;
  453. }
  454. }
  455. .page-info {
  456. font-size: 13px;
  457. color: $text-secondary;
  458. font-family: 'Courier New', monospace;
  459. }
  460. </style>