VideoModal.vue 1.21 KB
<template>
  <a-modal :visible="visible" @cancel="handleClose" @ok="handleClose" title="流程演示">
    <div>
      <!-- 添加 autoplay 和 muted 属性来确保视频自动播放 -->
      <video :src="videoUrl" controls autoplay muted></video>
      <p>{{ videoDescription }}</p>
    </div>
    <!-- 将确定和取消按钮替换为一个“已完成学习”按钮 -->
    <template #footer>
      <a-button type="primary" @click="handleComplete">已学习</a-button>
    </template>
  </a-modal>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    videoUrl: {
      type: String,
      default: ''
    },
    videoDescription: {
      type: String,
      default: ''
    }
  },
  methods: {
    handleClose() {
      this.$emit('update:visible', false);  // 关闭模态框时通知父组件
    },
    // 点击“已完成学习”按钮后的处理逻辑
    handleComplete() {
      this.$emit('update:visible', false);  // 关闭模态框
      this.$emit('completed');  // 触发已完成学习的事件
    },
  }
};
</script>

<style scoped>
/* 添加一些自定义样式,例如视频大小调整 */
video {
  max-width: 100%;
  height: auto;
}
</style>