From 3032e2fb3a2cda53fcd8bc9c823241ef50bf504a Mon Sep 17 00:00:00 2001 From: zdg Date: Tue, 11 Feb 2025 14:30:22 +0800 Subject: [PATCH] =?UTF-8?q?ppt=E5=AF=BC=E5=85=A5-=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/views/model/index.vue | 21 +++++++++++++++------ src/renderer/src/views/prepare/index.vue | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/views/model/index.vue b/src/renderer/src/views/model/index.vue index bf42e91..6ceca61 100644 --- a/src/renderer/src/views/model/index.vue +++ b/src/renderer/src/views/model/index.vue @@ -288,14 +288,17 @@ const createAIPPT = () => { }) }) } - +const isPgDialogClose = ref(false) // 弹窗-进度条-是否关闭 const pgDialog = ref({ // 弹窗-进度条 visible: false, title: 'PPT解析中...', width: 300, - showClose: false, + showClose: true, draggable: true, - beforeClose: done => {}, // 阻止-弹窗事件 + beforeClose: done => { // 弹窗关闭前回调 + isPgDialogClose.value = true + done() + }, pg: { // 进度条-参数 percentage: 0, // 百分比 color: [ @@ -316,20 +319,26 @@ const openFilePicker = () =>{ const handleFileChange = ()=> { const file = event.target.files[0]; + fileInput.value.value = '' if (file) { - console.log(file); createAIPPTByFile(file) } } // ppt文件转PPT线上数据 const createAIPPTByFile = async (file)=> { + isPgDialogClose.value = false // 默认没有关闭 pgDialog.value.visible = true pgDialog.value.pg.percentage = 0 + const closePgDialog = () => { + pgDialog.value.pg.percentage = 0 + pgDialog.value.visible = false + } pptMedia = {} // 清空媒体数据 const resPptJson = await PPTXFileToJson(file).catch(() => { ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!') pgDialog.value.visible = false }) + if(isPgDialogClose.value) return closePgDialog() // 弹窗关闭了,终止进行 const { def, slides, ...content } = resPptJson // 生成缩略图 const thumbnails = await slidesToImg(slides, content.width) @@ -337,13 +346,13 @@ const createAIPPTByFile = async (file)=> { let completed = 0 const total = slides.length for( let o of slides ) { + if(isPgDialogClose.value) return closePgDialog() // 弹窗关闭了,终止进行 completed++ await toRousrceUrl(o) // 设置进度条 pgDialog.value.pg.percentage = Math.floor(completed / total * 100) } - pgDialog.value.pg.percentage = 0 - pgDialog.value.visible = false + closePgDialog() // 关闭进度条弹窗 listEntpcourse({ evalid: currentNode.value.id, edituserid: userStore.userId, diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index e35738c..444a4bb 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -274,13 +274,17 @@ export default { treelogRef:null, // 获取当前章节对应的课程信息 Entpcourse entp: null, + isPgDialogClose: false, // 关闭进度条弹窗 pgDialog: { // 弹窗-进度条 visible: false, title: 'PPT解析中...', width: 300, - showClose: false, + showClose: true, draggable: true, - beforeClose: done => {}, // 阻止-弹窗事件 + beforeClose: done => { // 弹窗关闭前回调 + this.isPgDialogClose = true + done() + }, pg: { // 进度条-参数 percentage: 0, // 百分比 color: [ @@ -612,6 +616,7 @@ export default { }, handleFileChange(){ const file = event.target.files[0]; + this.$refs.fileInput.value = '' if (file) { console.log(file); console.log('文件名:', file.name); @@ -687,14 +692,20 @@ export default { } }, async createAIPPTByFile(file,fileShowName) { + this.isPgDialogClose = false // 默认不关闭 this.pgDialog.visible = true this.pgDialog.pg.percentage = 0 + const closePgDialog = () => { + this.pgDialog.pg.percentage = 0 + this.pgDialog.visible = false + } this.pptMedia = {} // 清空媒体数据 const resPptJson = await PPTXFileToJson(file).catch(() => { ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!') this.pgDialog.visible = false }) if (!resPptJson) return + if(this.isPgDialogClose) return closePgDialog() // 弹窗关闭了,终止进行 const { def, slides, ...content } = resPptJson // 生成缩略图 const thumbnails = await slidesToImg(slides, content.width) @@ -702,13 +713,13 @@ export default { let completed = 0 const total = slides.length for( let o of slides ) { + if(this.isPgDialogClose) return closePgDialog() // 弹窗关闭了,终止进行 completed++ await this.toRousrceUrl(o) // 设置进度条 this.pgDialog.pg.percentage = Math.floor(completed / total * 100) } - this.pgDialog.pg.percentage = 0 - this.pgDialog.visible = false + closePgDialog() // 关闭进度条弹窗 listEntpcourse({ evalid: this.currentNode.id, edituserid: this.userStore.userId,