吉安感知网项目-前端
罗广辉
2026-08-13 1d552a3bad95caae4af15322df28e6240b797693
uniapps/work-app/src/App.vue
@@ -3,8 +3,8 @@
import { useAppStore, useUserStore, useLocationStore } from '@/store'
import { useGlobalWS } from '@/hooks/useGlobalWS.js'
// #ifdef APP-PLUS
import { keepAliveStart, requestIgnoreBatteryOptimization } from '@/uni_modules/keep-app'
import { openDialog, allowFloat, getBatteryCapacity } from '@/uni_modules/lgh-dialog'
import { keepAliveStart, requestIgnoreBatteryOptimization, isIgnoringBatteryOptimizations } from '@/uni_modules/keep-app'
import { openDialog, allowFloat, getBatteryCapacity, allowBackgroundPopup, allowLockScreen } from '@/uni_modules/lgh-dialog'
// #endif
const appStore = useAppStore()
@@ -22,10 +22,6 @@
//    }, 1000)
// }
// testKeep()
// 开启悬浮窗
// allowFloat()
// 假设五秒后来电
// #endif
useGlobalWS()
@@ -50,14 +46,26 @@
   }
})
function setKeepFun() {
   // #ifdef APP-PLUS
   keepAliveStart()
   //显示悬浮窗权限
   setTimeout(allowFloat, 5000)
   // 请求用户允许忽略电池优化(重要:用于保活)
   setTimeout(requestIgnoreBatteryOptimization, 10000)
   // 引导用户开启「后台弹出界面」权限
   setTimeout(allowBackgroundPopup, 15000)
   //  引导用户开启「锁屏显示」权限
   setTimeout(allowLockScreen, 20000)
   // #endif
}
onLaunch(() => {
   // 初始化系统信息
   appStore.initSystemInfo()
   // #ifdef APP-PLUS
   // keepAliveStart()
   // 请求用户允许忽略电池优化(重要:用于保活)
   // setTimeout(requestIgnoreBatteryOptimization, 2000)
   // #endif
   setKeepFun()
   if (!userStore.userInfo) {
      //不存在则跳转至登录页
      uni.reLaunch({