zdg_dev #234
|
@ -222,9 +222,11 @@ export const createWindow = async (type, data) => {
|
||||||
if (import.meta.env.VITE_SHOW_DEV_TOOLS === 'true') win.webContents.openDevTools() // 打开调试工具
|
if (import.meta.env.VITE_SHOW_DEV_TOOLS === 'true') win.webContents.openDevTools() // 打开调试工具
|
||||||
let events = {} // 事件处理函数对象
|
let events = {} // 事件处理函数对象
|
||||||
Object.keys(data)
|
Object.keys(data)
|
||||||
.filter(k => typeof data[k] === 'function')
|
.filter(k => typeof data[k] === 'function' && k!=='success')
|
||||||
.forEach(k => events[k] = data[k])
|
.forEach(k => events[k] = data[k])
|
||||||
eventHandles(type, win, events) // 事件监听处理
|
eventHandles(type, win, events) // 事件监听处理
|
||||||
|
// 创建成功后触发回调
|
||||||
|
data.success && data.success(win)
|
||||||
return win
|
return win
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -306,9 +308,9 @@ const eventHandles = (type, win, events) => {
|
||||||
// 监听主窗口-关闭事件
|
// 监听主窗口-关闭事件
|
||||||
mainWin.once('close', () => {winPdf=null;win.destroy();})
|
mainWin.once('close', () => {winPdf=null;win.destroy();})
|
||||||
win.on('closed', () => {
|
win.on('closed', () => {
|
||||||
if(!!onClosed) onClosed() // 自定义关闭事件
|
if(!!onClosed) onClosed(win) // 自定义关闭事件
|
||||||
if(!!closed) closed() // 自定义关闭事件
|
if(!!closed) closed(win) // 自定义关闭事件
|
||||||
if(!!close) close() // 自定义关闭事件
|
if(!!close) close(win) // 自定义关闭事件
|
||||||
win = null
|
win = null
|
||||||
wins_tool = null
|
wins_tool = null
|
||||||
winChild=null
|
winChild=null
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ppt文件转PPT线上数据
|
// ppt文件转PPT线上数据
|
||||||
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,
|
||||||
|
@ -564,13 +573,38 @@ const changeClass = async (type, row, other) => {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'click': { // 点击-打开课件-aippt
|
case 'click': { // 点击-打开课件-aippt
|
||||||
if (row.fileFlag === 'aippt' && !!row.fileId) {
|
if (row.fileFlag === 'aippt' && !!row.fileId) {
|
||||||
|
const id = Number(row.fileId)
|
||||||
|
const openFileIds = sessionStore.get('curr.openFileIds')||[] // 已打开课件列表id
|
||||||
|
const isHasOpen = openFileIds.includes(id) // 是否已打开
|
||||||
|
if (isHasOpen) return ElMessage.warning('该课件已打开!')
|
||||||
const res = await getEntpcoursefile(row.fileId)
|
const res = await getEntpcoursefile(row.fileId)
|
||||||
if (res && res.code === 200) {
|
if (res && res.code === 200) {
|
||||||
|
openFileIds.push(id) // 课堂资源缓存-允许打开多个
|
||||||
|
sessionStore.set('curr.openFileIds', openFileIds) // 更新窗口课件列表id
|
||||||
sessionStore.set('curr.resource', res.data) // 缓存当前资源信息
|
sessionStore.set('curr.resource', res.data) // 缓存当前资源信息
|
||||||
sessionStore.set('curr.smarttalk', row) // 缓存当前文件smarttalk
|
sessionStore.set('curr.smarttalk', row) // 缓存当前文件smarttalk
|
||||||
createWindow('open-win', {
|
createWindow('open-win', {
|
||||||
url: '/pptist', // 窗口关闭时,清除缓存
|
url: '/pptist', // 窗口关闭时,清除缓存
|
||||||
close: () => {
|
success: (win) => { // 窗口打开成功
|
||||||
|
const map = sessionStore.get('curr.winMap') || {}
|
||||||
|
map[win.id] = id // 将当前窗口id和课件id进行关联
|
||||||
|
sessionStore.set('curr.winMap', map)
|
||||||
|
},
|
||||||
|
close: (win) => {
|
||||||
|
const openFileIds = sessionStore.get('curr.openFileIds')||[] // 已打开课件列表id
|
||||||
|
const map = sessionStore.get('curr.winMap') || {}
|
||||||
|
const resourceId = map[win.id] // 当前窗口关联的课件id
|
||||||
|
if (resourceId){
|
||||||
|
const ind = openFileIds.findIndex(id => id == resourceId) // 是否存在打开的课件
|
||||||
|
if (ind >= 0) { // 存在打开的课件
|
||||||
|
openFileIds.splice(ind, 1) // 删除关联课件
|
||||||
|
if (openFileIds.length) sessionStore.set('curr.openFileIds', openFileIds) // 更新窗口课件列表
|
||||||
|
else sessionStore.delete('curr.openFileIds') // 清除缓存
|
||||||
|
delete map[win.id] // 删除 当前窗口课件关联
|
||||||
|
if(Object.keys(map).length) sessionStore.set('curr.winMap', map) // 更新窗口课件关联
|
||||||
|
else sessionStore.delete('curr.winMap') // 清除缓存
|
||||||
|
}
|
||||||
|
}
|
||||||
sessionStore.delete('curr.resource') // 清除缓存
|
sessionStore.delete('curr.resource') // 清除缓存
|
||||||
sessionStore.delete('curr.smarttalk') // 清除缓存
|
sessionStore.delete('curr.smarttalk') // 清除缓存
|
||||||
getSmarttalkPage({
|
getSmarttalkPage({
|
||||||
|
|
|
@ -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: [
|
||||||
|
@ -453,6 +457,9 @@ export default {
|
||||||
}
|
}
|
||||||
case 'click': { // 点击-打开课件-aippt
|
case 'click': { // 点击-打开课件-aippt
|
||||||
if (row.fileFlag === 'aippt' && !!row.fileId) {
|
if (row.fileFlag === 'aippt' && !!row.fileId) {
|
||||||
|
const openFileIds = sessionStore.get('curr.openFileIds')||[] // 已打开课件列表id
|
||||||
|
const isHasOpen = openFileIds.includes(Number(row.fileId)) // 是否已打开
|
||||||
|
if (isHasOpen) return ElMessage.warning('该课件已打开!')
|
||||||
sessionStore.delete('curr.classcourse') // 清除上课相关信息
|
sessionStore.delete('curr.classcourse') // 清除上课相关信息
|
||||||
const res = await getEntpcoursefile(row.fileId)
|
const res = await getEntpcoursefile(row.fileId)
|
||||||
if (res && res.code === 200) {
|
if (res && res.code === 200) {
|
||||||
|
@ -496,12 +503,37 @@ export default {
|
||||||
* @param {object} currData 当前数据 type: edit/class 备课信息 | 课堂信息
|
* @param {object} currData 当前数据 type: edit/class 备课信息 | 课堂信息
|
||||||
*/
|
*/
|
||||||
openPublicScreen(type, resource, currData) {
|
openPublicScreen(type, resource, currData) {
|
||||||
|
const openFileIds = sessionStore.get('curr.openFileIds')||[]
|
||||||
|
const isNoOpen = !openFileIds.includes(Number(resource.id)) // 是否不存在
|
||||||
|
if (isNoOpen) {
|
||||||
|
openFileIds.push(resource.id) // 课堂资源缓存-允许打开多个
|
||||||
|
sessionStore.set('curr.openFileIds', openFileIds) // 更新窗口课件列表id
|
||||||
|
}
|
||||||
sessionStore.set('curr.resource', resource) // 缓存当前资源信息
|
sessionStore.set('curr.resource', resource) // 缓存当前资源信息
|
||||||
if (type=='edit') sessionStore.set('curr.smarttalk', currData) // 缓存当前文件smarttalk
|
if (type=='edit') sessionStore.set('curr.smarttalk', currData) // 缓存当前文件smarttalk
|
||||||
else sessionStore.set('curr.classcourse', currData) // 缓存当前当前上课
|
else sessionStore.set('curr.classcourse', currData) // 缓存当前当前上课
|
||||||
createWindow('open-win', {
|
createWindow('open-win', {
|
||||||
url: '/pptist', // 窗口关闭时,清除缓存
|
url: '/pptist', // 窗口关闭时,清除缓存
|
||||||
close: () => {
|
success: (win) => { // 窗口打开成功
|
||||||
|
const map = sessionStore.get('curr.winMap') || {}
|
||||||
|
map[win.id] = resource.id // 将当前窗口id和课件id进行关联
|
||||||
|
sessionStore.set('curr.winMap', map)
|
||||||
|
},
|
||||||
|
close: (win) => {
|
||||||
|
const openFileIds = sessionStore.get('curr.openFileIds')||[] // 课件列表
|
||||||
|
const map = sessionStore.get('curr.winMap') || {}
|
||||||
|
const resourceId = map[win.id] // 当前窗口关联的课件id
|
||||||
|
if (resourceId){
|
||||||
|
const ind = openFileIds.findIndex(id => id == resourceId) // 是否存在打开的课件
|
||||||
|
if (ind >= 0) { // 存在打开的课件
|
||||||
|
openFileIds.splice(ind, 1) // 删除关联课件
|
||||||
|
if (openFileIds.length) sessionStore.set('curr.openFileIds', openFileIds) // 更新窗口课件列表
|
||||||
|
else sessionStore.delete('curr.openFileIds') // 清除缓存
|
||||||
|
delete map[win.id] // 删除 当前窗口课件关联
|
||||||
|
if(Object.keys(map).length) sessionStore.set('curr.winMap', map) // 更新窗口课件关联
|
||||||
|
else sessionStore.delete('curr.winMap') // 清除缓存
|
||||||
|
}
|
||||||
|
}
|
||||||
sessionStore.delete('curr.resource') // 清除缓存
|
sessionStore.delete('curr.resource') // 清除缓存
|
||||||
if (type=='edit') {
|
if (type=='edit') {
|
||||||
sessionStore.delete('curr.smarttalk') // 清除缓存
|
sessionStore.delete('curr.smarttalk') // 清除缓存
|
||||||
|
@ -584,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);
|
||||||
|
@ -659,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)
|
||||||
|
@ -674,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,
|
||||||
|
|
Loading…
Reference in New Issue