VideoEdit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <el-container v-loading="loading" class="audit-container">
  3. <el-main class="audit-main">
  4. <div class="video-card">
  5. <div class="video-header">
  6. <el-tag size="small" type="info" effect="plain">ID: {{ currentVideo.videoId }}</el-tag>
  7. <h1 class="video-title">{{ currentVideo.title }}</h1>
  8. </div>
  9. <div class="player-wrapper">
  10. <video
  11. ref="videoPlayer"
  12. :key="currentVideo.videoId"
  13. :src="currentVideo.videoUrl"
  14. controls
  15. autoplay
  16. class="main-player"
  17. @timeupdate="onTimeUpdate"
  18. />
  19. </div>
  20. <div class="timeline-fast-tracks">
  21. <span class="track-label"><i class="el-icon-timer" /> 进度抽审:</span>
  22. <el-button-group>
  23. <el-button size="mini" @click="jumpTo(0.1)">10%</el-button>
  24. <el-button size="mini" @click="jumpTo(0.3)">30%</el-button>
  25. <el-button size="mini" @click="jumpTo(0.5)">50%</el-button>
  26. <el-button size="mini" @click="jumpTo(0.8)">80%</el-button>
  27. </el-button-group>
  28. <span class="current-time-tips">当前: {{ formatTime(currentTime) }} / {{ formatTime(duration) }}</span>
  29. </div>
  30. </div>
  31. <div class="meta-card">
  32. <h3 class="section-title">视频简介描述</h3>
  33. <p class="description-text">{{ currentVideo.description || '该视频无文字简介' }}</p>
  34. <div class="meta-grid">
  35. <div class="meta-item">
  36. <span class="label">画幅方向:</span>
  37. <span class="value">{{ currentVideo.horizontal ? '横屏 (16:9)' : '竖屏 (9:16)' }}</span>
  38. </div>
  39. <div class="meta-item">
  40. <span class="label">发布时间:</span>
  41. <span class="value">{{ currentVideo.pubDate }}</span>
  42. </div>
  43. <div class="meta-item">
  44. <span class="label">可见范围:</span>
  45. <el-tag size="mini" type="info">{{ scopeMap[currentVideo.scope] }}</el-tag>
  46. </div>
  47. </div>
  48. </div>
  49. </el-main>
  50. <el-aside width="360px" class="audit-aside">
  51. <div class="aside-card author-card">
  52. <h3 class="section-title">创作者信息</h3>
  53. <div class="author-info">
  54. <el-avatar :size="46" :src="currentVideo.userCard.avatarUrl" icon="el-icon-user-solid" />
  55. <div class="author-detail">
  56. <div class="author-name">{{ currentVideo.userCard.screenName || '未知用户' }}</div>
  57. <div class="author-id">UID: {{ currentVideo.userCard.userIdStr }}</div>
  58. </div>
  59. </div>
  60. <div class="author-badge-group">
  61. <el-tag size="mini" type="success">历史通过率: 98%</el-tag>
  62. <el-tag size="mini" type="warning">违规记录: 0次</el-tag>
  63. </div>
  64. </div>
  65. <div class="aside-card action-card">
  66. <h3 class="section-title">审核决策面板</h3>
  67. <el-form ref="auditForm" :model="auditForm" label-position="top" size="small">
  68. <el-form-item label="标签" prop="videoTags">
  69. <el-checkbox-group v-model="auditForm.videoTags">
  70. <el-checkbox
  71. v-for="item in tagList"
  72. :key="item.value"
  73. :label="item.label"
  74. :value="item.value"
  75. />
  76. </el-checkbox-group>
  77. </el-form-item>
  78. <div class="submit-buttons">
  79. <el-button
  80. type="success"
  81. icon="el-icon-check"
  82. class="btn-approve"
  83. :loading="submitting"
  84. @click="submitEdit"
  85. >
  86. 提交编辑
  87. </el-button>
  88. </div>
  89. </el-form>
  90. </div>
  91. </el-aside>
  92. </el-container>
  93. </template>
  94. <script>
  95. import { getAuditVideo, submitEditVideo } from '@/api/vod'
  96. export default {
  97. name: 'VideoEdit',
  98. // 组件激活前:摘除全局 #app 的强制滚动行为
  99. beforeRouteEnter(to, from, next) {
  100. next(vm => {
  101. const appEl = document.getElementById('app')
  102. if (appEl) appEl.style.overflowY = 'hidden'
  103. })
  104. },
  105. // 组件离开前:还原还原全局 #app 的原貌,不破坏其他页面的行为
  106. beforeRouteLeave(to, from, next) {
  107. const appEl = document.getElementById('app')
  108. if (appEl) appEl.style.overflowY = 'scroll'
  109. next()
  110. },
  111. data() {
  112. return {
  113. loading: false,
  114. submitting: false,
  115. currentTime: 0,
  116. duration: 0,
  117. scopeMap: {
  118. 1: '本人可见',
  119. 2: '所有人可见',
  120. 3: 'VIP 可见'
  121. },
  122. auditResult: {
  123. PUBLISHED: 3,
  124. REVIEW_REJECTED: 4
  125. },
  126. tagList: [
  127. { label: '涉政违规', value: '涉政违规' },
  128. { label: '色情低俗', value: '色情低俗' },
  129. { label: '血腥暴力', value: '血腥暴力' },
  130. { label: '侵权盗版', value: '侵权盗版' },
  131. { label: '垃圾广告', value: '垃圾广告' },
  132. { label: '画质低劣', value: '画质低劣' }
  133. ],
  134. // 当前待审核的视频数据模型
  135. currentVideo: {
  136. videoId: '',
  137. title: '',
  138. description: '',
  139. videoUrl: '',
  140. horizontal: null,
  141. pubDate: '',
  142. scope: 0,
  143. userCard: {
  144. userId: '',
  145. screenName: '',
  146. avatarUrl: ''
  147. }
  148. },
  149. auditForm: {
  150. videoId: null,
  151. videoTags: []
  152. }
  153. }
  154. },
  155. watch: {
  156. // 🌟 【核心修复】当 URL 中的 videoId 发生变化时,优雅地清理并重新加载
  157. '$route.params.id': {
  158. handler(newVideoId) {
  159. if (newVideoId) {
  160. // 1. 先安全地把当前的播放器彻底断流、卸载,腾出硬件解码器空间
  161. this.releaseVideoPlayer()
  162. // 2. 传入新的 ID,重新请求后端数据
  163. this.fetchNextVideo(newVideoId)
  164. }
  165. },
  166. immediate: false // 首次进页面交给 created,后续切换交给 watch
  167. }
  168. },
  169. created() {
  170. document.title = 'VideoEdit'
  171. const videoId = this.$route.params.id
  172. this.fetchNextVideo(videoId)
  173. },
  174. mounted() {
  175. // 全局监听键盘事件,开启极限盲审模式
  176. window.addEventListener('keydown', this.handleKeyboardShortcuts)
  177. },
  178. beforeDestroy() {
  179. window.removeEventListener('keydown', this.handleKeyboardShortcuts)
  180. },
  181. methods: {
  182. releaseVideoPlayer() {
  183. const player = this.$refs.videoPlayer
  184. if (player) {
  185. try {
  186. player.pause()
  187. player.src = '' // 切断视频网络流
  188. player.removeAttribute('src') // 彻底移除资源属性
  189. player.load() // 强制浏览器对该 DOM 节点触发垃圾回收
  190. } catch (e) {
  191. console.warn('释放播放器时发生异常:', e)
  192. }
  193. }
  194. },
  195. // 获取下一条待审核视频
  196. // 获取下一条待审核视频
  197. fetchNextVideo(videoId) {
  198. this.loading = true
  199. // 重置表单状态
  200. this.auditForm = { videoTags: [] }
  201. this.currentTime = 0
  202. this.duration = 0
  203. const queryParams = { videoId }
  204. getAuditVideo(queryParams).then(resp => {
  205. if (resp.code === 0) {
  206. this.currentVideo = resp.data
  207. this.auditForm.videoId = this.currentVideo.videoId
  208. // 确保 DOM 渲染完新地址后,播放器干净利开跑
  209. this.$nextTick(() => {
  210. const player = this.$refs.videoPlayer
  211. if (player) player.load()
  212. })
  213. } else {
  214. this.$message.warning(resp.msg)
  215. }
  216. }).finally(() => {
  217. this.loading = false
  218. })
  219. },
  220. submitEdit() {
  221. if (this.auditForm.videoTags.length === 0) {
  222. this.$message.error('请选择视频标签')
  223. return
  224. }
  225. this.submitting = true
  226. submitEditVideo(this.auditForm).then(resp => {
  227. if (resp.code === 0) {
  228. const nextVideoId = resp.data
  229. this.submitting = false
  230. this.$notify({
  231. title: status === this.auditResult.PUBLISHED ? '审核通过' : '已驳回',
  232. message: `视频 [${this.currentVideo.videoId}] 处理完毕,已自动加载下一条视频 [${nextVideoId}]。`,
  233. type: status === this.auditResult.PUBLISHED ? 'success' : 'warning',
  234. duration: 2500
  235. })
  236. // 🌟 这里正常 push。URL 会发生变化,从而触发上面的 '$route.params.id' 监听器
  237. this.$router.push('/vod_audit/' + nextVideoId)
  238. } else {
  239. this.$message.warning(resp.msg)
  240. }
  241. }).catch((error) => {
  242. this.$message.error(error.message)
  243. }).finally(() => {
  244. this.submitting = false
  245. })
  246. },
  247. // 播放器时间更新
  248. onTimeUpdate(e) {
  249. this.currentTime = e.target.currentTime
  250. this.duration = e.target.duration || 0
  251. },
  252. // 时间轴快捷百分比跳跃
  253. jumpTo(percentage) {
  254. const player = this.$refs.videoPlayer
  255. if (player && this.duration) {
  256. player.currentTime = this.duration * percentage
  257. }
  258. },
  259. // 工具函数:格式化时间 (00:00)
  260. formatTime(seconds) {
  261. if (isNaN(seconds)) return '00:00'
  262. const min = Math.floor(seconds / 60).toString().padStart(2, '0')
  263. const sec = Math.floor(seconds % 60).toString().padStart(2, '0')
  264. return `${min}:${sec}`
  265. },
  266. // 键盘快捷键矩阵处理器
  267. handleKeyboardShortcuts(e) {
  268. // 如果光标正停留在文本输入框内,不触发快捷键,防止冲突
  269. if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return
  270. const player = this.$refs.videoPlayer
  271. switch (e.key) {
  272. case ' ': // 空格键:暂停/播放
  273. e.preventDefault()
  274. if (player) {
  275. player.paused ? player.play() : player.pause()
  276. }
  277. break
  278. case 'ArrowRight': // 方向右键:快进5秒
  279. if (player) player.currentTime += 5
  280. break
  281. case 'ArrowLeft': // 方向左键:快退5秒
  282. if (player) player.currentTime -= 5
  283. break
  284. case 'A': // Shift + A: 快捷通过
  285. if (e.shiftKey) this.submitAudit(3)
  286. break
  287. case 'R': // Shift + R: 快捷拒绝
  288. if (e.shiftKey) this.submitAudit(4)
  289. break
  290. }
  291. }
  292. }
  293. }
  294. </script>
  295. <style scoped>
  296. /* 全局页面沙箱 - 修正为直接吃满 100vh 浏览器视口 */
  297. .audit-container {
  298. height: 100vh;
  299. width: 100vw;
  300. background-color: #f4f7f9;
  301. gap: 20px;
  302. padding: 20px; /* 给四周留出高级的视窗边距 */
  303. box-sizing: border-box; /* 锁定边距不撑开大盘 */
  304. overflow: hidden; /* 严禁外层容器出现滚动条 */
  305. }
  306. /* ==================== 🎬 左侧内容区 ==================== */
  307. .audit-main {
  308. padding: 0;
  309. display: flex;
  310. flex-direction: column;
  311. gap: 20px;
  312. height: 100%; /* 锁定跟随父级高度 */
  313. overflow-y: auto; /* 仅允许内容区独立轴向滚动 */
  314. }
  315. .video-card {
  316. background: #ffffff;
  317. border-radius: 8px;
  318. padding: 20px;
  319. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  320. }
  321. .video-header {
  322. display: flex;
  323. align-items: center;
  324. gap: 12px;
  325. margin-bottom: 16px;
  326. }
  327. .video-title {
  328. font-size: 18px;
  329. font-weight: 600;
  330. color: #1e293b;
  331. margin: 0;
  332. }
  333. /* 核心播放器容器 */
  334. .player-wrapper {
  335. background-color: #000000;
  336. border-radius: 6px;
  337. overflow: hidden;
  338. position: relative;
  339. width: 100%;
  340. aspect-ratio: 16 / 9; /* 保持16:9黄金比例,自适应各屏幕 */
  341. max-height: 500px;
  342. display: flex;
  343. justify-content: center;
  344. align-items: center;
  345. }
  346. .main-player {
  347. width: 100%;
  348. height: 100%;
  349. object-fit: contain; /* 防止视频拉伸变形 */
  350. }
  351. /* 抽审进度控制条 */
  352. .timeline-fast-tracks {
  353. margin-top: 14px;
  354. display: flex;
  355. align-items: center;
  356. gap: 12px;
  357. background: #f8fafc;
  358. padding: 8px 12px;
  359. border-radius: 6px;
  360. border: 1px dashed #e2e8f0;
  361. }
  362. .track-label {
  363. font-size: 13px;
  364. color: #64748b;
  365. font-weight: 500;
  366. }
  367. .current-time-tips {
  368. margin-left: auto;
  369. font-family: monospace;
  370. font-size: 13px;
  371. color: #334155;
  372. background: #cbd5e1;
  373. padding: 2px 8px;
  374. border-radius: 4px;
  375. }
  376. /* 视频元数据描述卡片 */
  377. .meta-card {
  378. background: #ffffff;
  379. border-radius: 8px;
  380. padding: 20px;
  381. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  382. }
  383. .section-title {
  384. font-size: 14px;
  385. font-weight: 600;
  386. color: #475569;
  387. margin-top: 0;
  388. margin-bottom: 12px;
  389. border-left: 3px solid #1890ff;
  390. padding-left: 8px;
  391. }
  392. .description-text {
  393. font-size: 14px;
  394. color: #334155;
  395. line-height: 1.6;
  396. background: #f8fafc;
  397. padding: 12px;
  398. border-radius: 6px;
  399. margin-bottom: 16px;
  400. }
  401. .meta-grid {
  402. display: grid;
  403. grid-template-columns: repeat(3, 1fr);
  404. gap: 16px;
  405. }
  406. .meta-item {
  407. font-size: 13px;
  408. }
  409. .meta-item .label { color: #64748b; }
  410. .meta-item .value { color: #1e293b; font-weight: 500; }
  411. /* ==================== 🛠️ 右侧风控工作台 ==================== */
  412. .audit-aside {
  413. display: flex;
  414. flex-direction: column;
  415. gap: 20px;
  416. height: 100%; /* 锁定跟随父级高度 */
  417. overflow-y: auto; /* 防止右侧内容过多时溢出屏幕 */
  418. }
  419. .aside-card {
  420. background: #ffffff;
  421. border-radius: 8px;
  422. padding: 20px;
  423. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  424. }
  425. /* 创作者信息 */
  426. .author-info {
  427. display: flex;
  428. align-items: center;
  429. gap: 12px;
  430. margin-bottom: 12px;
  431. }
  432. .author-name {
  433. font-size: 15px;
  434. font-weight: 600;
  435. color: #1e293b;
  436. }
  437. .author-id {
  438. font-size: 12px;
  439. color: #94a3b8;
  440. margin-top: 2px;
  441. }
  442. .author-badge-group {
  443. display: flex;
  444. gap: 6px;
  445. }
  446. /* 审核决策控制流 */
  447. ::v-deep .el-checkbox {
  448. margin-bottom: 8px;
  449. margin-right: 16px;
  450. width: 120px; /* 两列规整排列 */
  451. }
  452. .submit-buttons {
  453. display: flex;
  454. gap: 12px;
  455. margin-top: 20px;
  456. }
  457. .btn-reject, .btn-approve {
  458. flex: 1;
  459. height: 40px;
  460. font-weight: 600;
  461. border-radius: 6px;
  462. }
  463. /* 盲审快捷键指南卡片 */
  464. .shortcut-card {
  465. background: #0f172a; /* 深色极客风,与快捷键功能相呼应 */
  466. color: #94a3b8;
  467. }
  468. .shortcut-title {
  469. color: #f1f5f9;
  470. margin: 0 0 12px 0;
  471. font-size: 13px;
  472. font-weight: 500;
  473. }
  474. .shortcut-grid {
  475. display: grid;
  476. grid-template-columns: 1fr;
  477. gap: 8px;
  478. }
  479. .shortcut-item {
  480. display: flex;
  481. justify-content: space-between;
  482. align-items: center;
  483. font-size: 12px;
  484. }
  485. kbd {
  486. background-color: #334155;
  487. color: #ffffff;
  488. border-radius: 3px;
  489. border: 1px solid #475569;
  490. padding: 2px 6px;
  491. font-family: monospace;
  492. font-weight: bold;
  493. box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  494. }
  495. .text-success { color: #10b981; }
  496. .text-danger { color: #ef4444; }
  497. </style>