refactor: externalize upload and conflict helpers

This commit is contained in:
lix-2026
2026-05-25 01:13:08 +08:00
parent 7975ce0997
commit ac15424328
6 changed files with 128 additions and 15 deletions
@@ -246,6 +246,7 @@ pub async fn document_page_shell(
{}
{}
{}
{}
</body>
</html>"#,
escape_html(title),
@@ -270,6 +271,7 @@ pub async fn document_page_shell(
.unwrap_or_default(),
render_document_title_controller_script(),
render_editor_island_adapter_script(),
r#"<script type="module" src="/api/mnote-browser-runtime/document-conflict-panel-runtime.js"></script>"#.to_string(),
);
let mut response = Html(html).into_response();
stamp_shell_headers(response.headers_mut(), "document");
@@ -1896,6 +1898,11 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
};
const clearSessionConflictSurface = (session) => {
var _rt_ = window.__mnoteDocumentConflictPanelRuntime;
if (_rt_ && typeof _rt_.clearSessionConflictSurface === 'function') {
_rt_.clearSessionConflictSurface(session, { sessionViews: sessionViews });
return;
}
sessionViews(session).forEach((view) => {
const host = view.runtimeDescriptor.root.closest('.document-pane') || view.runtimeDescriptor.root;
if (!(host instanceof HTMLElement)) return;
@@ -4465,6 +4472,21 @@ pub async fn tree_shell_runtime_asset() -> Response {
.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");
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",