吉安感知网项目-前端
罗广辉
2026-02-09 53d98f546cd75d9a54a99a9faf6456cdefd0d755
uniapps/work-app/src/App.vue
@@ -4,6 +4,7 @@
import { useGlobalWS } from '@/hooks/useGlobalWS.js'
// #ifdef APP-PLUS
import { keepAliveStart, requestIgnoreBatteryOptimization } from '@/uni_modules/keep-app'
import { openDialog,closeDialog } from '@/uni_modules/lgh-dialog'
// #endif
const appStore = useAppStore()
@@ -15,14 +16,29 @@
// console.log('电池电量:', getBatteryCapacity())
// #endif
const valuetest = ref(1)
const currentKey = ref(1)
function tests() {
   setInterval(() => {
      valuetest.value = valuetest.value + 1
      console.log('valuetest.value:', valuetest.value)
      uni.showToast({ title: valuetest.value, icon: 'none' })
      currentKey.value = currentKey.value + 1
      const val = '保活服务验证:' + currentKey.value
      console.log(val)
      uni.showToast({ title: val, icon: 'none' })
   }, 1000)
}
function popUpInterface() {
  uni.showToast({ title: '弹框', icon: 'none' })
   openDialog()
}
setTimeout(() => {
   popUpInterface()
},10000)
setTimeout(() => {
   closeDialog()
},20000)
tests()
useGlobalWS()
@@ -52,9 +68,7 @@
   // #ifdef APP-PLUS
   keepAliveStart()
   // 请求用户允许忽略电池优化(重要:用于保活)
   setTimeout(() => {
      requestIgnoreBatteryOptimization()
   }, 2000)
   setTimeout(requestIgnoreBatteryOptimization, 2000)
   // #endif
   if (!userStore.userInfo) {
      //不存在则跳转至登录页