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() +}