代码优化

This commit is contained in:
kron
2026-01-12 15:03:20 +08:00
parent 4771f53d71
commit a2674aae5b
5 changed files with 62 additions and 66 deletions

View File

@@ -6,7 +6,7 @@ import Header from "@/components/Header.vue";
import ScreenHint from "@/components/ScreenHint.vue";
import BackToGame from "@/components/BackToGame.vue";
import { getCurrentGameAPI, laserAimAPI } from "@/apis";
import { debounce } from "@/util";
import { capsuleHeight, debounce } from "@/util";
import AudioManager from "@/audioManager";
const props = defineProps({
title: {
@@ -49,7 +49,6 @@ const props = defineProps({
const isIOS = uni.getDeviceInfo().osName === "ios";
const showHint = ref(false);
const hintType = ref(0);
const capsuleHeight = ref(0);
const isLoading = ref(false);
const audioInitProgress = ref(1);
const audioProgress = ref(0);
@@ -96,11 +95,6 @@ const audioFinalProgress = computed(() => {
return Math.max(0, (audioProgress.value - audioInitProgress.value) / left);
});
onMounted(() => {
const menuBtnInfo = uni.getMenuButtonBoundingClientRect();
capsuleHeight.value = menuBtnInfo.top - 9;
});
onBeforeUnmount(() => {
if (audioTimer.value) clearInterval(audioTimer.value);
});
@@ -162,7 +156,7 @@ const goCalibration = async () => {
:show-scrollbar="false"
:style="{
height: `calc(100vh - ${capsuleHeight + (isHome ? 0 : 50)}px - ${
$slots.bottom && showBottom ? (isIOS ? '85px' : '65px') : '0px'
$slots.bottom && showBottom ? (isIOS ? '75px' : '65px') : '0px'
})`,
}"
>
@@ -171,7 +165,7 @@ const goCalibration = async () => {
<view
class="bottom-part"
v-if="$slots.bottom && showBottom"
:style="{ height: isIOS ? '75px' : '55px', paddingTop: '10px' }"
:style="{ height: isIOS ? '65px' : '55px', paddingTop: '10px' }"
>
<slot name="bottom"></slot>
</view>