From 9cc36560506cdbb3428aceefe1aaeb1ece7b6f49 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 17 Jan 2026 17:47:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
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