| | |
| | | }; |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | 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; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = (event) => { |
| | | if (!event || !event.target) { |
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | const inputBox = document.querySelectorAll('.input-box'); |
| | | const target = event.target; |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target)); |
| | | |
| | | if (!isMouseInInput) { |
| | | const parms = obj.params; |
| | | const parms = obj.params; |
| | | const fanzhuan = obj.fanzhuan; |
| | | const xiaoche = obj.xiaoche; |
| | | const dache = obj.dache1; |
| | |
| | | const parms2 = obj.params2; |
| | | const fanzhuan2 = obj.fanzhuan2; |
| | | const xiaoche2 = obj.xiaoche2; |
| | | |
| | | if(parms && !isMouseInInputBox){ |
| | | |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length - 1; i++) { |
| | |
| | | |
| | | let index2 = 0; |
| | | for (let i = 5; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | let arr2 = jsonData2[i]; |
| | | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | for (let j = 0; j < arr2.length; j++) { |
| | | let obj2 = arr2[j]; |
| | | if (obj2.type === '0' && Object.prototype.hasOwnProperty.call(obj2, 'value')) { |
| | | if (Array.isArray(parms2) && Array.isArray(parms2[0]) && parms2[0][index2] !== undefined) { |
| | | obj2.value = parms2[0][index2]; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) { |
| | | if (Array.isArray(parms) && Array.isArray(parms[0]) && parms[0][index] !== undefined) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (Array.isArray(fanzhuan2) && Array.isArray(fanzhuan2[0]) && fanzhuan2[0][0] !== undefined) { |
| | | jsonData2[8][0]['value'] = fanzhuan2[0][0]; |
| | | } |
| | | |
| | | if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) { |
| | | jsonData2[9][0]['value'] = xiaoche2[0][0]; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置 |
| | | |
| | | document.addEventListener('mousemove', event => handleMouseMove(event)); |
| | | }; |
| | | |
| | | |