修复抢购后 UI 状态不刷新
This commit is contained in:
@@ -39,8 +39,14 @@ const getStatusInfo = (name: string, selected: boolean) => {
|
||||
|
||||
if (st && typeof st === 'object') {
|
||||
const obj = st as any
|
||||
if (obj.ok) return { text: '成功', cls: 'status-success' }
|
||||
const msg = String(obj.message || '')
|
||||
if (obj.pending) {
|
||||
return {
|
||||
text: msg.includes('定时') ? '待触发' : '抢购中',
|
||||
cls: 'status-ready'
|
||||
}
|
||||
}
|
||||
if (obj.ok) return { text: '成功', cls: 'status-success' }
|
||||
if (msg.includes('库存已耗完')) return { text: '库存耗尽', cls: 'status-warn' }
|
||||
if (msg.includes('兑换上限') || msg.includes('已抢到')) return { text: '已抢到', cls: 'status-success' }
|
||||
if (msg.includes('未绑定')) return { text: '未绑定', cls: 'status-fail' }
|
||||
|
||||
@@ -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++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,14 @@ const openSettings = () => {
|
||||
CK 管理
|
||||
</button>
|
||||
</div>
|
||||
<span
|
||||
v-if="currentPage === 'console'"
|
||||
class="run-state"
|
||||
:class="{ active: runState !== '等待操作' }"
|
||||
:title="runState"
|
||||
>
|
||||
{{ runState }}
|
||||
</span>
|
||||
<span v-if="countdownSeconds > 0 && currentPage === 'console'" class="countdown-badge">
|
||||
{{ formatRemain(countdownSeconds) }}
|
||||
</span>
|
||||
@@ -158,6 +166,26 @@ const openSettings = () => {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.run-state {
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--muted);
|
||||
background: var(--surface-2);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.run-state.active {
|
||||
color: var(--accent);
|
||||
background: var(--accent-soft);
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
|
||||
.top-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -12,6 +12,8 @@ const { showToast } = useToast()
|
||||
const activeTab = ref<'log' | 'result' | 'stats' | 'verify'>('log')
|
||||
const logBodyRef = ref<HTMLElement | null>(null)
|
||||
|
||||
const messageSucceeded = (message: string) => /成功|兑换上限|已抢到/.test(message)
|
||||
|
||||
// 自动滚动到底部
|
||||
watch(logs, async () => {
|
||||
await nextTick()
|
||||
@@ -31,9 +33,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