From 6fb170c475c2a18e41c795ce91ab10525ae1309b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Wed, 10 Sep 2025 14:21:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/index.vue | 34 +++++++++++++++++++++++++++++++--- vite.config.js | 2 +- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index 3711e35..6e8b070 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -629,6 +629,29 @@ onMounted(() => { ad() getOption() getShildTableList() + points.value = localStorage.getItem('points') ? JSON.parse(localStorage.getItem('points')) : [ + { + lon: 120.38532472236, + lat: 36.14505053622, + name: '点位1', + }, + { + lon: 120.38532472236, + lat: 36.15302618219, + name: '点位2', + }, + { + lon: 120.39109582218, + lat: 36.15302618219, + name: '点位3', + }, + { + lon: 120.39109582218, + lat: 36.14505053622, + name: '点位4', + }, + ] + getArea() }) const getOption = () => { @@ -707,7 +730,7 @@ const ad = () => { // 1. 创建 WebSocket 连接(ws:// 或 wss://) // const socket = new WebSocket("ws://192.168.1.123:7789/ws"); - const socket = new WebSocket("ws://localhost:7789/ws"); + const socket = new WebSocket("ws://172.20.10.5:7789/ws"); // 2. 连接成功时触发 socket.addEventListener("open", () => { @@ -747,7 +770,8 @@ const getPoint = (k) => { points.value[k].lon = currentPosition.value.lon points.value[k].lat = currentPosition.value.lat } -const savePoint = () => { +const getArea = () => { + if (points.value.length < 4) return let data = points.value let latMin = data[0].lat; @@ -769,10 +793,14 @@ const savePoint = () => { LonMax: lonMax, } } +const savePoint = () => { + localStorage.setItem('points', JSON.stringify(points.value)) + getArea() +}