mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-28 00:07:33 +00:00
Merge pull request #3533 from Pluviobyte/codex/fix-api-key-unlimited-quota
fix(keys): reactivate exhausted keys set to unlimited
This commit is contained in:
@@ -1068,7 +1068,7 @@ import TablePageLayout from '@/components/layout/TablePageLayout.vue'
|
||||
import EndpointPopover from '@/components/keys/EndpointPopover.vue'
|
||||
import GroupBadge from '@/components/common/GroupBadge.vue'
|
||||
import GroupOptionItem from '@/components/common/GroupOptionItem.vue'
|
||||
import type { ApiKey, Group, PublicSettings, SubscriptionType, GroupPlatform } from '@/types'
|
||||
import type { ApiKey, Group, PublicSettings, SubscriptionType, GroupPlatform, UpdateApiKeyRequest } from '@/types'
|
||||
import type { Column } from '@/components/common/types'
|
||||
import type { BatchApiKeyUsageStats } from '@/api/usage'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
@@ -1211,6 +1211,13 @@ const statusOptions = computed(() => [
|
||||
{ value: 'inactive', label: t('common.inactive') }
|
||||
])
|
||||
|
||||
const shouldSubmitEditStatus = (key: ApiKey, status: 'active' | 'inactive') => {
|
||||
if (key.status === 'quota_exhausted' || key.status === 'expired') {
|
||||
return status === 'active'
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Filter dropdown options
|
||||
const groupFilterOptions = computed(() => [
|
||||
{ value: '', label: t('keys.allGroups') },
|
||||
@@ -1542,10 +1549,9 @@ const handleSubmit = async () => {
|
||||
submitting.value = true
|
||||
try {
|
||||
if (showEditModal.value && selectedKey.value) {
|
||||
await keysAPI.update(selectedKey.value.id, {
|
||||
const updates: UpdateApiKeyRequest = {
|
||||
name: formData.value.name,
|
||||
group_id: formData.value.group_id,
|
||||
status: formData.value.status,
|
||||
ip_whitelist: ipWhitelist,
|
||||
ip_blacklist: ipBlacklist,
|
||||
quota: quota,
|
||||
@@ -1553,7 +1559,11 @@ const handleSubmit = async () => {
|
||||
rate_limit_5h: rateLimitData.rate_limit_5h,
|
||||
rate_limit_1d: rateLimitData.rate_limit_1d,
|
||||
rate_limit_7d: rateLimitData.rate_limit_7d,
|
||||
})
|
||||
}
|
||||
if (shouldSubmitEditStatus(selectedKey.value, formData.value.status)) {
|
||||
updates.status = formData.value.status
|
||||
}
|
||||
await keysAPI.update(selectedKey.value.id, updates)
|
||||
appStore.showSuccess(t('keys.keyUpdatedSuccess'))
|
||||
} else {
|
||||
const customKey = formData.value.use_custom_key ? formData.value.custom_key : undefined
|
||||
|
||||
Reference in New Issue
Block a user