zdg_dev #75

Merged
zhengdegang merged 8 commits from zdg_dev into main 2024-11-28 16:16:11 +08:00
3 changed files with 31 additions and 17 deletions
Showing only changes of commit c555de5fe5 - Show all commits

View File

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

View File

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

View File

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