Flex
2025-04-23 9313e8f67bc9865c516065cbb778d6b273882155
添加人脸校验
已修改1个文件
38 ■■■■■ 文件已修改
easegen-front/src/views/chooseTemplate/index.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
easegen-front/src/views/chooseTemplate/index.vue
@@ -628,7 +628,8 @@
<script lang="ts" setup>
import { ref, reactive, onMounted } from 'vue'
import draggable from 'vuedraggable'
//引入人脸识别方法
import { useFaceDetection } from '@/utils/HaveFace'
import Vue3DraggableResizable from 'vue3-draggable-resizable'
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
import { config } from '@/config/axios/config'
@@ -687,6 +688,10 @@
const message = useMessage()
const isEditing = ref(false)
const inputRef = ref(null)
//当前是否存在人脸
const IsHaveFace = ref(false)
//当前是否完成ppt人脸校验
const IsEndCheckFace = ref(true)
// 切换到编辑模式
const toggleEdit = () => {
  isEditing.value = true
@@ -1015,6 +1020,18 @@
  }
  return selectPPT.value?.pictureUrl || ''
})
//ppt人脸校验方法
const PPtIsHaveFace = async ()=>{
  IsEndCheckFace.value = false
  //添加ppt中人脸校验
  //向原始ppt添加数据,用作后续ppt中是否包含人脸的数据校验原始数据
  const InitPpt = PPTArr.value.map( (item)=>{
      return item.innerPicture.src
  } )
  const { detectFacesInImages } = useFaceDetection()
  IsHaveFace.value = await detectFacesInImages(InitPpt)
  IsEndCheckFace.value = true
}
// 打开智能讲稿弹窗
const openScriptRewriter = () => {
  if (!selectPPT.value?.pptRemark && !currentImageUrl.value) {
@@ -1180,6 +1197,10 @@
        console.log('selectPPT.value', selectPPT.value)
        showLeftList.value = true
        clearInterval(schedulePPTTimer.value)
        //ppt人脸校验
        PPtIsHaveFace()
        //轮询保存课程
        /**
         * 后端数据库压力过大,暂时停止定时保存
@@ -1463,6 +1484,19 @@
    return false
  }
  //人脸校验
  while(!IsEndCheckFace.value){} //一个空循环,主要为了避免极端情况下当用户点击保存按钮或者视频合成按钮时,人脸校验未完成的问题
  if( IsHaveFace.value ){
    message.warning('当前ppt中存在人脸元素,为方便后续视频生成,请去除该元素')
    return
  }
  //保存课程
  let saveSubmitForm = {
    accountId: courseInfo.value.accountId,
@@ -1647,6 +1681,8 @@
      for (let i = 0; i < PPTArr.value.length; i++) {
        const item = PPTArr.value[i]
        console.log(item)
        console.log( "宽度", item.width )
        console.log( "高度", item.height )
        // 校验背景宽高
        if (!item.width || !item.height) {
          message.warning('背景尺寸无效,请检查宽高设置,或者重新选择模板')