refactor: split tree shell filetree helpers
This commit is contained in:
@@ -178,6 +178,10 @@ pub fn build_router(state: AppState) -> Router {
|
||||
"/api/mnote-browser-runtime/tree-shell-icons-runtime.js",
|
||||
get(web_shell::tree_shell_icons_runtime_asset),
|
||||
)
|
||||
.route(
|
||||
"/api/mnote-browser-runtime/tree-shell-filetree-runtime.js",
|
||||
get(web_shell::tree_shell_filetree_runtime_asset),
|
||||
)
|
||||
.route(
|
||||
"/api/mnote-browser-runtime/document-conflict-panel-runtime.js",
|
||||
get(web_shell::document_conflict_panel_runtime_asset),
|
||||
@@ -632,6 +636,7 @@ mod tests {
|
||||
"/api/mnote-browser-runtime/tree-shell-page-runtime.js",
|
||||
"/api/mnote-browser-runtime/tree-shell-state-runtime.js",
|
||||
"/api/mnote-browser-runtime/tree-shell-icons-runtime.js",
|
||||
"/api/mnote-browser-runtime/tree-shell-filetree-runtime.js",
|
||||
"/api/mnote-browser-runtime/document-conflict-panel-runtime.js",
|
||||
"/api/mnote-browser-runtime/document-pane-runtime.js",
|
||||
"/api/mnote-browser-runtime/document-mindmap-host-runtime.js",
|
||||
|
||||
@@ -2393,6 +2393,8 @@ pub async fn reduce_tree_shell_runtime(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
const TREE_SHELL_RUNTIME_JS: &str = include_str!("../../browser/tree-shell-runtime.js");
|
||||
const TREE_SHELL_FILETREE_RUNTIME_JS: &str =
|
||||
include_str!("../../browser/tree-shell-filetree-runtime.js");
|
||||
|
||||
use super::{
|
||||
collect_filetree_render_rows, create_command_wire, TreeCommandEnvelopeContext,
|
||||
@@ -2673,7 +2675,10 @@ mod tests {
|
||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.filetree.external-drop"));
|
||||
assert!(html.contains("\"rowKind\":\"asset_folder\""));
|
||||
assert!(html.contains("\"resourceMeta\""));
|
||||
assert!(TREE_SHELL_RUNTIME_JS.contains("const getFileTreeRowOwnerDocumentId = (item) => {"));
|
||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-shell-filetree-runtime.js"));
|
||||
assert!(
|
||||
TREE_SHELL_FILETREE_RUNTIME_JS.contains("function getFileTreeRowOwnerDocumentId(item)")
|
||||
);
|
||||
assert!(TREE_SHELL_RUNTIME_JS
|
||||
.contains("row.dataset.ownerDocumentId = ownerDocumentId || \"\";"));
|
||||
assert!(
|
||||
|
||||
@@ -980,6 +980,20 @@ pub async fn tree_shell_icons_runtime_asset() -> Response {
|
||||
.unwrap_or_else(|_| Response::new(Body::empty()))
|
||||
}
|
||||
|
||||
pub async fn tree_shell_filetree_runtime_asset() -> Response {
|
||||
const JS: &str = include_str!("../../browser/tree-shell-filetree-runtime.js");
|
||||
Response::builder()
|
||||
.status(StatusCode::OK)
|
||||
.header(
|
||||
header::CONTENT_TYPE,
|
||||
"application/javascript; charset=utf-8",
|
||||
)
|
||||
.header(header::CACHE_CONTROL, "no-store")
|
||||
.header(HEADER_MNOTE_WEB_OWNER, "mnote-web")
|
||||
.body(Body::from(JS))
|
||||
.unwrap_or_else(|_| Response::new(Body::empty()))
|
||||
}
|
||||
|
||||
pub async fn document_conflict_panel_runtime_asset() -> Response {
|
||||
// include_str! 路径相对于当前源文件 (src/routes/web_shell.rs -> ../../browser/)
|
||||
const JS: &str = include_str!("../../browser/document-conflict-panel-runtime.js");
|
||||
|
||||
Reference in New Issue
Block a user