design: plan browser runtime extraction

This commit is contained in:
lix-2026
2026-05-24 21:03:33 +08:00
parent cafd29a963
commit b61b56b5b5
6 changed files with 936 additions and 0 deletions
+4
View File
@@ -94,6 +94,10 @@ pub fn build_router(state: AppState) -> Router {
"/api/editor/image-placeholder.svg",
get(web_shell::editor_image_placeholder_asset),
)
.route(
"/api/mnote-browser-runtime/resource-open-runtime.js",
get(web_shell::resource_open_runtime_asset),
)
.route("/api/search/documents", post(search::documents))
.route(
"/api/search/local-index/refresh",
@@ -4366,6 +4366,21 @@ pub async fn editor_image_placeholder_asset() -> Response {
.unwrap_or_else(|_| Response::new(Body::empty()))
}
pub async fn resource_open_runtime_asset() -> Response {
// include_str! 路径相对于当前源文件 (src/routes/web_shell.rs -> ../../browser/)
const JS: &str = include_str!("../../browser/resource-open-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 leptos_tiptap_manifest() -> Response {
let manifest = json!({
"entryAssetPath": "mnote-leptos-tiptap-spike-island.js",