feat: onShow静默刷新 + 群组预算双显 + TransactionItem优化
onShow 静默刷新(首次有loading,后续静默): - budget: 添加 initialLoaded 守卫,避免首次双重请求 - profile: 添加 onShow 刷新概览/预算/账单/群组 - group-manage: 添加 onShow 刷新群组列表 - category-manage: 添加 onShow 刷新分类列表 - add: 添加 onShow 刷新分类(可能新增了分类) 群组模式预算双显: - 服务端 GET /budget 群组模式额外返回 myAmount(本人预算) - 客户端 Budget 类型添加 myAmount 字段 - 预算页群组模式:群组总预算卡片(只读)+ 我的预算卡片(可编辑) - 个人模式保持原样 TransactionItem 群组模式优化: - 主图标始终显示分类图标(不再显示创建者头像) - 他人记录在昵称旁显示小头像(28rpx圆形)
This commit is contained in:
@@ -118,6 +118,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { useTransactionStore } from '@/stores/transaction'
|
||||
import { useStatsStore } from '@/stores/stats'
|
||||
import { useBudgetStore } from '@/stores/budget'
|
||||
@@ -140,6 +141,7 @@ const budget = computed(() => budgetStore.budget)
|
||||
const loading = ref(true)
|
||||
const showAbout = ref(false)
|
||||
const showIdentity = ref(false)
|
||||
const initialLoaded = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
await waitForReady()
|
||||
@@ -156,9 +158,23 @@ onMounted(async () => {
|
||||
console.error('Profile load error:', e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
initialLoaded.value = true
|
||||
}
|
||||
})
|
||||
|
||||
// 返回页面时静默刷新
|
||||
onShow(async () => {
|
||||
if (!initialLoaded.value) return
|
||||
try {
|
||||
await Promise.all([
|
||||
statsStore.fetchOverview(),
|
||||
budgetStore.fetchBudget(),
|
||||
txStore.fetchTransactions({ page: 1, pageSize: 1 }),
|
||||
groupStore.fetchGroups()
|
||||
])
|
||||
} catch {}
|
||||
})
|
||||
|
||||
function goBudget() {
|
||||
uni.navigateTo({ url: '/pages/budget/index' })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user