//! MNOTE 搜索页面组件 (SSR) //! //! 提供搜索页面的服务器端渲染壳。 //! 由 `` 外层包装、搜索契约 JSON 嵌入脚本由路由 handler 处理。 use crate::ssr::pages::layout::PageLayout; use leptos::prelude::*; /// MNOTE 搜索页面 /// /// 渲染搜索页面的 SSR 壳结构: /// - `
` /// - 搜索标题区域 /// - 搜索岛占位区 #[component] pub fn SearchPage( /// 工作区 ID #[prop(into)] workspace_id: String, /// 搜索查询 #[prop(into)] search_query: String, /// 侧栏页面树 HTML(可选) #[prop(optional)] sidebar_tree_html: Option, /// 工作区名称(可选) #[prop(optional)] workspace_name: Option, /// 服务端首批搜索结果 HTML(可选) #[prop(optional)] initial_results_html: Option, ) -> impl IntoView { let initial_results_html = initial_results_html.unwrap_or_default(); view! {

{"搜索"}

{format!("工作区: {}", workspace_id)}

{if search_query.is_empty() { "请输入关键词".to_string() } else { format!("查询: {}", search_query) }}

} } #[cfg(test)] mod tests { use super::*; use crate::ssr::render_view; #[test] fn search_page_renders_correct_structure() { let html = render_view(view! { }); assert!(html.contains("mnote-search-shell")); assert!(html.contains("data-island-host=\"search_interaction_island\"")); assert!(html.contains("mnote-search-island")); assert!(html.contains("mnote-search-results")); assert!(html.contains("搜索")); } #[test] fn search_page_contains_layout() { let html = render_view(view! { }); assert!(html.contains("mnote-shell")); assert!(html.contains("mnote-sidebar")); assert!(html.contains("mnote-sidebar-brand")); assert!(html.contains("mnote-sidebar-nav")); assert!(html.contains("mnote-content")); } }