VideoPlayerModal.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="vpm-overlay" @click.self="$emit('close')">
  3. <div class="vpm-dialog">
  4. <button class="vpm-close" @click="$emit('close')" aria-label="关闭">
  5. <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  6. stroke-width="2" stroke-linecap="round">
  7. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  8. </svg>
  9. </button>
  10. <div class="vpm-title">{{ title }}</div>
  11. <video
  12. class="vpm-video"
  13. :src="videoUrl"
  14. controls
  15. autoplay
  16. playsinline
  17. />
  18. </div>
  19. </div>
  20. </template>
  21. <script lang="ts" setup>
  22. defineProps<{ title: string; videoUrl: string }>()
  23. defineEmits<{ (e: 'close'): void }>()
  24. </script>
  25. <style lang="scss" scoped>
  26. .vpm-overlay {
  27. position: fixed;
  28. inset: 0;
  29. background: rgba(0, 0, 0, 0.55);
  30. display: flex;
  31. align-items: center;
  32. justify-content: center;
  33. z-index: 1100;
  34. }
  35. .vpm-dialog {
  36. position: relative;
  37. width: min(80%, 720px);
  38. background: #000;
  39. border-radius: 12px;
  40. overflow: hidden;
  41. box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  42. }
  43. .vpm-title {
  44. position: absolute;
  45. top: 12px;
  46. left: 16px;
  47. color: #fff;
  48. font-size: 14px;
  49. font-weight: 500;
  50. text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  51. z-index: 1;
  52. pointer-events: none;
  53. }
  54. .vpm-close {
  55. position: absolute;
  56. top: 8px;
  57. right: 8px;
  58. width: 32px;
  59. height: 32px;
  60. display: flex;
  61. align-items: center;
  62. justify-content: center;
  63. border: none;
  64. border-radius: 50%;
  65. background: rgba(0, 0, 0, 0.5);
  66. color: #fff;
  67. cursor: pointer;
  68. z-index: 2;
  69. &:hover {
  70. background: rgba(0, 0, 0, 0.75);
  71. }
  72. }
  73. .vpm-video {
  74. width: 100%;
  75. aspect-ratio: 16 / 9;
  76. display: block;
  77. background: #000;
  78. }
  79. </style>