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() // 打开调试工具
|
||||
let events = {} // 事件处理函数对象
|
||||
Object.keys(data)
|
||||
.filter(k => typeof data[k] === 'function')
|
||||
.filter(k => typeof data[k] === 'function' && k!=='success')
|
||||
.forEach(k => events[k] = data[k])
|
||||
eventHandles(type, win, events) // 事件监听处理
|
||||
// 创建成功后触发回调
|
||||
data.success && data.success(win)
|
||||
return win
|
||||
}
|
||||
default:
|
||||
|
@ -306,9 +308,9 @@ const eventHandles = (type, win, events) => {
|
|||
// 监听主窗口-关闭事件
|
||||
mainWin.once('close', () => {winPdf=null;win.destroy();})
|
||||
win.on('closed', () => {
|
||||
if(!!onClosed) onClosed() // 自定义关闭事件
|
||||
if(!!closed) closed() // 自定义关闭事件
|
||||
if(!!close) close() // 自定义关闭事件
|
||||
if(!!onClosed) onClosed(win) // 自定义关闭事件
|
||||
if(!!closed) closed(win) // 自定义关闭事件
|
||||
if(!!close) close(win) // 自定义关闭事件
|
||||
win = null
|
||||
wins_tool = null
|
||||
winChild=null
|
||||
|
|
|
@ -564,13 +564,38 @@ const changeClass = async (type, row, other) => {
|
|||
switch(type) {
|
||||
case 'click': { // 点击-打开课件-aippt
|
||||
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)
|
||||
if (res && res.code === 200) {
|
||||
openFileIds.push(id) // 课堂资源缓存-允许打开多个
|
||||
sessionStore.set('curr.openFileIds', openFileIds) // 更新窗口课件列表id
|
||||
sessionStore.set('curr.resource', res.data) // 缓存当前资源信息
|
||||
sessionStore.set('curr.smarttalk', row) // 缓存当前文件smarttalk
|
||||
createWindow('open-win', {
|
||||
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.smarttalk') // 清除缓存
|
||||
getSmarttalkPage({
|
||||
|
|
|
@ -453,6 +453,9 @@ export default {
|
|||
}
|
||||
case 'click': { // 点击-打开课件-aippt
|
||||
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') // 清除上课相关信息
|
||||
const res = await getEntpcoursefile(row.fileId)
|
||||
if (res && res.code === 200) {
|
||||
|
@ -496,12 +499,37 @@ export default {
|
|||
* @param {object} currData 当前数据 type: edit/class 备课信息 | 课堂信息
|
||||
*/
|
||||
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) // 缓存当前资源信息
|
||||
if (type=='edit') sessionStore.set('curr.smarttalk', currData) // 缓存当前文件smarttalk
|
||||
else sessionStore.set('curr.classcourse', currData) // 缓存当前当前上课
|
||||
createWindow('open-win', {
|
||||
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') // 清除缓存
|
||||
if (type=='edit') {
|
||||
sessionStore.delete('curr.smarttalk') // 清除缓存
|
||||
|
|
Loading…
Reference in New Issue