diff --git a/frontend/src/pages/admin/cards/components/columns.ts b/frontend/src/pages/admin/cards/components/columns.ts index 215d8db..43130ca 100644 --- a/frontend/src/pages/admin/cards/components/columns.ts +++ b/frontend/src/pages/admin/cards/components/columns.ts @@ -1,7 +1,7 @@ import type { ColumnDef } from '@tanstack/vue-table' import type { Composer } from 'vue-i18n' -import { Ban, MoreHorizontal, Trash2 } from 'lucide-vue-next' +import { Ban, KeyRound, MoreHorizontal, Trash2 } from 'lucide-vue-next' import { h } from 'vue' import type { Card } from '@/pages/admin/cards/data/schema' @@ -196,6 +196,14 @@ export function getColumns(actions: { isBanned ? t('admin.cards.enable') : t('admin.cards.disable'), ]), h(DropdownMenuSeparator), + // 只有登录卡能补发:换一把钥匙,主体/余额/设备都不动 + card.purpose === 'credential' && actions.onReissue + ? h(DropdownMenuItem, { onClick: () => actions.onReissue!(card) }, () => [ + h(KeyRound, { class: 'mr-2 h-4 w-4' }), + '作废并补发新卡密', + ]) + : null, + card.purpose === 'credential' && actions.onReissue ? h(DropdownMenuSeparator) : null, h(DropdownMenuItem, { class: 'text-destructive', onClick: () => actions.onDelete(card) }, () => [ h(Trash2, { class: 'mr-2 h-4 w-4' }), t('admin.cards.delete'), diff --git a/frontend/src/pages/admin/cards/index.vue b/frontend/src/pages/admin/cards/index.vue index 52c39b7..192a786 100644 --- a/frontend/src/pages/admin/cards/index.vue +++ b/frontend/src/pages/admin/cards/index.vue @@ -175,15 +175,10 @@ async function reissueCard(row: Card) { if (!ok) return try { - const res: any = await api.post(`/dev/cards/${row.id}/reissue`, {}) - const data = res.data - if (data.code === 200) { - toast.success(`已补发新卡密:${data.data.new_key}`) - fetchCards() - } - else { - toast.error(data.message || '补发失败') - } + const data: any = await api.post(`/dev/cards/${row.id}/reissue`, {}) + toast.success(`已补发新卡密:${data?.new_key || ''}`) + fetchCards() + fetchSecurity() } catch (e: any) { toast.error(e?.response?.data?.message || '补发失败') @@ -195,10 +190,7 @@ const secStats = ref(null) async function fetchSecurity() { try { const qs = appFilter.value ? `?application_id=${appFilter.value}` : '' - const res: any = await api.get(`/dev/cards/security${qs}`) - const payload = res?.data ?? res - if (payload?.code === 200) - secStats.value = payload.data + secStats.value = await api.get(`/dev/cards/security${qs}`) } catch { /* 概览失败不影响列表 */ } }