| | |
| | | };
|
| | |
|
| | | // 收到消息
|
| | | let isMouseInInputBox = false; // 标记鼠标是否在输入框内
|
| | |
|
| | | const inputBox = document.querySelectorAll('.input-box');
|
| | | inputBox.forEach(box => {
|
| | | box.addEventListener('mouseenter', () => {
|
| | | isMouseInInputBox = true;
|
| | | });
|
| | | box.addEventListener('mouseleave', () => {
|
| | | isMouseInInputBox = false;
|
| | | });
|
| | | });
|
| | |
|
| | | socket.onmessage = (msg) => {
|
| | | if (!msg.data) {
|
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑
|
| | |
| | | // console.log(obj)
|
| | | const jsonData2 = this.jsonData;
|
| | | const weihuiling = obj.weihuiling;
|
| | | const handleMouseMove = (event) => {
|
| | | if (!event || !event.target) {
|
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑
|
| | | }
|
| | |
|
| | | const inputBox = document.querySelectorAll('.input-box');
|
| | | const target = event.target;
|
| | | // console.log(obj);
|
| | | |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
|
| | |
|
| | |
|
| | | if (!isMouseInInput) {
|
| | |
|
| | | if (obj.zuhe1 ) {
|
| | | |
| | | if (obj.zuhe1&& !isMouseInInputBox ) {
|
| | | // 执行更新逻辑
|
| | | for (let i = 0; i < 2; i++) {
|
| | | jsonData2[i].forEach((item, index) => {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | // console.log(jsonData2);
|
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置
|
| | |
|
| | | document.addEventListener('mousemove', event => handleMouseMove(event));
|
| | |
|
| | |
|
| | | if(obj.zuhe1){
|