mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
feat(admin/accounts): confirm before OpenAI weekly limit reset
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
class="inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium text-orange-600 transition-colors hover:bg-orange-50 disabled:cursor-not-allowed disabled:opacity-50 dark:text-orange-400 dark:hover:bg-orange-900/30"
|
class="inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium text-orange-600 transition-colors hover:bg-orange-50 disabled:cursor-not-allowed disabled:opacity-50 dark:text-orange-400 dark:hover:bg-orange-900/30"
|
||||||
:disabled="resetting || loading || !canReset"
|
:disabled="resetting || loading || !canReset"
|
||||||
:title="resetButtonTitle"
|
:title="resetButtonTitle"
|
||||||
@click="handleReset"
|
@click="openResetConfirm"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class="h-2.5 w-2.5"
|
class="h-2.5 w-2.5"
|
||||||
@@ -77,6 +77,17 @@
|
|||||||
>
|
>
|
||||||
{{ resetMessage }}
|
{{ resetMessage }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ConfirmDialog
|
||||||
|
:show="showResetConfirm"
|
||||||
|
:title="t('admin.accounts.openaiQuotaReset.confirmTitle')"
|
||||||
|
:message="t('admin.accounts.openaiQuotaReset.confirmMessage', { count: availableResetCount })"
|
||||||
|
:confirm-text="t('admin.accounts.openaiQuotaReset.reset')"
|
||||||
|
:cancel-text="t('common.cancel')"
|
||||||
|
danger
|
||||||
|
@confirm="confirmReset"
|
||||||
|
@cancel="showResetConfirm = false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -90,6 +101,7 @@ import {
|
|||||||
type OpenAIQuotaUsage,
|
type OpenAIQuotaUsage,
|
||||||
type OpenAIQuotaResetResult
|
type OpenAIQuotaResetResult
|
||||||
} from '@/api/admin/accounts'
|
} from '@/api/admin/accounts'
|
||||||
|
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
account: Account
|
account: Account
|
||||||
@@ -105,6 +117,7 @@ const resetting = ref(false)
|
|||||||
const error = ref<string | null>(null)
|
const error = ref<string | null>(null)
|
||||||
const data = ref<OpenAIQuotaUsage | null>(null)
|
const data = ref<OpenAIQuotaUsage | null>(null)
|
||||||
const resetMessage = ref<string | null>(null)
|
const resetMessage = ref<string | null>(null)
|
||||||
|
const showResetConfirm = ref(false)
|
||||||
|
|
||||||
const availableResetCount = computed(() => data.value?.rate_limit_reset_credits?.available_count ?? 0)
|
const availableResetCount = computed(() => data.value?.rate_limit_reset_credits?.available_count ?? 0)
|
||||||
const canReset = computed(() => availableResetCount.value > 0)
|
const canReset = computed(() => availableResetCount.value > 0)
|
||||||
@@ -161,7 +174,17 @@ const handleQuery = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleReset = async () => {
|
const openResetConfirm = () => {
|
||||||
|
if (resetting.value || loading.value) return
|
||||||
|
if (!canReset.value) {
|
||||||
|
error.value = t('admin.accounts.openaiQuotaReset.noCreditsAvailable')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
showResetConfirm.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmReset = async () => {
|
||||||
|
showResetConfirm.value = false
|
||||||
if (resetting.value) return
|
if (resetting.value) return
|
||||||
if (!canReset.value) {
|
if (!canReset.value) {
|
||||||
error.value = t('admin.accounts.openaiQuotaReset.noCreditsAvailable')
|
error.value = t('admin.accounts.openaiQuotaReset.noCreditsAvailable')
|
||||||
@@ -195,6 +218,7 @@ watch(
|
|||||||
resetMessage.value = null
|
resetMessage.value = null
|
||||||
loading.value = false
|
loading.value = false
|
||||||
resetting.value = false
|
resetting.value = false
|
||||||
|
showResetConfirm.value = false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4126,7 +4126,9 @@ export default {
|
|||||||
resetTooltipNeedQuery: 'Click Credits first to load the available count',
|
resetTooltipNeedQuery: 'Click Credits first to load the available count',
|
||||||
resetTooltipNoCredits: 'No reset credits available',
|
resetTooltipNoCredits: 'No reset credits available',
|
||||||
noCreditsAvailable: 'No reset credits available',
|
noCreditsAvailable: 'No reset credits available',
|
||||||
resetSuccess: 'Reset {windows} window(s)'
|
resetSuccess: 'Reset {windows} window(s)',
|
||||||
|
confirmTitle: 'Confirm Weekly Limit Reset',
|
||||||
|
confirmMessage: 'This will consume 1 reset credit to immediately restore the current window ({count} remaining). This action cannot be undone. Continue?'
|
||||||
},
|
},
|
||||||
tier: {
|
tier: {
|
||||||
free: 'Free',
|
free: 'Free',
|
||||||
|
|||||||
@@ -3414,7 +3414,9 @@ export default {
|
|||||||
resetTooltipNeedQuery: '先点击「次数」加载剩余重置次数',
|
resetTooltipNeedQuery: '先点击「次数」加载剩余重置次数',
|
||||||
resetTooltipNoCredits: '没有可用的重置次数',
|
resetTooltipNoCredits: '没有可用的重置次数',
|
||||||
noCreditsAvailable: '没有可用的重置次数',
|
noCreditsAvailable: '没有可用的重置次数',
|
||||||
resetSuccess: '已重置 {windows} 个窗口'
|
resetSuccess: '已重置 {windows} 个窗口',
|
||||||
|
confirmTitle: '确认重置周限',
|
||||||
|
confirmMessage: '将消耗 1 次重置次数立即恢复当前窗口,剩余 {count} 次。此操作不可撤销,确定继续吗?'
|
||||||
},
|
},
|
||||||
tier: {
|
tier: {
|
||||||
free: 'Free',
|
free: 'Free',
|
||||||
|
|||||||
Reference in New Issue
Block a user