From 43afd575deced75d4b51185745445a4a2f132aa0 Mon Sep 17 00:00:00 2001 From: zdg Date: Wed, 7 Aug 2024 16:52:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8B=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/utils/tool.js | 12 +++-- .../src/views/tool/components/side.vue | 16 +++--- .../src/views/tool/directive/ignore.js | 3 +- src/renderer/src/views/tool/sphere.vue | 52 ++++++++++++++----- 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index 09a1fb1..87ee641 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -58,6 +58,12 @@ export function ipcMsgSend(key, data, type) { return ipcRenderer?.invoke(key, data) } } +export function ipcMsgSend2(key, ...args) { + return ipcRenderer?.send(key, ...args) +} +export function ipcMsgInvoke(key, ...args) { + return ipcRenderer?.invoke(key, ...args) +} /** * @description 封装ipcRenderer事件监听 * @param {*} fn on once handle invoke @@ -197,9 +203,9 @@ const eventHandles = (type, win) => { const setIgnore = (_, ignore) => {win.setIgnoreMouseEvents(ignore, {forward: true})} Remote.ipcMain.handle('tool-sphere:set:ignore', setIgnore) // 异步 // 关闭窗口 - Remote.ipcMain.once('tool-sphere:close', () => { win&&win.destroy() }) - // 放大监听-测试 - Remote.ipcMain.once('maximize-window', () => {win&&win.destroy()}) + Remote.ipcMain.handleOnce('tool-sphere:close', () => {win&&win.destroy()}) + // // 放大监听-测试 + // Remote.ipcMain.once('maximize-window', () => {win&&win.destroy()}) const on = { onClosed: () => { Remote.ipcMain.removeHandler('tool-sphere:set:ignore', setIgnore) diff --git a/src/renderer/src/views/tool/components/side.vue b/src/renderer/src/views/tool/components/side.vue index 63b766e..184518e 100644 --- a/src/renderer/src/views/tool/components/side.vue +++ b/src/renderer/src/views/tool/components/side.vue @@ -38,7 +38,7 @@ const props = defineProps({ { label: '资源', prop: 'resource', icon: 'icon-hudong' }, { label: '互动', prop: 'interact', icon: 'icon-hudong' }, { label: '窗口', prop: 'win', icon: 'icon-hudong' }, - { label: '下课', prop: 'over', icon: 'icon-hudong' }, + { label: '下课', prop: 'over', isExtra: true, icon: 'icon-hudong' }, ] } }) @@ -71,12 +71,14 @@ const getStyle = (style,index) => { } // 事件 const clickHandel = (o, e) => { - const node = e.target.parentNode.getBoundingClientRect() - const isColse = activeObj.value && activeObj.value.prop === o.prop && isVisible.value - isVisible.value = !isColse // 相同的按钮且打开状态,点击关闭 - activeObj.value = o - const nodeH = parseInt(node.height / 2) // 高度的一半 - topPos.value = parseInt(node.top) - posBtnAll.top + nodeH + if (!o.isExtra) { // 忽略其他操作: 打开内容窗口,指示器指向当前 + const node = e.target.parentNode.getBoundingClientRect() + const isColse = activeObj.value && activeObj.value.prop === o.prop && isVisible.value + isVisible.value = !isColse // 相同的按钮且打开状态,点击关闭 + activeObj.value = o + const nodeH = parseInt(node.height / 2) // 高度的一半 + topPos.value = parseInt(node.top) - posBtnAll.top + nodeH + } emit('change', o) } diff --git a/src/renderer/src/views/tool/directive/ignore.js b/src/renderer/src/views/tool/directive/ignore.js index 63a3ca3..b7e3e26 100644 --- a/src/renderer/src/views/tool/directive/ignore.js +++ b/src/renderer/src/views/tool/directive/ignore.js @@ -29,7 +29,8 @@ class Ignore { }) } changeHandle(e) { - const customEvent = new CustomEvent('ignore-mounted', {detail:{ignore: this, e}}) + const data = {detail:{ignore: this, e, type: e.type}} + const customEvent = new CustomEvent('ignore-mounted', data) this.el.dispatchEvent(customEvent) } } diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 9559937..fb63263 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -3,7 +3,7 @@ - +
{ resetStatus() // 开启重置状态-监听 }) -// const test = (e) => { console.log('test', e) } + + // ==== 方法 === -const tabChange = (val) => { // 切换tab-change +// const test = (e) => { console.log('test', e) } +// 切换tab-change +const tabChange = (val) => { const bool = !toolStore.isPdfWin && !toolStore.showBoardAll if(bool) toolStore.showBoardAll = true // ipcMsgSend('tool-sphere:close') toolStore.model = val // 存储当前tab } -const logoHandle = (e,t) => { // logo 点击-事件 折叠|展开 +// logo 点击-事件 折叠|展开 +const logoHandle = (e,t) => { if (Date.now() - dragtime.value < 200) { isFold.value = !isFold.value } } -const mouseChange = (bool) => { // 鼠标移入工具栏 是否穿透 +// 底部工具栏:移入移出-是否穿透 +const mouseChange = (bool) => { let resBool = false if (tabActive.value == 'select') resBool = !!bool if (!isShow.value) resBool = !!bool setIgnore(resBool) } -const setIgnore = (bool) => { // 忽略鼠标穿透 - ipcMsgSend('tool-sphere:set:ignore', bool) -} -const resetStatus = () => { // 重置状态 +// 忽略鼠标穿透 +const setIgnore = (bool) => {ipcMsgSend('tool-sphere:set:ignore', bool)} +// 重置状态: 鼠标|画板 +const resetStatus = () => { if (toolStore.isToolWin) return // 已经打开过-忽略 ipcMain?.handle?.('tool-sphere:reset', () => { setTimeout(() => { boardVueRef.value.handleMode(tabActive.value) - mouseChange(1) + mouseChange(1) }, 500) }) toolStore.isToolWin = true // 标记状态 } +// 侧边工具栏: 移入移出 +const sideMouse = e => { + const {type} = e.detail + mouseChange(type == 'mouseleave') +} +// 侧边工具栏: 操作变化 +const sideChange = o => { + // console.log(o) + switch(o.prop) { + case 'resource': // 资源 + break + case 'interact': // 互动 + break + case 'win': // 窗口 + break + case 'over': // 下课 + ipcMsgSend('tool-sphere:close') + break + } +} -watchEffect(() => { // 监听 +// === 监听器 === +watchEffect(() => { // 不同的时候, 更新值: 是否显示-画板 const show = !toolStore.isPdfWin && toolStore.showBoardAll if (show != isShow.value) isShow.value = show -- 2.44.0.windows.1 From 618618f736dfe01555275925a79e7b500051d2a1 Mon Sep 17 00:00:00 2001 From: zdg Date: Wed, 7 Aug 2024 17:04:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B7=A5=E5=85=B7-=E4=B8=8B=E8=AF=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/views/tool/sphere.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index fb63263..834b317 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -110,6 +110,7 @@ const sideChange = o => { case 'win': // 窗口 break case 'over': // 下课 + toolStore.isToolWin = false ipcMsgSend('tool-sphere:close') break } -- 2.44.0.windows.1