ppt导入-解析过程中增加关闭功能
This commit is contained in:
parent
6f3ffc45cf
commit
3032e2fb3a
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue