2025-11-05 15:59:48 +08:00
|
|
|
|
<script>
|
2026-01-15 15:40:27 +08:00
|
|
|
|
import {
|
|
|
|
|
|
connectWs,
|
|
|
|
|
|
closeWs
|
|
|
|
|
|
} from '@/common/websocketManager.js';
|
2025-12-30 08:40:09 +08:00
|
|
|
|
let globalWs = null;
|
|
|
|
|
|
|
2025-11-05 15:59:48 +08:00
|
|
|
|
export default {
|
2025-12-30 08:40:09 +08:00
|
|
|
|
onLaunch() {
|
2026-01-15 15:40:27 +08:00
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
|
// 检测是否为 Android
|
|
|
|
|
|
if (plus.os.name === 'Android') {
|
|
|
|
|
|
// 隐藏虚拟按键(底部横线)
|
|
|
|
|
|
const mainActivity = plus.android.runtimeMainActivity();
|
|
|
|
|
|
const Window = plus.android.importClass('android.view.Window');
|
|
|
|
|
|
const View = plus.android.importClass('android.view.View');
|
|
|
|
|
|
|
|
|
|
|
|
const window = mainActivity.getWindow();
|
|
|
|
|
|
const decorView = window.getDecorView();
|
|
|
|
|
|
|
|
|
|
|
|
// 隐藏导航栏
|
|
|
|
|
|
const uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
|
|
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
|
|
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
|
|
|
|
|
|
|
|
|
|
plus.android.invoke(decorView, 'setSystemUiVisibility', uiOptions);
|
|
|
|
|
|
|
|
|
|
|
|
// 监听焦点变化,防止导航栏重新显示
|
|
|
|
|
|
decorView.setOnSystemUiVisibilityChangeListener(
|
|
|
|
|
|
new plus.android.implements('OnSystemUiVisibilityChangeListener', {
|
|
|
|
|
|
onSystemUiVisibilityChange: function (visibility) {
|
|
|
|
|
|
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) === 0) {
|
|
|
|
|
|
plus.android.invoke(decorView, 'setSystemUiVisibility', uiOptions);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
// #endif
|
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>
|