「列表查询页」包含在 Pro 里,开通会员后显示预览。
用法
import { ListPage } from './ListPage.jsx'
<ListPage
locale="en"
rows={projects.list} // [{ id, name, client, owner, status, due: 'YYYY-MM-DD', budget }]
statuses={[ // optional: your own statuses; the final one is never overdue and is what Approve moves to
{ id: 'draft', label: 'Draft', tone: 'neutral' },
{ id: 'live', label: 'Live', tone: 'progress' },
{ id: 'done', label: 'Done', tone: 'success', final: true },
]}
currency="EUR"
today={new Date().toISOString().slice(0, 10)}
loading={projects.loading}
error={projects.error}
onRetry={projects.reload}
onBulk={async (action, ids) => (await fetch('/api/projects/' + action, { method: 'POST', body: JSON.stringify(ids) })).ok}
onOpen={(project) => router.push('/projects/' + project.id)}
onCreate={() => router.push('/projects/new')}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字、示例数据以及日期和金额格式的语言。 |
rows | Array<{ id, name, client, owner, status, due, budget }> | — | 记录列表。为空时显示“还没有数据”的空状态,而不是“无结果”。 |
statuses | Array<{ id, label, tone: 'neutral' | 'progress' | 'warning' | 'success' | 'danger', final? }> | draft, active, review, approved | 记录可有的状态,按筛选顺序排列。标了 `final` 的状态不算逾期并带勾号;“通过”会把记录移到第一个 final 状态(没有 final 状态就不显示“通过”)。 |
currency | string | by locale | 预算列的 ISO 货币代码,例如 EUR。 |
today | 'YYYY-MM-DD' | — | 判断“已逾期”和“本月到期”所用的日期。 |
pageSize | number | 6 | 每页行数。 |
loading / error | boolean | — | 加载中显示占位行;加载失败时显示提示和重试(onRetry)。 |
onBulk | (action: 'approve' | 'archive' | 'restore', ids) => Promise<boolean | void> | — | 对所选行执行批量操作(“restore”是归档后的撤销)。返回 false 时保持原样。 |
onOpen / onCreate | (row) => void / () => void | — | 打开某个项目名称时;点击“新建项目”时。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
装进你的项目
Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。
ListPage.jsxlist-page.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/status-tag/ui/alert-banner/ui/select/ui/text-input/ui/skeleton-shimmer/ui/pagination/ui/select-table/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。
