From 7fc04faad1533d57dfac0d0d13fb9d655362c988 Mon Sep 17 00:00:00 2001 From: zhuhao <979263092@qq.com> Date: Tue, 13 Aug 2024 17:43:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=9C=9F=EF=BC=9ABUG=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/utils/tool.js | 21 +++++++++++-------- .../src/views/classManage/reserv-item.vue | 8 +++---- src/renderer/src/views/prepare/index.vue | 1 - 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index c9c91f1..28c7902 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -82,7 +82,9 @@ export function ipcHandle(fn,key, cb) { * @param {*} data 参数 * @returns */ +let wins_tool = null export const createWindow = async (type, data) => { + if (wins_tool) return console.error('createWindow: win is have') if (!type) return console.error('createWindow: type is null') switch(type) { case 'tool-sphere': { // 创建-悬浮球 @@ -97,16 +99,16 @@ export const createWindow = async (type, data) => { } data.isConsole = true // 是否开启控制台 data.option = {...defOption, ...option} - const win = await toolWindow(data) - win.type = type // 唯一标识 - win.show() - win.setFullScreen(true) // 设置窗口为全屏 - win.setIgnoreMouseEvents(true, {forward: true}) // 忽略鼠标事件但是事件继续传递给窗口 - win.setAlwaysOnTop(true,'screen-saver') // 将窗口设置为顶层窗口 - win.setVisibleOnAllWorkspaces(true) // 如果窗口在所有工作区都可见 + wins_tool = await toolWindow(data) + wins_tool.type = type // 唯一标识 + wins_tool.show() + wins_tool.setFullScreen(true) // 设置窗口为全屏 + wins_tool.setIgnoreMouseEvents(true, {forward: true}) // 忽略鼠标事件但是事件继续传递给窗口 + wins_tool.setAlwaysOnTop(true,'screen-saver') // 将窗口设置为顶层窗口 + wins_tool.setVisibleOnAllWorkspaces(true) // 如果窗口在所有工作区都可见 // win.webContents.openDevTools() // 打开调试工具 - eventHandles(type, win) // 事件监听处理 - return win + eventHandles(type, wins_tool) // 事件监听处理 + return wins_tool } case 'open-PDF': { //课本展示-pdf const option = data.option||{} @@ -193,6 +195,7 @@ const eventHandles = (type, win) => { win.on('closed', () => { if(onClosed) onClosed() // 自定义关闭事件 win = null + wins_tool = null }) // 新窗口-创建事件(如:主进程加载远程服务) ipcRenderer.send('new-window', {id:win.id, type}) diff --git a/src/renderer/src/views/classManage/reserv-item.vue b/src/renderer/src/views/classManage/reserv-item.vue index 685d03a..76d2726 100644 --- a/src/renderer/src/views/classManage/reserv-item.vue +++ b/src/renderer/src/views/classManage/reserv-item.vue @@ -68,18 +68,18 @@ const startClassR = (item) => { } }) } -const toolStore = useToolState() +// const toolStore = useToolState() +let wins = null; // 上课-工具类悬浮 const openLesson = () => { - if (toolStore.isToolWin) return ElMessage.error('您当前已开始上课,请勿重复操作') startClass(props.item.id) listEntpcourse({ evalid: props.item.ex2, edituserid: useUserStore().user.userId, pageSize: 500 - }).then(res=>{ + }).then(async res=>{ if (res.rows[0].id) { - createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id }) + wins = await createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id }) } }) } diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 13933d5..b8a21f8 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -596,7 +596,6 @@ export default { // 上课-工具类悬浮 openLesson() { const toolStore = useToolState() - if (toolStore.isToolWin) return this.$message.error('您当前已开始上课,请勿重复操作') startClass(this.curClassReserv.id) createWindow('tool-sphere', { url: