页面骨架导入路径
PageShell、AppShell、Sidebar、RightSidebar 等布局件分别从哪个包导入;分层规则与常见错误
页面骨架类组件分布在两个包,导入路径由分层决定,不要按名字猜:
@mox-hub/ui:原子层 —— 控件、导航原语与基础布局件(Sidebar*、Card、Tabs、Breadcrumb、Button…)。@mox-hub/patterns:模式层 —— 在 ui 原子之上组合的页面骨架与业务模式件(PageShell、AppShell、DetailPageFrame、RightSidebar…)。
依赖方向是 patterns → ui 单向;ui 不会反向 re-export patterns(否则产生循环依赖),所以页面骨架必须从 patterns 导入。
速查表
| 组件 | 包 | 导入 |
|---|---|---|
AppShell / PageShell / PageHeader | @mox-hub/patterns | import { PageShell } from '@mox-hub/patterns' |
DetailPageFrame / RightSidebar / SidebarPanel | @mox-hub/patterns | import { DetailPageFrame } from '@mox-hub/patterns' |
SettingsPageFrame / SettingsHeader / SettingsSectionCard | @mox-hub/patterns | import { SettingsPageFrame } from '@mox-hub/patterns' |
Sidebar / SidebarProvider / SidebarInset / SidebarTrigger | @mox-hub/ui | import { Sidebar, SidebarProvider } from '@mox-hub/ui' |
Card / Tabs / Breadcrumb / Button / Badge | @mox-hub/ui | import { Card, Tabs } from '@mox-hub/ui' |
ChartContainer(依赖 recharts) | @mox-hub/ui 子路径 | import { ChartContainer } from '@mox-hub/ui/components/chart' |
常见错误
// ❌ @mox-hub/ui 根入口没有 PageShell
// TS: Module '"@mox-hub/ui"' has no exported member 'PageShell'.
import { PageShell } from '@mox-hub/ui'
// ✅ 页面骨架从 patterns 导入
import { PageShell } from '@mox-hub/patterns'// ❌ Sidebar 属于 ui 原子层
import { Sidebar } from '@mox-hub/patterns'
// ✅
import { Sidebar, SidebarProvider, SidebarInset } from '@mox-hub/ui'推荐组合
import {
Breadcrumb,
Sidebar,
SidebarContent,
SidebarProvider,
SidebarRail,
SidebarTrigger,
} from '@mox-hub/ui'
import { AppShell, PageShell } from '@mox-hub/patterns'
<AppShell
providerProps={{ collapsible: 'icon' }}
sidebar={
<Sidebar>
<SidebarContent>{/* 导航 */}</SidebarContent>
<SidebarRail />
</Sidebar>
}
header={
<>
<SidebarTrigger />
<Breadcrumb>{/* 面包屑 */}</Breadcrumb>
</>
}
content={
<PageShell scroll="content" title="项目看板" variant="wide" padded>
{/* 页面内容 */}
</PageShell>
}
/>- 应用壳(侧栏 + 顶栏 + 内容 + 右栏)用
AppShell。 - 单页骨架(标题栏 + 宽度档 + 滚动归属)用
PageShell。 - 详情页双栏母版用
DetailPageFrame。 - 带可选 peer 的组件(chart / donut-chart / form-dialog / code-block 等)不进根 barrel,请按子路径导入。