From 03ceb1d226925de8bc8bbef8e79c4e22d445f38d Mon Sep 17 00:00:00 2001 From: wangxk Date: Sun, 27 Apr 2025 09:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=93=A6=E7=89=87=E5=9C=B0=E5=9B=BE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/package.json | 3 ++- web/public/webconfig.js | 1 + web/src/components/trajectory/index.vue | 20 +++++++++++--------- web/src/store/modules/user.ts | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/web/package.json b/web/package.json index 7227256..6697950 100644 --- a/web/package.json +++ b/web/package.json @@ -95,7 +95,8 @@ "husky": "^7.0.4", "postcss": "^8.4.20", "prettier": "^2.6.2", - "sass": "^1.53.0", + "sass": "^1.66.0", + "sass-loader": "^13.3.0", "tailwindcss": "^3.2.4", "typescript": "^4.7.4", "vite": "^4.0.3", diff --git a/web/public/webconfig.js b/web/public/webconfig.js index e20da99..bdd0efe 100644 --- a/web/public/webconfig.js +++ b/web/public/webconfig.js @@ -2,6 +2,7 @@ window.webConfig = { "webApiBaseUrl": "https://edu.mmhyvision.com:8445", "VITEAPPBASEWEB": "https://edu.mmhyvision.com/vision", "webApiBaseApp": "https://edu.mmhyvision.com/parent", + "mapUrl":"http://192.168.1.208", "title": "文档与数据管理系统", "bgImg": "beijing.jpg", diff --git a/web/src/components/trajectory/index.vue b/web/src/components/trajectory/index.vue index f8084da..17e3351 100644 --- a/web/src/components/trajectory/index.vue +++ b/web/src/components/trajectory/index.vue @@ -7,7 +7,9 @@ import { onMounted, watch, nextTick, onUnmounted } from 'vue' import L from 'leaflet' import 'leaflet/dist/leaflet.css' - +import { useUserStore } from '@/store/modules/user'; +const userStore = useUserStore(); +const url = userStore.mapUrl; // 类型定义 interface PointProp { points?: Array<[number, number]>; @@ -53,10 +55,10 @@ function initMap() { * 添加离线瓦片图层 */ function addTileLayer() { - L.tileLayer('/tiles/{z}/{y}/{x}.jpg', { - attribution: 'Offline Map', // 图层属性说明 - tileSize: 256, // 瓦片尺寸 - noWrap: true // 禁止重复瓦片 + L.tileLayer(url+'/{z}/{y}/{x}.jpg', { + attribution: 'Offline Map', + tileSize: 256, + noWrap: true }).addTo(map!) } @@ -94,7 +96,7 @@ function createPolyline(latlngs: L.LatLng[]) { * @returns 标记实例数组 */ function createMarkers(latlngs: L.LatLng[]) { - return latlngs.map(latlng => + return latlngs.map(latlng => L.marker(latlng).addTo(map!) ) } @@ -103,12 +105,12 @@ function createMarkers(latlngs: L.LatLng[]) { * 主绘制函数 * @param points 原始坐标数组 */ - function drawTrajectory(points: Array<[number, number]>) { +function drawTrajectory(points: Array<[number, number]>) { if (!map) return - + // 始终执行清理(无论是否有新坐标) clearLayers() - + // 仅在有有效坐标时创建新元素 if (points?.length > 0) { const latlngs = points.map(convertToLatLng) diff --git a/web/src/store/modules/user.ts b/web/src/store/modules/user.ts index 31b59b4..2064c9d 100644 --- a/web/src/store/modules/user.ts +++ b/web/src/store/modules/user.ts @@ -19,6 +19,7 @@ export const useUserStore = defineStore('user', () => { const badgeval = ref('') const webApiBaseUrl: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_API : window.webConfig.webApiBaseUrl const webApiBaseHttp: any = process.env.NODE_ENV == 'development' ? import.meta.env.VITE_APP_BASE_WEB : window.webConfig.VITEAPPBASEWEB + const mapUrl: any = window.webConfig.mapUrl const webApiBaseApp: any = window.webConfig.webApiBaseApp const title = window.webConfig.title const content1 = window.webConfig.content1 @@ -116,6 +117,7 @@ export const useUserStore = defineStore('user', () => { resetToken, badgeval, webApiBaseUrl, + mapUrl, webApiBaseHttp, webApiBaseApp, title,