perf: 优化订阅刷新逻辑
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user