From 9a6f37528c119f25285e2846a8910b1e626b44c6 Mon Sep 17 00:00:00 2001 From: lyc Date: Tue, 6 Aug 2024 15:02:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/select-subject/index.vue | 26 ++++++++++++++++--- src/renderer/src/views/login/index.vue | 5 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/components/select-subject/index.vue b/src/renderer/src/components/select-subject/index.vue index 9071092..bec856c 100644 --- a/src/renderer/src/components/select-subject/index.vue +++ b/src/renderer/src/components/select-subject/index.vue @@ -23,7 +23,7 @@ + \ No newline at end of file diff --git a/src/renderer/src/views/tool/directive/ignore.js b/src/renderer/src/views/tool/directive/ignore.js new file mode 100644 index 0000000..449a658 --- /dev/null +++ b/src/renderer/src/views/tool/directive/ignore.js @@ -0,0 +1,39 @@ +/** + * 处理元素是否穿透-窗口 + */ +import { ipcMsgSend } from '@/utils/tool' +class Ignore { + el // 绑定元素 + binding // 绑定对象(参数) + value // 绑定值 + isAuto // 是否自动控制 + constructor(el, binding) { + this.el = el + this.binding = binding + this.value = binding.value + this.isAuto = !(this.value && this.value instanceof Boolean) + } + // 设置是否穿透 + send(bool) { + ipcMsgSend('tool-sphere:set:ignore', bool) + } + // 监听元素移入移出,自动设置 + mounted() { + this.el.addEventListener('mouseenter', () => { // 进入 + this.send(false) // 元素不穿透,鼠标有效 + }) + this.el.addEventListener('mouseleave', () => { // 离开 + this.send(true) // 元素穿透,鼠标无效 + }) + } +} +export default { + mounted(el, binding) { + const ignore = new Ignore(el, binding) + if (ignore.isAuto) { // 自动控制 + ignore.mounted() + } else { // 手动设置 + ignore.send(ignore.value) + } + } +} \ No newline at end of file diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 546067c..c6b9b9f 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -1,9 +1,11 @@