「工作台」包含在 Pro 里,开通会员后显示预览。
用法
import { Workbench } from './Workbench.jsx'
<Workbench
locale="en"
name={user.firstName}
hour={new Date().getHours()}
todos={tasks.list} // [{ id, title, when?, late?, done? }]
shortcuts={[{ label: 'New roast', icon: 'plus' }, { label: 'Log a brew', icon: 'cup' }]}
agenda={[{ time: '10:00', title: 'Cupping session', where: 'Lab · 45 min' }]}
numbers={[{ label: 'Bags sold', value: '312', change: '8%', trend: 'up' }]}
recent={[{ kind: 'roast', icon: 'cup', title: 'Ethiopia Guji', meta: 'Roast · 10 min ago', href: '/roasts/guji' }]}
loading={tasks.loading}
error={tasks.error}
onRetry={tasks.reload}
onToggle={(id, done) => tasks.update(id, { done })}
onShortcut={(index) => router.push(['/projects/new', '/invoices/new', '/time', '/files'][index])}
onOpen={(item) => router.push(item.href)}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字和示例数据的语言。 |
name / hour | string / number | 'Mia' / 9 | 问候的对象,以及决定早上、下午或晚上的小时数(传入它,服务端和浏览器才会一致)。 |
todos | Array<{ id, title, when?, late?, done? }> | — | 待办列表。没有未完成项时,模块会说明已全部处理并告诉新待办从哪里来。 |
date | string | by locale | 问候语上方的日期,传已经格式化好的文字。 |
shortcuts | Array<string | { label, icon? }> | 4 sample shortcuts | 快捷按钮;`onShortcut` 收到按钮序号。图标用 kit 里的图标名。 |
agenda | Array<{ time, title, where }> | sample agenda | “今天”日程卡片。 |
numbers | Array<{ label, value, change, trend: 'up' | 'down' }> | sample numbers | 本周数字;数值按传入的文字原样显示。 |
recent | Array<{ kind, title, meta, icon? }> | sample records | 最近打开的记录;`onOpen` 收到该条目。 |
loading / error | boolean | — | 加载中显示占位模块;加载失败时显示提示和重试(onRetry)。 |
onToggle / onShortcut / onOpen | (id, done) => void / (index) => void / (item) => void | — | 勾选或取消待办时;点击快捷入口时;打开最近内容时。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
装进你的项目
Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。
Workbench.jsxworkbench.csscopy.jskit.jsxkit.cssui/base-button/ui/alert-banner/ui/checkbox/ui/skeleton-shimmer/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。
