mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
fix(admin): close quota reset modal on success
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -96,6 +96,11 @@ function creditOptionClasses(creditId: string) {
|
||||
function creditOptionLabel(credit: { title: string | null, expiresAt: string | null }) {
|
||||
return `${credit.title || 'Codex 主动重置卡'},${expiryLabel(credit.expiresAt)}`
|
||||
}
|
||||
|
||||
async function handleConfirmConsume() {
|
||||
if (await confirmConsume())
|
||||
panelOpen.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -254,7 +259,7 @@ function creditOptionLabel(credit: { title: string | null, expiresAt: string | n
|
||||
<BaseButton variant="ghost" :disabled="consuming" @click="cancelConsume">
|
||||
返回
|
||||
</BaseButton>
|
||||
<BaseButton variant="primary" :loading="consuming" @click="confirmConsume">
|
||||
<BaseButton variant="primary" :loading="consuming" @click="handleConfirmConsume">
|
||||
{{ ambiguous ? '再次确认' : '确认重置' }}
|
||||
</BaseButton>
|
||||
</template>
|
||||
|
||||
@@ -160,10 +160,10 @@ export function useAccountResetCredits(options: {
|
||||
pendingOperation.value = null
|
||||
}
|
||||
|
||||
async function confirmConsume() {
|
||||
async function confirmConsume(): Promise<boolean> {
|
||||
const operation = pendingOperation.value
|
||||
if (!operation || consuming.value)
|
||||
return
|
||||
return false
|
||||
|
||||
consuming.value = true
|
||||
try {
|
||||
@@ -179,7 +179,7 @@ export function useAccountResetCredits(options: {
|
||||
if (!confirmed) {
|
||||
toast.error(resetResultMessage(result.code))
|
||||
await loadCredits()
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
const successMessage = result.code === 'already_redeemed'
|
||||
@@ -199,6 +199,7 @@ export function useAccountResetCredits(options: {
|
||||
{ duration: 5000 },
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
catch (error: unknown) {
|
||||
showConfirm.value = false
|
||||
@@ -214,6 +215,7 @@ export function useAccountResetCredits(options: {
|
||||
toast.error(errorMessage(error, '额度重置失败'))
|
||||
await loadCredits()
|
||||
}
|
||||
return false
|
||||
}
|
||||
finally {
|
||||
consuming.value = false
|
||||
|
||||
Reference in New Issue
Block a user