//! MNOTE 通用页面布局组件(Wolai / Notion 风格) use leptos::prelude::*; const SIDEBAR_TREE_JS: &str = r##" "##; /// MNOTE Wolai 风格页面布局 /// /// 包含左侧栏 + 内容区的双栏布局。 /// 侧栏显示品牌、导航链接和可选的页面树。 /// /// # 用法 /// /// ```ignore /// view! { /// /// ... /// /// } /// ``` #[component] pub fn PageLayout( children: Children, current_nav: &'static str, /// 侧栏页面树 HTML(可选),由路由 handler 渲染 #[prop(optional)] sidebar_tree_html: Option, /// 工作区名称(可选),显示在侧栏顶部 #[prop(optional)] workspace_name: Option, /// workspace shell 侧栏 sections HTML(可选),由 projection 渲染 #[prop(optional)] workspace_sidebar_html: Option, ) -> impl IntoView { let sidebar_tree_html = sidebar_tree_html.unwrap_or_default(); let ws_name = workspace_name .map(|value| value.trim().to_string()) .filter(|value| !value.is_empty()) .unwrap_or_else(|| "开发用户 的空间".to_string()); let sidebar_sections_html = workspace_sidebar_html .map(|value| value.trim().to_string()) .filter(|value| !value.is_empty()) .unwrap_or_else(|| { let dataset = serde_json::json!({ "workspaces": [{ "id": "default", "name": ws_name.clone() }], "documents": [] }); let projection = crate::workspace_shell::build_workspace_shell_projection( &dataset, "default", None, &ws_name, ); crate::workspace_shell::render_workspace_shell_sidebar_html( &projection, Some(sidebar_tree_html.as_str()), ) }); view! { "☰""⌂"{"个人"} "☆" "▻" "◴" "⌬" "♙+" "◷" "…" {children()} "AI" "?" } }