fix: repair resource tab and slash menu regressions

This commit is contained in:
lix-2026
2026-05-20 17:47:09 +08:00
parent bbd9dab701
commit 4c62ea7e35
8 changed files with 404 additions and 17 deletions
@@ -183,6 +183,24 @@ async function readOnlyOfficeDebug(page) {
});
}
async function assertOnlyOfficeDocumentUrlReachableFromContainer(debug) {
const resolvedFileUrl = String(debug && debug.resolvedFileUrl || "");
assert(resolvedFileUrl.includes("/api/onlyoffice/proxy"), `OnlyOffice resolvedFileUrl 未走 proxy${JSON.stringify(debug)}`);
assert(
/^(http:\/\/host\.docker\.internal:3000|http:\/\/172\.17\.0\.1:3000)/.test(resolvedFileUrl),
`OnlyOffice resolvedFileUrl 应使用 DocumentServer 可回源的 mnote-web 地址:${resolvedFileUrl}`,
);
const { execFile } = require("node:child_process");
const { promisify } = require("node:util");
const execFileAsync = promisify(execFile);
const response = await execFileAsync(
"docker",
["exec", "mnote-onlyoffice-documentserver", "curl", "-fsSI", "--max-time", "10", resolvedFileUrl],
{ timeout: 15_000, maxBuffer: 1024 * 1024 },
);
assert(/HTTP\/[0-9.]+ 200/.test(response.stdout), `DocumentServer 容器无法回源读取文档:${response.stdout}\n${response.stderr}`);
}
async function main() {
const browser = await chromium.launch({ headless: process.env.HEADFUL !== "1" });
const context = await browser.newContext();
@@ -217,6 +235,8 @@ async function main() {
const firstDebug = await readOnlyOfficeDebug(popup);
assert(firstDebug.ready, "OnlyOffice ready flag 应为 true");
assert(firstDebug.frameCount > 0, "OnlyOffice 应创建 iframe/canvas");
assert(firstDebug.debug && firstDebug.debug.documentUrlBase, `OnlyOffice debug 应暴露 documentUrlBase${JSON.stringify(firstDebug)}`);
await assertOnlyOfficeDocumentUrlReachableFromContainer(firstDebug.debug);
assert(
/^[0-9A-Za-z_.=-]{1,128}$/.test(firstDebug.docKey),
`OnlyOffice document.key 不符合安全字符集或长度:${firstDebug.docKey}`,