feat: Add owner account management feature with a new frontend list component and backend API/database integration.

This commit is contained in:
2026-01-30 13:23:29 +08:00
parent 3430b57cbf
commit 23901c9d14
4 changed files with 144 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'
import { Users, Trash2, RefreshCw, ChevronLeft, ChevronRight } from 'lucide-react'
import { Users, Trash2, RefreshCw, ChevronLeft, ChevronRight, Key } from 'lucide-react'
import { Card, CardHeader, CardTitle, CardContent, Button } from '../common'
interface TeamOwner {
@@ -84,6 +84,30 @@ export default function OwnerList({ onStatsChange }: OwnerListProps) {
}
}
const [refetching, setRefetching] = useState(false)
const handleRefetchAccountIds = async () => {
if (refetching) return
setRefetching(true)
try {
const res = await fetch('/api/db/owners/refetch-account-ids', { method: 'POST' })
const data = await res.json()
if (data.code === 0) {
const result = data.data
alert(`重新获取完成\n总数: ${result.total}\n成功: ${result.success}\n失败: ${result.fail}`)
loadOwners()
onStatsChange?.()
} else {
alert(`操作失败: ${data.message}`)
}
} catch (e) {
console.error('Failed to refetch account ids:', e)
alert('操作失败,请查看控制台')
} finally {
setRefetching(false)
}
}
const totalPages = Math.ceil(total / limit)
const formatTime = (ts: string) => {
@@ -124,6 +148,16 @@ export default function OwnerList({ onStatsChange }: OwnerListProps) {
<Button variant="ghost" size="sm" onClick={loadOwners} icon={<RefreshCw className="h-4 w-4" />}>
</Button>
<Button
variant="ghost"
size="sm"
onClick={handleRefetchAccountIds}
disabled={refetching}
icon={<Key className={`h-4 w-4 ${refetching ? 'animate-pulse' : ''}`} />}
className="text-blue-500 hover:text-blue-600"
>
{refetching ? '获取中...' : '重新获取ID'}
</Button>
<Button
variant="ghost"
size="sm"