|
@@ -28,6 +28,7 @@ import AccountDetailDrawer from '@/components/admin/accounts/AccountDetailDrawer
|
|
|
import AccountExportModal from '@/components/admin/accounts/AccountExportModal';
|
|
import AccountExportModal from '@/components/admin/accounts/AccountExportModal';
|
|
|
import Pagination from '@/components/common/Pagination';
|
|
import Pagination from '@/components/common/Pagination';
|
|
|
import { Account } from '@/types';
|
|
import { Account } from '@/types';
|
|
|
|
|
+import { isItemInCooldown } from '@/lib/cooldown';
|
|
|
|
|
|
|
|
export default function AdminAccountsPage() {
|
|
export default function AdminAccountsPage() {
|
|
|
const [loading, setLoading] = useState<boolean>(true);
|
|
const [loading, setLoading] = useState<boolean>(true);
|
|
@@ -38,7 +39,8 @@ export default function AdminAccountsPage() {
|
|
|
const [total, setTotal] = useState(0);
|
|
const [total, setTotal] = useState(0);
|
|
|
const [keyword, setKeyword] = useState('');
|
|
const [keyword, setKeyword] = useState('');
|
|
|
const [selectedPool, setSelectedPool] = useState<string>('all');
|
|
const [selectedPool, setSelectedPool] = useState<string>('all');
|
|
|
- const [statusFilter, setStatusFilter] = useState<'all' | 'active' | 'locked' | 'disable'>('all');
|
|
|
|
|
|
|
+ const [statusFilter, setStatusFilter] = useState<'all' | 'active' | 'disable'>('all');
|
|
|
|
|
+ const [cooldownFilter, setCooldownFilter] = useState<'all' | 'cooling' | 'ready'>('all');
|
|
|
|
|
|
|
|
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
|
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
|
|
|
|
|
|
@@ -105,14 +107,20 @@ export default function AdminAccountsPage() {
|
|
|
return data.filter((item) => {
|
|
return data.filter((item) => {
|
|
|
const matchPool = selectedPool === 'all' || item.pool_name === selectedPool;
|
|
const matchPool = selectedPool === 'all' || item.pool_name === selectedPool;
|
|
|
const matchStatus = statusFilter === 'all' || item.status === statusFilter;
|
|
const matchStatus = statusFilter === 'all' || item.status === statusFilter;
|
|
|
- return matchPool && matchStatus;
|
|
|
|
|
|
|
+ const isCooling = isItemInCooldown(item.next_use_time);
|
|
|
|
|
+ const matchCooldown =
|
|
|
|
|
+ cooldownFilter === 'all' ||
|
|
|
|
|
+ (cooldownFilter === 'cooling' && isCooling) ||
|
|
|
|
|
+ (cooldownFilter === 'ready' && !isCooling);
|
|
|
|
|
+
|
|
|
|
|
+ return matchPool && matchStatus && matchCooldown;
|
|
|
});
|
|
});
|
|
|
- }, [data, selectedPool, statusFilter]);
|
|
|
|
|
|
|
+ }, [data, selectedPool, statusFilter, cooldownFilter]);
|
|
|
|
|
|
|
|
const stats = useMemo(() => {
|
|
const stats = useMemo(() => {
|
|
|
const totalCount = data.length;
|
|
const totalCount = data.length;
|
|
|
const activeCount = data.filter((a) => a.status === 'active').length;
|
|
const activeCount = data.filter((a) => a.status === 'active').length;
|
|
|
- const lockedCount = data.filter((a) => a.status === 'locked').length;
|
|
|
|
|
|
|
+ const lockedCount = data.filter((a) => isItemInCooldown(a.next_use_time)).length;
|
|
|
const disabledCount = data.filter((a) => a.status === 'disable').length;
|
|
const disabledCount = data.filter((a) => a.status === 'disable').length;
|
|
|
const poolsCount = uniquePools.length;
|
|
const poolsCount = uniquePools.length;
|
|
|
|
|
|
|
@@ -243,27 +251,27 @@ export default function AdminAccountsPage() {
|
|
|
{/* 2. 统计指标卡片看板 */}
|
|
{/* 2. 统计指标卡片看板 */}
|
|
|
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
|
|
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
|
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
|
- <span className="text-[10px] font-black uppercase text-neutral-500">[ 总账号池 ]</span>
|
|
|
|
|
|
|
+ <span className="text-[10px] font-black uppercase text-neutral-500">[ 总账号池 TOTAL ]</span>
|
|
|
<div className="text-2xl font-black text-black">{stats.total} 个</div>
|
|
<div className="text-2xl font-black text-black">{stats.total} 个</div>
|
|
|
<div className="text-[10px] text-neutral-500 font-sans">全量登记账号</div>
|
|
<div className="text-[10px] text-neutral-500 font-sans">全量登记账号</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
|
- <span className="text-[10px] font-black uppercase text-black">[ 正常可用 ACTIVE ]</span>
|
|
|
|
|
- <div className="text-2xl font-black text-black">{stats.active} 个</div>
|
|
|
|
|
- <div className="text-[10px] text-neutral-500 font-sans">就绪直接调用</div>
|
|
|
|
|
|
|
+ <span className="text-[10px] font-black uppercase text-emerald-800">[ 启用中 ACTIVE ]</span>
|
|
|
|
|
+ <div className="text-2xl font-black text-emerald-800">{stats.active} 个</div>
|
|
|
|
|
+ <div className="text-[10px] text-neutral-500 font-sans">正常启用账号</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
|
- <span className="text-[10px] font-black uppercase text-neutral-600">[ 冷却锁定 LOCKED ]</span>
|
|
|
|
|
- <div className="text-2xl font-black text-black">{stats.locked} 个</div>
|
|
|
|
|
|
|
+ <span className="text-[10px] font-black uppercase text-amber-700">[ 冷却锁定 COOLING ]</span>
|
|
|
|
|
+ <div className="text-2xl font-black text-amber-700">{stats.locked} 个</div>
|
|
|
<div className="text-[10px] text-neutral-500 font-sans">冷却倒计时中</div>
|
|
<div className="text-[10px] text-neutral-500 font-sans">冷却倒计时中</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1">
|
|
|
<span className="text-[10px] font-black uppercase text-rose-800">[ 已禁用 DISABLED ]</span>
|
|
<span className="text-[10px] font-black uppercase text-rose-800">[ 已禁用 DISABLED ]</span>
|
|
|
<div className="text-2xl font-black text-rose-800">{stats.disabled} 个</div>
|
|
<div className="text-2xl font-black text-rose-800">{stats.disabled} 个</div>
|
|
|
- <div className="text-[10px] text-neutral-500 font-sans">失效或手动停用</div>
|
|
|
|
|
|
|
+ <div className="text-[10px] text-neutral-500 font-sans">手动停用账号</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1 col-span-2 sm:col-span-1">
|
|
<div className="bg-white p-4 border-2 border-black shadow-[4px_4px_0px_#000] space-y-1 col-span-2 sm:col-span-1">
|
|
@@ -306,10 +314,19 @@ export default function AdminAccountsPage() {
|
|
|
onChange={(e: any) => setStatusFilter(e.target.value)}
|
|
onChange={(e: any) => setStatusFilter(e.target.value)}
|
|
|
className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
|
>
|
|
>
|
|
|
- <option value="all">[ 全部状态 ]</option>
|
|
|
|
|
- <option value="active">正常 (Active)</option>
|
|
|
|
|
- <option value="locked">锁定 (Locked)</option>
|
|
|
|
|
- <option value="disable">禁用 (Disabled)</option>
|
|
|
|
|
|
|
+ <option value="all">[ 全部启用状态 ]</option>
|
|
|
|
|
+ <option value="active">仅启用 (Active)</option>
|
|
|
|
|
+ <option value="disable">仅禁用 (Disabled)</option>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select
|
|
|
|
|
+ value={cooldownFilter}
|
|
|
|
|
+ onChange={(e: any) => setCooldownFilter(e.target.value)}
|
|
|
|
|
+ className="px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-bold text-black outline-none shadow-[2px_2px_0px_#000]"
|
|
|
|
|
+ >
|
|
|
|
|
+ <option value="all">[ 全部冷却状态 ]</option>
|
|
|
|
|
+ <option value="cooling">仅冷却中 (Cooling)</option>
|
|
|
|
|
+ <option value="ready">仅就绪可用 (Ready)</option>
|
|
|
</select>
|
|
</select>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|