diff --git a/src/components/Header.vue b/src/components/Header.vue
index 6950948..a1692c5 100644
--- a/src/components/Header.vue
+++ b/src/components/Header.vue
@@ -59,6 +59,8 @@ const loading = ref(false);
const pointBook = ref(null);
const showProgress = ref(false);
const heat = ref(0);
+/** 房间号按钮动态定位样式(position: fixed,根据胶囊真实位置计算,脱离 flex 流避免挤压标题) */
+const battleRoomBtnStyle = ref({});
const updateLoading = (value) => {
loading.value = value;
@@ -83,6 +85,23 @@ onMounted(() => {
if (currentPage.route === "pages/team-battle") {
showProgress.value = true;
}
+ // 仅在对战房间页获取胶囊位置,按钮用 fixed 定位精确贴靠胶囊左侧(脱离 flex 流,不挤压标题)
+ if (currentPage.route === "pages/battle-room") {
+ try {
+ const menuButtonRect = uni.getMenuButtonBoundingClientRect();
+ const { windowWidth } = uni.getSystemInfoSync();
+ battleRoomBtnStyle.value = {
+ // 按钮右边缘距视口右侧 = 屏幕宽 - 胶囊左边缘 + 4px 安全间隙
+ right: (windowWidth - menuButtonRect.left + 4) + "px",
+ // 垂直位置与胶囊顶部对齐
+ top: menuButtonRect.top + "px",
+ // 高度与胶囊一致,视觉融合
+ height: menuButtonRect.height + "px",
+ };
+ } catch (e) {
+ // 获取失败时使用 CSS 兜底定位(28vw + 4px 作为 right,8px 作为 top)
+ }
+ }
uni.$on("update-hot", updateHot);
});
onBeforeUnmount(() => {
@@ -173,12 +192,13 @@ onBeforeUnmount(() => {
-
+