修复抢购后 UI 状态不刷新
This commit is contained in:
@@ -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++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user