fix(ui): 统一表格筛选分页和用量明细,升级 ESLint
This commit is contained in:
@@ -29,6 +29,7 @@ import i18next from 'i18next';
|
||||
import { Database, MessageSquareText, SlidersHorizontal } from 'lucide-react';
|
||||
import {
|
||||
Table,
|
||||
Pagination,
|
||||
Button,
|
||||
Input,
|
||||
Select,
|
||||
@@ -61,6 +62,8 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const [calls, setCalls] = useState(null); // null = 加载中
|
||||
const [error, setError] = useState('');
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
@@ -89,6 +92,10 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
};
|
||||
}, [orgId, groupKey, t]);
|
||||
|
||||
useEffect(() => {
|
||||
setPage(1);
|
||||
}, [calls]);
|
||||
|
||||
if (calls === null) {
|
||||
return (
|
||||
<div className='text-xs text-gray-400 dark:text-gray-500 mt-2'>
|
||||
@@ -134,7 +141,7 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{calls.map((log) => (
|
||||
{calls.slice((page - 1) * pageSize, page * pageSize).map((log) => (
|
||||
<tr
|
||||
key={log.id}
|
||||
className='border-t border-gray-100 dark:border-white/[0.06]'
|
||||
@@ -160,6 +167,18 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<Pagination
|
||||
className='mt-4'
|
||||
align='end'
|
||||
currentPage={page}
|
||||
pageSize={pageSize}
|
||||
total={calls.length}
|
||||
onPageChange={setPage}
|
||||
onPageSizeChange={(size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user