perf: 优化订阅刷新逻辑

This commit is contained in:
richarjiang
2026-09-07 14:06:19 +08:00
parent 88cd8419c8
commit f5c7b7eaac
27 changed files with 3248 additions and 1060 deletions

View File

@@ -163,6 +163,7 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import type { BookingWithDetails } from '@mp-pilates/shared'
import { BookingStatus } from '@mp-pilates/shared'
import { useBookingStore } from '../../stores/booking'
@@ -295,6 +296,8 @@ function formatDateDisplay(dateStr: string): string {
}
// ─── Actions ──────────────────────────────────────────────
const hasLoadedOnce = ref(false)
function selectTab(key: TabKey) {
activeTab.value = key
}
@@ -351,7 +354,19 @@ onMounted(() => {
const windowInfo = uni.getWindowInfo()
const statusBarH = windowInfo.statusBarHeight ?? 20
navBarHeight.value = `${statusBarH + Math.round(88 * windowInfo.windowWidth / 750)}px`
bookingStore.fetchMyBookings()
bookingStore.fetchMyBookings().then(() => {
hasLoadedOnce.value = true
})
})
// After returning from booking detail (where status may have changed),
// silently re-sync without flipping loading state — keeps the list visible
// and avoids the skeleton flash. Store action `replaceBooking` already
// keeps `myBookings` in sync for the common case; this is the safety net
// for any state we didn't locally patch (e.g. server-side cascading fields).
onShow(() => {
if (!hasLoadedOnce.value) return
bookingStore.fetchMyBookings(undefined, { silent: true })
})
</script>