feat(subscription): 支持恢复已撤销订阅

This commit is contained in:
deqiying
2026-07-01 22:19:21 +08:00
parent 7dc7cfce1d
commit b26dcc3da2
17 changed files with 382 additions and 19 deletions
@@ -404,6 +404,14 @@
<Icon name="ban" size="sm" />
<span class="text-xs">{{ t('admin.subscriptions.revoke') }}</span>
</button>
<button
v-if="row.status === 'revoked'"
@click="handleRestore(row)"
class="flex flex-col items-center gap-0.5 rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-green-50 hover:text-green-600 dark:hover:bg-green-900/20 dark:hover:text-green-400"
>
<Icon name="refresh" size="sm" />
<span class="text-xs">{{ t('admin.subscriptions.restore') }}</span>
</button>
</div>
</template>
@@ -645,6 +653,17 @@
@cancel="showRevokeDialog = false"
/>
<!-- Restore Confirmation Dialog -->
<ConfirmDialog
:show="showRestoreDialog"
:title="t('admin.subscriptions.restoreSubscription')"
:message="t('admin.subscriptions.restoreConfirm', { user: restoringSubscription?.user?.email })"
:confirm-text="t('admin.subscriptions.restore')"
:cancel-text="t('common.cancel')"
@confirm="confirmRestore"
@cancel="showRestoreDialog = false"
/>
<!-- Reset Quota Confirmation Dialog -->
<ConfirmDialog
:show="showResetQuotaConfirm"
@@ -940,12 +959,14 @@ const pagination = reactive({
const showAssignModal = ref(false)
const showExtendModal = ref(false)
const showRevokeDialog = ref(false)
const showRestoreDialog = ref(false)
const showResetQuotaConfirm = ref(false)
const submitting = ref(false)
const resettingSubscription = ref<UserSubscription | null>(null)
const resettingQuota = ref(false)
const extendingSubscription = ref<UserSubscription | null>(null)
const revokingSubscription = ref<UserSubscription | null>(null)
const restoringSubscription = ref<UserSubscription | null>(null)
const assignForm = reactive({
user_id: null as number | null,
@@ -1261,6 +1282,26 @@ const confirmRevoke = async () => {
}
}
const handleRestore = (subscription: UserSubscription) => {
restoringSubscription.value = subscription
showRestoreDialog.value = true
}
const confirmRestore = async () => {
if (!restoringSubscription.value) return
try {
await adminAPI.subscriptions.restore(restoringSubscription.value.id)
appStore.showSuccess(t('admin.subscriptions.subscriptionRestored'))
showRestoreDialog.value = false
restoringSubscription.value = null
loadSubscriptions()
} catch (error: any) {
appStore.showError(error.response?.data?.detail || t('admin.subscriptions.failedToRestore'))
console.error('Error restoring subscription:', error)
}
}
const handleResetQuota = (subscription: UserSubscription) => {
resettingSubscription.value = subscription
showResetQuotaConfirm.value = true