diff --git a/web/frontend/src/pages/projects/index.jsx b/web/frontend/src/pages/projects/index.jsx index e23f6858..7bf13799 100644 --- a/web/frontend/src/pages/projects/index.jsx +++ b/web/frontend/src/pages/projects/index.jsx @@ -1,7 +1,7 @@ /** 项目管理:项目列表(含仪表盘统计)、项目详情、深链接 ?id=。 */ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useSearchParams } from 'react-router-dom'; -import { Button, Empty, Input, Select, Space, Tag, Typography } from '@douyinfe/semi-ui'; +import { Button, Empty, Input, Pagination, Select, Space, Tag, Typography } from '@douyinfe/semi-ui'; import { IconPlus, IconRefresh, IconSearch } from '@douyinfe/semi-icons'; import { api } from '../../lib/http'; import { useT } from '../../lib/i18n'; @@ -17,6 +17,7 @@ import { errorProp, errText } from './helpers'; import './page.css'; const { Text } = Typography; +const PROJECT_PAGE_SIZE = 10; async function loadProjects() { const [list, summary] = await Promise.all([ @@ -43,6 +44,7 @@ export default function ProjectsPage() { const [search, setSearch] = useState(''); const debounced = useDebounced(search, 250); const [statusFilter, setStatusFilter] = useState('all'); + const [listPage, setListPage] = useState(1); const [modal, setModal] = useState({ visible: false, project: null }); const [detailRev, setDetailRev] = useState(0); @@ -68,6 +70,8 @@ export default function ProjectsPage() { return [item.name, item.description, item.id].join(' ').toLowerCase().includes(keyword); }); }, [projects, debounced, statusFilter]); + const currentPage = Math.min(listPage, Math.max(1, Math.ceil(filtered.length / PROJECT_PAGE_SIZE))); + const pageProjects = filtered.slice((currentPage - 1) * PROJECT_PAGE_SIZE, currentPage * PROJECT_PAGE_SIZE); // 首次进入且没有指定项目时,默认选中第一个可见项目,避免右侧面板空白。 useEffect(() => { @@ -220,6 +224,7 @@ export default function ProjectsPage() { {filtered.length} / {projects.length}} >
@@ -228,12 +233,12 @@ export default function ProjectsPage() { value={search} showClear placeholder={t('projects.searchProjectsPlaceholder', null, '搜索项目…')} - onChange={value => setSearch(value)} + onChange={value => { setSearch(value); setListPage(1); }} style={{ width: '100%' }} />