2025-11-05 15:59:48 +08:00
|
|
|
|
<script>
|
2025-12-30 08:40:09 +08:00
|
|
|
|
import { connectWs, closeWs } from '@/common/websocketManager.js';
|
|
|
|
|
|
let globalWs = null;
|
|
|
|
|
|
|
2025-11-05 15:59:48 +08:00
|
|
|
|
export default {
|
2025-12-30 08:40:09 +08:00
|
|
|
|
onLaunch() {
|
|
|
|
|
|
console.log('App Launch');
|
2026-01-06 11:06:16 +08:00
|
|
|
|
|
2025-11-05 15:59:48 +08:00
|
|
|
|
},
|
2025-12-30 08:40:09 +08:00
|
|
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
|
|
console.log('App Show');
|
|
|
|
|
|
if (uni.getStorageSync('userInfo')) {
|
|
|
|
|
|
// 重置重连计数,确保立即重连
|
|
|
|
|
|
connectWs()
|
|
|
|
|
|
}
|
2025-11-05 15:59:48 +08:00
|
|
|
|
},
|
2025-12-30 08:40:09 +08:00
|
|
|
|
|
|
|
|
|
|
onHide() {
|
|
|
|
|
|
console.log('App Hide');
|
|
|
|
|
|
if (uni.getStorageSync('userInfo')) {
|
|
|
|
|
|
// 可选择关闭 socket,或只是停止心跳
|
|
|
|
|
|
closeWs()
|
|
|
|
|
|
}
|
2025-11-05 15:59:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
@import "./uni_modules/vk-uview-ui/index.scss";
|
2025-12-30 08:40:09 +08:00
|
|
|
|
/* 每个页面公共css */
|
|
|
|
|
|
</style>
|