修复抢购后 UI 状态不刷新

This commit is contained in:
yml2213
2026-06-26 20:23:06 +08:00
parent 385a6d882c
commit 818e1ff11b
7 changed files with 143 additions and 13 deletions
@@ -8,6 +8,8 @@ defineProps<{
const { accounts, selectedIndices, statusMap } = useAccounts()
const messageSucceeded = (message: string) => /成功|兑换上限|已抢到/.test(message)
const stats = computed(() => {
const selectedNames = [...selectedIndices.value]
.map(i => accounts.value[i]?.name)
@@ -18,9 +20,11 @@ const stats = computed(() => {
for (const name of selectedNames) {
const st = statusMap.value[name]
if (st === true || (st && typeof st === 'object' && (st as any).ok)) {
const msg = st && typeof st === 'object' ? String((st as any).message || '') : ''
if (st === true || (st && typeof st === 'object' && ((st as any).ok || messageSucceeded(msg)))) {
success++
} else if (st === false || (st && typeof st === 'object' && (st as any).message)) {
} else if (st === false || (st && typeof st === 'object' && !(st as any).pending && msg)) {
fail++
}
}