From 16e9746e5da1ac0485fde18e71fb7bf8ee376d42 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 19 Jan 2026 11:38:00 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/jagzwxm/ja_web

---
 uniapps/work-app/src/App.vue |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/uniapps/work-app/src/App.vue b/uniapps/work-app/src/App.vue
index 020fe6c..3240b20 100644
--- a/uniapps/work-app/src/App.vue
+++ b/uniapps/work-app/src/App.vue
@@ -1,19 +1,32 @@
 <script setup>
 import { onHide, onLaunch, onShow } from "@dcloudio/uni-app";
-import { useAppStore, useUserStore } from "@/store";
+import { useAppStore, useUserStore, useLocationStore } from "@/store";
 import { useGlobalWS } from "@/hooks/useGlobalWS.js";
 
 const appStore = useAppStore();
 const userStore = useUserStore();
+const locationStore = useLocationStore();
 
 useGlobalWS();
 
-onShow(() => {
+onShow(async () => {
   console.log("App Show");
+  // 应用从后台返回前台时,重新初始化位置服务
+  if (userStore.userInfo && locationStore) {
+    try {
+      await locationStore.initLocationService();
+    } catch (error) {
+      console.error('重新初始化位置服务失败:', error);
+    }
+  }
 });
 
 onHide(() => {
   console.log("App Hide");
+  // 应用进入后台时,停止位置监听以节省资源
+  if (locationStore) {
+    locationStore.stopLocationWatch();
+  }
 });
 
 onLaunch(() => {

--
Gitblit v1.9.3