Implement Rust web sidebar title and tree interactions
This commit is contained in:
@@ -9,7 +9,7 @@ use leptos::prelude::*;
|
||||
/// MNOTE 搜索页面
|
||||
///
|
||||
/// 渲染搜索页面的 SSR 壳结构:
|
||||
/// - `<main id="mnote-search-shell" data-island-host="react_search_palette">`
|
||||
/// - `<main id="mnote-search-shell" data-island-host="search_interaction_island">`
|
||||
/// - 搜索标题区域
|
||||
/// - 搜索岛占位区
|
||||
#[component]
|
||||
@@ -26,10 +26,14 @@ pub fn SearchPage(
|
||||
/// 工作区名称(可选)
|
||||
#[prop(optional)]
|
||||
workspace_name: Option<String>,
|
||||
/// 服务端首批搜索结果 HTML(可选)
|
||||
#[prop(optional)]
|
||||
initial_results_html: Option<String>,
|
||||
) -> impl IntoView {
|
||||
let initial_results_html = initial_results_html.unwrap_or_default();
|
||||
view! {
|
||||
<PageLayout current_nav="search" sidebar_tree_html={sidebar_tree_html.unwrap_or_default()} workspace_name={workspace_name.unwrap_or_default()}>
|
||||
<main id="mnote-search-shell" data-island-host="react_search_palette">
|
||||
<main id="mnote-search-shell" data-island-host="search_interaction_island">
|
||||
<header class="search-header">
|
||||
<h1>{"搜索"}</h1>
|
||||
<p class="search-meta">
|
||||
@@ -43,7 +47,8 @@ pub fn SearchPage(
|
||||
}}
|
||||
</p>
|
||||
</header>
|
||||
<section id="mnote-search-island" data-react-island="search_palette"></section>
|
||||
<section id="mnote-search-results" data-search-results-owner="rust-kernel" inner_html={initial_results_html}></section>
|
||||
<section id="mnote-search-island" data-react-island="search_interaction"></section>
|
||||
</main>
|
||||
</PageLayout>
|
||||
}
|
||||
@@ -60,9 +65,9 @@ mod tests {
|
||||
<SearchPage workspace_id="ws_demo" search_query="Rust" />
|
||||
});
|
||||
assert!(html.contains("mnote-search-shell"));
|
||||
assert!(html.contains("data-island-host=\"react_search_palette\""));
|
||||
assert!(html.contains("data-island-host=\"search_interaction_island\""));
|
||||
assert!(html.contains("mnote-search-island"));
|
||||
assert!(html.contains("data-react-island=\"search_palette\""));
|
||||
assert!(html.contains("mnote-search-results"));
|
||||
assert!(html.contains("搜索"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user