fix: stabilize local attachment icons and office proxy urls

This commit is contained in:
lix-2026
2026-05-26 09:44:35 +08:00
parent 0a15595066
commit 8cd8b44db3
11 changed files with 564 additions and 14 deletions
@@ -405,10 +405,9 @@ pub async fn page(Query(query): Query<OnlyOfficePageQuery>) -> Result<Response,
mode: {mode}
}};
const MNOTE_AGENT_PLUGIN_GUID = "asc.{{05F87DDF-7B42-4C6F-9F2B-9C77A8D5F4E2}}";
const pageLocal = location.hostname === "127.0.0.1" || location.hostname === "localhost";
const documentUrlBase = {document_url_base};
const proxyOrigin = pageLocal ? documentUrlBase : location.origin;
const callbackOrigin = proxyOrigin;
const proxyOrigin = documentUrlBase;
const callbackOrigin = documentUrlBase;
function showError(message) {{
window.__MNOTE_ONLYOFFICE_ERRLOG__.push({{ kind: "error", message: String(message || "") }});
@@ -1821,7 +1820,11 @@ mod tests {
.expect("body");
let html = String::from_utf8(body.to_vec()).expect("html");
assert!(html.contains("const documentUrlBase = \"http://host.docker.internal:3000\";"));
assert!(html.contains("const proxyOrigin = pageLocal ? documentUrlBase : location.origin;"));
assert!(html.contains("const proxyOrigin = documentUrlBase;"));
assert!(html.contains("const callbackOrigin = documentUrlBase;"));
assert!(
!html.contains("const proxyOrigin = pageLocal ? documentUrlBase : location.origin;")
);
assert!(html.contains("documentUrlBase,"));
assert!(html.contains("resolvedFileUrl: fileState.resolvedFileUrl"));
}