0.3.3 外网下载修复
This commit is contained in:
@@ -78,7 +78,7 @@ const setupOnlyOfficeGlobalErrorCapture = () => {
|
||||
window.__MNOTE_ONLYOFFICE_DOMPATCHED__ = true;
|
||||
try {
|
||||
const orig = Node.prototype.removeChild;
|
||||
// eslint-disable-next-line no-extend-native
|
||||
|
||||
(Node.prototype as any).removeChild = function removeChildPatched<T extends Node>(child: T): T {
|
||||
try {
|
||||
return orig.call(this, child) as T;
|
||||
@@ -195,7 +195,7 @@ const setupOnlyOfficeInternalRequestRewrite = (baseUrl: string, onlyofficeBaseUr
|
||||
};
|
||||
const origOpen = (win as any).XMLHttpRequest?.prototype?.open;
|
||||
if (typeof origOpen !== "function") return;
|
||||
// eslint-disable-next-line no-extend-native
|
||||
|
||||
(win as any).XMLHttpRequest.prototype.open = function openPatched(
|
||||
method: string,
|
||||
url: string,
|
||||
@@ -204,7 +204,7 @@ const setupOnlyOfficeInternalRequestRewrite = (baseUrl: string, onlyofficeBaseUr
|
||||
password?: string | null,
|
||||
) {
|
||||
const nextUrl = typeof url === "string" ? rewriteUrl(url) : url;
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
|
||||
return origOpen.call(this, method, nextUrl, async, user as any, password as any);
|
||||
};
|
||||
(win as any).__MNOTE_ONLYOFFICE_XHR_REWRITE__ = true;
|
||||
@@ -225,7 +225,7 @@ const setupOnlyOfficeInternalRequestRewrite = (baseUrl: string, onlyofficeBaseUr
|
||||
const w = (f as HTMLIFrameElement).contentWindow;
|
||||
if (!w) continue;
|
||||
// 说明:同源时才能访问 location;跨域会抛异常,直接跳过。
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
|
||||
w.location?.origin;
|
||||
patchWindow(w);
|
||||
} catch {
|
||||
@@ -259,7 +259,7 @@ const docTypeFromExt = (ext: string) => {
|
||||
|
||||
const waitForDocEditorReady = async (timeoutMs = 120_000) => {
|
||||
const start = Date.now();
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
|
||||
while (true) {
|
||||
// @ts-expect-error ONLYOFFICE 全局对象
|
||||
const ok = Boolean(window.DocsAPI && window.DocsAPI.DocEditor);
|
||||
@@ -267,7 +267,7 @@ const waitForDocEditorReady = async (timeoutMs = 120_000) => {
|
||||
if (Date.now() - start > timeoutMs) {
|
||||
throw new Error("等待 ONLYOFFICE DocEditor 初始化超时");
|
||||
}
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
|
||||
await new Promise((r) => setTimeout(r, 250));
|
||||
}
|
||||
};
|
||||
@@ -606,7 +606,7 @@ export default function OnlyOfficePage() {
|
||||
// 说明:api.js 的 onload 并不代表 DocsAPI/DocEditor 已完全就绪(在慢网/高负载时会出现空白页)。
|
||||
// 因此这里额外等待 DocEditor 挂载,避免偶发“白屏但无错误”的体验。
|
||||
await waitForDocEditorReady(120_000);
|
||||
// eslint-disable-next-line new-cap,@typescript-eslint/no-explicit-any
|
||||
|
||||
const pluginConfigUrl = `${window.location.origin}/onlyoffice/plugins/agent-tools/config.json`;
|
||||
|
||||
const config: any = {
|
||||
@@ -708,7 +708,7 @@ export default function OnlyOfficePage() {
|
||||
config.editorConfig.token = editorConfigToken;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line new-cap,@typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
new (window as any).DocsAPI.DocEditor("onlyoffice-frame", config);
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
|
||||
Reference in New Issue
Block a user