优化返回游戏的数据更新

This commit is contained in:
kron
2025-07-23 11:18:47 +08:00
parent b87ccbb7b0
commit be4619ee24
8 changed files with 94 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, onUnmounted } from "vue";
const isIos = ref(true);
const props = defineProps({
@@ -18,9 +18,28 @@ const onClick = () => {
else uni.navigateBack();
};
const loading = ref(false);
const showLoader = ref(false);
const updateLoading = (value) => {
loading.value = value;
};
onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (
currentPage.route === "pages/battle-room" ||
currentPage.route === "pages/team-match" ||
currentPage.route === "pages/melee-match"
) {
showLoader.value = true;
}
uni.$on("update-header-loading", updateLoading);
});
onUnmounted(() => {
uni.$off("update-header-loading", updateLoading);
});
</script>
@@ -58,6 +77,12 @@ onMounted(() => {
</view>
</block>
</view>
<image
:style="{ opacity: showLoader && loading ? 1 : 0 }"
src="../static/btn-loading.png"
mode="widthFix"
class="loading"
/>
</view>
</template>
@@ -100,4 +125,12 @@ onMounted(() => {
font-size: 16px;
color: #fff;
}
.loading {
width: 20px;
height: 20px;
margin-left: 10px;
transition: all 0.3s ease;
background-blend-mode: darken;
animation: rotate 2s linear infinite;
}
</style>

View File

@@ -117,7 +117,7 @@ watch(
const updateRemain = (value) => {
if (timer.value) clearInterval(timer.value);
remain.value = Math.floor(value);
remain.value = Math.round(value);
if (remain.value > 0) {
timer.value = setInterval(() => {
if (remain.value > 0) remain.value--;

View File

@@ -70,7 +70,7 @@ onUnmounted(() => {
.container > view:last-child > text:nth-child(2) {
color: #fed847;
font-size: 16px;
width: 16px;
width: 18px;
text-align: center;
}
</style>