面板与导航
SDUI 提供三段式应用外壳、多级导航树、全局搜索与页面级仪表盘布局;上层 Fly 在此基础上封装 Panel 注册、Resource 路由与账户流程。
页面文案与 Document#
页面元信息、HTML 文档槽位、明暗主题切换与顶栏账户菜单由以下组件协作管理:
| 组件 / 类型 | 作用与核心配置 |
|---|---|
PageChrome / Document | PageChrome::capture 采标题;Document 收 main、sidebar、topbar、breadcrumb(DocumentError::DuplicateSlot)与 set_body_attribute |
ThemeSwitch | 顶栏按钮(kxed-theme-switch-trigger),切换 Light/Dark/Auto 并写 THEME_ATTRIBUTE(data-kxed-theme)与 THEME_STORAGE_KEY(kxed-theme),首屏由同步 theme.js 防闪白 |
ViewerProfile | 宿主在 mount 调 set_viewer_profile、render 调 with_viewer_profile 注入(见 FLY.md 的 Panel),子组件由 viewer_profile() 读取 |
UserMenu | 共用 Menu 漫游(同名设 key);UserMenu::from_profile 展示 kxed-user-menu-avatar 与角色副标题 |
TenantSwitcher | from_profile 支持导航式(path_template/url_using/external()/more(Link))与 POST 式 submit_to(TenantSubmit::new(action, csrf))(读 csrf_token(&session)) |
容器外观#
Section、Fieldset、Card、Collapse、Tabs 与 Infolist 统一通过 .surface(Surface) 设置外框风格(输出 data-kxed-surface):
卡片
区块内容
填充
区块内容
朴素
区块内容
查看后端实现源码(Rust)折叠 / 展开
fn surfaces(ctx: RenderCtx<'_>) -> Html {
let section = |title: &'static str, surface| {
Section::make(title)
.surface(surface)
.schema(Schema::new().component(Placeholder::make("surface_note").content("区块内容")))
};
Html::fragment([
ctx.render(section("卡片", Surface::Card)),
ctx.render(section("填充", Surface::Filled)),
ctx.render(section("朴素", Surface::Plain)),
])
}Surface | 中文 | 外观 |
|---|---|---|
Card | 卡片 | 分隔线色描边、md 圆角、--kxed-surface 底色、xs 阴影与内边距 |
Plain | 无边框分组 | 没有描边、底色、阴影与外围内边距,标题与内容之间保留分组间距,相邻分组之间用细分隔线区分 |
Filled | 浅底填充 | 没有描边,--kxed-subtle 浅底、md 圆角与内边距 |
Auto(缺省) | 自动 | 最外层按 Card 渲染,嵌在 card、filled 或 auto 容器里按 Plain 渲染 |
use kxed_livecell::sdui::{Card, Fieldset, Schema, Section, Surface, TextInput};
fn profile_card() -> Card {
Card::make().title("Profile").child(
Section::make("Contact")
.surface(Surface::Plain)
.schema(Schema::new().component(TextInput::make("email")))
.render(),
)
}
fn filled_group() -> Fieldset {
Fieldset::make("Address").surface(Surface::Filled).compact()
}- 自动去重:
Auto由 CSS 选择器在外层有框容器内自动降级为Plain,避免卡片套卡片(显式嵌套两个Surface::Card会在开发期报错)。 - 组件差异:
Section与Fieldset支持compact();Tabs的surface控制整体外框(不影响改页签头的Tabs::card());Infolist在Card/Filled下用density(TableDensity)调整疏密。
布局与导航#
PanelLayout 提供包含侧栏、顶栏、多标签页栏与响应式内容区的应用骨架,主导航位置由 navigation_mode(NavigationMode)(输出 data-kxed-layout)决定:
| 取值 | 桌面 | 48rem 以下 |
|---|---|---|
Side(缺省) | 侧栏放整棵导航,顶栏放折叠键、面包屑与工具区 | 侧栏是抽屉 |
Top | 顶栏横跨整行放品牌位、横排导航与工具区,无侧栏;放不下的入口收进「更多」下拉 | 横排导航隐藏,折叠键打开整棵导航抽屉;fixed_sidebar 与 without_sidebar 不生效 |
Mix | 顶栏放一级入口,侧栏切换显示当前入口的子导航段,无子项时不出侧栏 | 一级入口换到顶栏第二行横向滚动,侧栏是抽屉 |
导航权限裁决是异步过程,必须在 mount 中调用 Navigation::resolve 预先生成可见导航树(公开无权限导航可用同步的 resolve_public):
async fn mount(&mut self, ctx: &mut MountCtx<'_>) -> LiveResult {
self.navigation = navigation().resolve(&self.access, ctx.viewer(), ctx.path()).await?;
Ok(())
}| 组件 / 能力 | 关键配置与运行行为 |
|---|---|
PanelLayout 外壳 | width(ContentWidth);含 topbar_start/end、sidebar_header/footer、header_action、without_fixed_header、fixed_sidebar、without_sidebar |
| 侧栏折叠 | 展开 256px、折叠 64px、顶栏 56px(kxedSidebar 写 data-kxed-sidebar 存 SIDEBAR_STORAGE_KEY/sidebar_scope,窄屏写 data-kxed-drawer) |
| 首字徽记与分组折叠 | 折叠态生成 kxed-nav-initial 与 sdui-navigation-badge 说明;NavigationGroup::collapsible()/collapsed() 由 kxedNavGroup 持久化 |
Brand 与骨架 | Brand 含 logo_image*、wordmark_image*;NavigationItem/Link::skeleton、Table::route_skeleton() 写 data-kxed-skeleton(RouteSkeleton) |
tabs_bar() 多标签栏 | 由 kxedTabsBar 在 TABS_STORAGE_KEY(kxed-tabs 或 tabs_bar_scope)记录访问路径并切换(不保活实例),首个导航项固定为不可关闭的首页,溢出显示横向滚动箭头 |
Navigation 裁决 | NavigationAccess(并发 NAVIGATION_CONCURRENCY = 8,navigation_access/AllowAllNavigation)配 authorize_with(data-kxed-active/trail) |
NavigationBadge | 支持同步计数,或调 deferred() 后通过 navigation_badge_target、navigation_badge_html、navigation_badge_name_target、navigation_badge_name_html 异步 morph 推送 |
Breadcrumb / SubNavigation | Breadcrumb::from_navigation 自动提取路径(超 5 段折叠中间层至 Tooltip,link_at 可改写链接);SubNavigation 在内容区顶部渲染二级页签导航 |
GlobalSearch | GlobalSearchState(MAX_SEARCH_CHARS、DEFAULT_MIN_LENGTH)调 GlobalSearchSource::search/search_loader(SearchResult),kxedSearch 响应 ⌘K |
FusedGroup | 将一组相邻控件与按钮去除内侧圆角拼成一体,通过 label(..) 设置 aria-label |
Dashboard | 分 header/body/footer 排布 widget,支持 data(Value)/set_data 与整页 state(ViewState)/set_state/view_state()/status_view(单卡状态见只读详情与仪表盘) |
ResourcePage | 提供标题、页头动作与 status(Html),配合 FormState 与 render_form 承载表单页(CRUD 约束见 Fly) |