「文件管理」包含在 Pro 里,开通会员后显示预览。
用法
import { DashboardFiles } from './DashboardFiles.jsx'
// Without items the block shows its sample bakery drive. Wire it to yours:
<DashboardFiles
locale="en"
items={drive.items} // [{ id, name, type: 'folder' | 'pdf' | 'sheet' | 'doc' | 'image' | 'video' | 'archive' | 'design', size, at, parent }]
storage={drive.storage} // { total, used: { images, videos, documents, other } } in bytes
onOpen={(item) => item.type !== 'folder' && preview(item)}
onUpload={(file, progress) => drive.upload(file, { onProgress: progress })} // progress(0..1); resolve when stored
onDownload={(items) => drive.zip(items)}
onDelete={(items) => drive.remove(items.map((item) => item.id))}
loading={drive.loading}
error={drive.error}
onRetry={drive.reload}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字、示例文件、大小和日期格式所用的语言。 |
items | Array<{ id, name, type, size, at, parent }> | sample drive | 所有文件夹和文件;parent 是所在文件夹的 id,顶层为 null。size 以字节计。 |
storage | { total, used: { images, videos, documents, other } } | sample plan | 套餐总空间和各类型用量(字节),上传和删除时会随之变化。 |
view | 'grid' | 'list' | 'grid' | 初始显示方式。 |
onUpload | (file, progress) => Promise | — | 拖入或选择了文件。用 0 到 1 调用 progress 汇报进度;保存后 resolve,失败时 reject。 |
onOpen / onDownload / onDelete | (item) => void / (items) => Promise / (items) => Promise | — | 打开了某一项(文件夹也会在原地打开),或用选择栏下载、删除所选项。 |
now | Date | string | now | 新上传文件的日期。 |
loading | boolean | false | 显示文件区的骨架。 |
error / onRetry | boolean | string / () => void | false | 显示带重试按钮的错误提示;传字符串可替换说明。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素上的类名。 |
装进你的项目
Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。
DashboardFiles.jsxdashboard-files.csscopy.jskit.jsxkit.cssui/base-button/ui/category-bar/ui/empty-state/ui/alert-banner/ui/checkbox/ui/skeleton-shimmer/ui/breadcrumb/ui/segmented-control/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。
