fix: 修复代理卡密统计和列表查询逻辑
- 前端使用后端返回的total字段显示总数 - 后端查询条件兼容旧数据(agent_id IS NULL AND creator_id = ?) - handleGetStats统计接口使用相同查询逻辑 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ const router = useRouter()
|
||||
|
||||
const loading = ref(true)
|
||||
const cards = ref<Card[]>([])
|
||||
const total = ref(0)
|
||||
const tableRef = ref()
|
||||
const searchFilter = ref('')
|
||||
|
||||
@@ -42,17 +43,22 @@ async function fetchCards() {
|
||||
const data = await api.get<any>('/agent/cards')
|
||||
if (Array.isArray(data)) {
|
||||
cards.value = data
|
||||
total.value = data.length
|
||||
} else if (data?.cards) {
|
||||
cards.value = data.cards
|
||||
total.value = data.total || data.cards.length
|
||||
} else if (data?.data) {
|
||||
cards.value = Array.isArray(data.data) ? data.data : []
|
||||
total.value = data.total || cards.value.length
|
||||
} else {
|
||||
cards.value = []
|
||||
total.value = 0
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Load cards failed:', error)
|
||||
cards.value = []
|
||||
total.value = 0
|
||||
}
|
||||
finally {
|
||||
loading.value = false
|
||||
@@ -111,7 +117,7 @@ onMounted(() => {
|
||||
</UiCardHeader>
|
||||
<UiCardContent>
|
||||
<div class="text-2xl font-bold">
|
||||
{{ cards.length }}
|
||||
{{ total }}
|
||||
</div>
|
||||
</UiCardContent>
|
||||
</UiCard>
|
||||
|
||||
Reference in New Issue
Block a user