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

用法

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

// Without events the feed shows its sample morning. Wire it to yours, with your own types of event:
<DashboardActivity
  locale="en"
  filters={[
    { id: 'sales', label: 'Sales', icon: 'bag', tone: 'secondary' },
    { id: 'roasts', label: 'Roasts', icon: 'flame' },
    { id: 'team', label: 'Team', icon: 'user', tone: 'tertiary' },
  ]}
  events={feed.events}       // [{ id, type: a filter id, actor?, text, at, unread?, warn?, icon? }]
  incoming={feed.incoming}   // arrived since: shown behind the "new" pill
  onShowNew={(events) => feed.merge(events)}
  onOpen={(event) => openEvent(event.id)}
  onMarkAllRead={() => feed.markAllRead()}
  loading={feed.loading}
  error={feed.error}
  onRetry={feed.reload}
/>

属性

属性类型默认值作用
locale'en' | 'zh-CN' | 'es' | 'ja''en'内置文字、示例动态和时间格式所用的语言。
eventsArray<{ id, type, actor?, text, at, unread?, warn?, icon?, tone? }>sample morningtype 为 `filters` 中某一项的 id,动态沿用该项的图标和底色,也可自带 icon(图标名或节点)。按时间倒序;at 为日期或日期字符串;warn 表示需要注意的问题。之前没出现过的动态会从顶部长出。
filtersArray<{ id, label, icon?, tone?: 'secondary' | 'tertiary' }>orders, kitchen, team“全部”之后的筛选标签,每种动态类型一个,附带该类动态使用的图标(图标名、“flame”或节点)和底色。
incomingArray<event>[]浏览期间新到的动态:先收在“新动态”提示后面。
nowDate | stringnow“今天”“昨天”分组以哪一天为准。
onOpen(event) => void—打开了一条动态,它会被标为已读。
onShowNew(events) => void—点开了“新动态”提示,参数为新动态列表。
onMarkAllRead() => void—全部标为已读时调用。
loadingbooleanfalse显示动态流的骨架。
error / onRetryboolean | string / () => voidfalse显示带重试按钮的错误提示;传字符串可替换说明。
labelsobject—替换任意内置文字(键名见 copy.js)。

装进你的项目

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

DashboardActivity.jsxdashboard-activity.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/alert-banner/ui/skeleton-shimmer/ui/sliding-tabs/tokens.cssREADME.md

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