跳到正文
简体中文
「详情页」包含在 Pro 里,开通会员后显示预览。

用法

import { DetailPage } from './DetailPage.jsx'

<DetailPage
  locale="en"
  record={project}          // { id, name, status: 'draft' | 'active' | 'review' | 'approved', client, owner, start, due, budget, spent, billing, about }
  activity={project.events} // [{ id, kind: 'status' | 'comment' | 'file' | 'invoice' | 'created', icon?, who, text, when }]
  statuses={[               // optional: your own statuses; Approve moves the record to the final one
    { id: 'open', label: 'Open', tone: 'progress' },
    { id: 'done', label: 'Done', tone: 'success', final: true },
  ]}
  facts={[{ label: 'Client', value: project.client }, { label: 'Due', value: '4 Dec' }]}
  files={project.files}     // [{ name, meta }]
  people={project.people}   // [{ name, role, tone: 0-3 }]
  next={{ name: 'Menu boards to print', date: '2026-12-04' }}
  currency="EUR"
  loading={!project}
  onAction={async (which) => {           // 'approve' | 'edit' | 'share'
    if (which === 'approve') return (await fetch('/api/projects/' + project.id + '/approve', { method: 'POST' })).ok
    if (which === 'edit') router.push('/projects/' + project.id + '/edit')
  }}
  onComment={async (text) => (await postComment(project.id, text)).ok}
  onBack={() => router.push('/projects')}
/>

属性

属性类型默认值作用
locale'en' | 'zh-CN' | 'es' | 'ja''en'内置文字、示例记录以及日期和金额格式的语言。
recordobject—要显示的记录(字段见用法)。
activityArray<{ id, kind, who, text, when }>—动态时间线,最新的在前。为空时说明并引导写第一条评论。
statusesArray<{ id, label, tone: 'neutral' | 'progress' | 'warning' | 'success' | 'danger', final? }>'draft, active, review, approved'记录可有的状态。标了 `final` 的状态带勾号;“通过”把记录移到第一个 final 状态,之后按钮隐藏(没有 final 状态就没有“通过”)。
currencystringby locale预算的 ISO 货币代码,例如 EUR(也可用 `record.currency`)。
factsArray<{ label, value }>client, owner, start, due, budget, billing概览页签里的信息行,替换内置的项目信息。可复制的编号始终在最后。
filesArray<{ name, meta }>sample files文件页签的内容。
peopleArray<{ name, role, tone?: 0 | 1 | 2 | 3 }>sample people页签旁的成员卡片;头像取名字的首字母。
next{ name, date: 'YYYY-MM-DD' } | nullsample milestone下一个里程碑卡片;传 null 则隐藏。
defaultTab'overview' | 'activity' | 'files''overview'初始显示的标签页。
loading / errorboolean—加载中显示占位;加载失败时显示提示和重试(onRetry)。
onAction(which: 'approve' | 'edit' | 'share', record) => Promise<boolean | void> | void—点击顶部操作时调用。失败时返回 false,审核通过就不会改变状态。
onComment(text) => Promise<boolean | void>—提交评论时调用。
labelsobject—替换任意内置文字(键名见 copy.js)。

装进你的项目

Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。

DetailPage.jsxdetail-page.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/status-tag/ui/alert-banner/ui/textarea/ui/skeleton-shimmer/ui/sliding-tabs/tokens.cssREADME.md

区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。