修复pptx

This commit is contained in:
zdg 2024-11-27 14:09:32 +08:00
parent a10d3b078b
commit c555de5fe5
3 changed files with 31 additions and 17 deletions

View File

@ -26,6 +26,7 @@ import Mobile from './views/Mobile/index.vue'
import msgUtils from '@/plugins/modal' // import msgUtils from '@/plugins/modal' //
import * as API_entpcoursefile from '@/api/education/entpcoursefile' // api import * as API_entpcoursefile from '@/api/education/entpcoursefile' // api
import { PPTApi } from './api' import { PPTApi } from './api'
import { sessionStore } from '@/utils/store' // electron-store
const loading = ref(true) const loading = ref(true)
const _isPC = isPC() const _isPC = isPC()
@ -68,11 +69,17 @@ interface Result {
} }
// //
const initLoad: Function = () => { const initLoad: Function = () => {
const urlSearch = location.href.split('?')[1] // const urlSearch = location.href.split('?')[1]
const query = Object.fromEntries(new URLSearchParams(urlSearch)) // const query = Object.fromEntries(new URLSearchParams(urlSearch))
const id: String = query.id // const id: String = query.id
// pptx // // pptx
if (!!id) return PPTApi.getSlideList(id) // if (!!id) return PPTApi.getSlideList(id)
//
const resource = sessionStore.get('curr.resource')
if (!!resource) { // ppt
slidesStore.setTitle(resource.title)
return PPTApi.getSlideList(resource.id)
}
return Promise.resolve() return Promise.resolve()
} }

View File

@ -216,7 +216,11 @@ export const createWindow = async (type, data) => {
win.maximize(); win.maximize();
// win.setFullScreen(true) // 设置窗口为全屏 // win.setFullScreen(true) // 设置窗口为全屏
if (import.meta.env.VITE_SHOW_DEV_TOOLS === 'true') win.webContents.openDevTools() // 打开调试工具 if (import.meta.env.VITE_SHOW_DEV_TOOLS === 'true') win.webContents.openDevTools() // 打开调试工具
eventHandles(type, win) // 事件监听处理 let events = {} // 事件处理函数对象
Object.keys(data)
.filter(k => typeof data[k] === 'function')
.forEach(k => events[k] = data[k])
eventHandles(type, win, events) // 事件监听处理
break break
} }
default: default:
@ -286,17 +290,20 @@ export function toolWindow(type, {url, isConsole, isWeb=true, option={}}) {
* 窗口创建-事件处理 * 窗口创建-事件处理
* @param {*} type 事件类型 * @param {*} type 事件类型
* @param {*} win 窗口对象 * @param {*} win 窗口对象
* @param {*} events 事件对象
*/ */
const eventHandles = (type, win) => { const eventHandles = (type, win, events) => {
const toolState = useToolState() // 获取store状态 const toolState = useToolState() // 获取store状态
const winAll = Remote.BrowserWindow.getAllWindows() const winAll = Remote.BrowserWindow.getAllWindows()
const mainWin = winAll.find(o => o.type == 'main') // 主窗口对象 const mainWin = winAll.find(o => o.type == 'main') // 主窗口对象
// 公共方法 // 公共方法
const publicMethods = ({onClosed}={}) => { const publicMethods = ({onClosed, closed, close}={}) => {
// 监听主窗口-关闭事件 // 监听主窗口-关闭事件
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() // 自定义关闭事件
if(!!closed) closed() // 自定义关闭事件
if(!!close) close() // 自定义关闭事件
win = null win = null
wins_tool = null wins_tool = null
winChild=null winChild=null
@ -385,8 +392,7 @@ const eventHandles = (type, win) => {
win&&win.destroy() win&&win.destroy()
}); });
const on = { const on = {
onClosed: () => { ...events
}
} }
publicMethods(on) // 加载公共方法 publicMethods(on) // 加载公共方法
break break

View File

@ -255,13 +255,14 @@ const handleAll = async(type, row) =>{
break; break;
} }
case 'open': { // -pptist case 'open': { // -pptist
// console.log(row)
if (row.filetype != 'aptist') return msgUtils.msgWarning('暂不支持该类型文件!') if (row.filetype != 'aptist') return msgUtils.msgWarning('暂不支持该类型文件!')
sessionStore.set('curr.resource', row) // //
const query = { id: row.id } sessionStore.set('curr.resource', row)
const queryUrl = new URLSearchParams(query).toString() createWindow('open-win', {
console.log('打开资源 ', queryUrl) url: '/pptist',
createWindow('open-win', { url: `/pptist?${queryUrl}` }) //
close: () => {sessionStore.set('curr.resource', null)}
})
} }
} }
} }