ppt导入-解析过程中增加关闭功能

This commit is contained in:
zdg 2025-02-11 14:30:22 +08:00
parent 6f3ffc45cf
commit 3032e2fb3a
2 changed files with 30 additions and 10 deletions

View File

@ -288,14 +288,17 @@ const createAIPPT = () => {
}) })
}) })
} }
const isPgDialogClose = ref(false) // --
const pgDialog = ref({ // - const pgDialog = ref({ // -
visible: false, visible: false,
title: 'PPT解析中...', title: 'PPT解析中...',
width: 300, width: 300,
showClose: false, showClose: true,
draggable: true, draggable: true,
beforeClose: done => {}, // - beforeClose: done => { //
isPgDialogClose.value = true
done()
},
pg: { // - pg: { // -
percentage: 0, // percentage: 0, //
color: [ color: [
@ -316,20 +319,26 @@ const openFilePicker = () =>{
const handleFileChange = ()=> { const handleFileChange = ()=> {
const file = event.target.files[0]; const file = event.target.files[0];
fileInput.value.value = ''
if (file) { if (file) {
console.log(file);
createAIPPTByFile(file) createAIPPTByFile(file)
} }
} }
// pptPPT线 // pptPPT线
const createAIPPTByFile = async (file)=> { const createAIPPTByFile = async (file)=> {
isPgDialogClose.value = false //
pgDialog.value.visible = true pgDialog.value.visible = true
pgDialog.value.pg.percentage = 0 pgDialog.value.pg.percentage = 0
const closePgDialog = () => {
pgDialog.value.pg.percentage = 0
pgDialog.value.visible = false
}
pptMedia = {} // pptMedia = {} //
const resPptJson = await PPTXFileToJson(file).catch(() => { const resPptJson = await PPTXFileToJson(file).catch(() => {
ElMessageBox.alert('PPT文件转换失败请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入') ElMessageBox.alert('PPT文件转换失败请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入')
pgDialog.value.visible = false pgDialog.value.visible = false
}) })
if(isPgDialogClose.value) return closePgDialog() // ,
const { def, slides, ...content } = resPptJson const { def, slides, ...content } = resPptJson
// //
const thumbnails = await slidesToImg(slides, content.width) const thumbnails = await slidesToImg(slides, content.width)
@ -337,13 +346,13 @@ const createAIPPTByFile = async (file)=> {
let completed = 0 let completed = 0
const total = slides.length const total = slides.length
for( let o of slides ) { for( let o of slides ) {
if(isPgDialogClose.value) return closePgDialog() // ,
completed++ completed++
await toRousrceUrl(o) await toRousrceUrl(o)
// //
pgDialog.value.pg.percentage = Math.floor(completed / total * 100) pgDialog.value.pg.percentage = Math.floor(completed / total * 100)
} }
pgDialog.value.pg.percentage = 0 closePgDialog() //
pgDialog.value.visible = false
listEntpcourse({ listEntpcourse({
evalid: currentNode.value.id, evalid: currentNode.value.id,
edituserid: userStore.userId, edituserid: userStore.userId,

View File

@ -274,13 +274,17 @@ export default {
treelogRef:null, treelogRef:null,
// Entpcourse // Entpcourse
entp: null, entp: null,
isPgDialogClose: false, //
pgDialog: { // - pgDialog: { // -
visible: false, visible: false,
title: 'PPT解析中...', title: 'PPT解析中...',
width: 300, width: 300,
showClose: false, showClose: true,
draggable: true, draggable: true,
beforeClose: done => {}, // - beforeClose: done => { //
this.isPgDialogClose = true
done()
},
pg: { // - pg: { // -
percentage: 0, // percentage: 0, //
color: [ color: [
@ -612,6 +616,7 @@ export default {
}, },
handleFileChange(){ handleFileChange(){
const file = event.target.files[0]; const file = event.target.files[0];
this.$refs.fileInput.value = ''
if (file) { if (file) {
console.log(file); console.log(file);
console.log('文件名:', file.name); console.log('文件名:', file.name);
@ -687,14 +692,20 @@ export default {
} }
}, },
async createAIPPTByFile(file,fileShowName) { async createAIPPTByFile(file,fileShowName) {
this.isPgDialogClose = false //
this.pgDialog.visible = true this.pgDialog.visible = true
this.pgDialog.pg.percentage = 0 this.pgDialog.pg.percentage = 0
const closePgDialog = () => {
this.pgDialog.pg.percentage = 0
this.pgDialog.visible = false
}
this.pptMedia = {} // this.pptMedia = {} //
const resPptJson = await PPTXFileToJson(file).catch(() => { const resPptJson = await PPTXFileToJson(file).catch(() => {
ElMessageBox.alert('PPT文件转换失败请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入') ElMessageBox.alert('PPT文件转换失败请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入')
this.pgDialog.visible = false this.pgDialog.visible = false
}) })
if (!resPptJson) return if (!resPptJson) return
if(this.isPgDialogClose) return closePgDialog() // ,
const { def, slides, ...content } = resPptJson const { def, slides, ...content } = resPptJson
// //
const thumbnails = await slidesToImg(slides, content.width) const thumbnails = await slidesToImg(slides, content.width)
@ -702,13 +713,13 @@ export default {
let completed = 0 let completed = 0
const total = slides.length const total = slides.length
for( let o of slides ) { for( let o of slides ) {
if(this.isPgDialogClose) return closePgDialog() // ,
completed++ completed++
await this.toRousrceUrl(o) await this.toRousrceUrl(o)
// //
this.pgDialog.pg.percentage = Math.floor(completed / total * 100) this.pgDialog.pg.percentage = Math.floor(completed / total * 100)
} }
this.pgDialog.pg.percentage = 0 closePgDialog() //
this.pgDialog.visible = false
listEntpcourse({ listEntpcourse({
evalid: this.currentNode.id, evalid: this.currentNode.id,
edituserid: this.userStore.userId, edituserid: this.userStore.userId,