feat: 接入 mnote web tree shell 与主页链路整理

- 增加 mnote-web tree/command 支持与前端 MnoteWebTreeShell 集成
- 调整 sidebar、documents、runtime config 与 dev/prod server 配套逻辑
- 补充 homepage/tree shell smoke 脚本并更新 harness 进度文件
This commit is contained in:
lix-2026
2026-04-17 23:36:24 +08:00
parent cfc3af8984
commit d8de820d93
40 changed files with 4668 additions and 4143 deletions
+28 -17
View File
@@ -9,7 +9,7 @@
* - node scripts/dev-server.js -p 3000
*
* 依赖环境变量:
* - ONLYOFFICE_INTERNAL_URL:可显式指定;未指定或失效时会自动探测 8081/8082
* - ONLYOFFICE_INTERNAL_URL:可显式指定;未指定或失效时优先探测 8082,再回退 8081
*/
const http = require("http");
@@ -20,7 +20,7 @@ const { parse: parseUrl } = require("url");
const ONLYOFFICE_PREFIX = "/onlyoffice-server";
const CONVEX_PREFIX = "/convex";
const DEFAULT_ONLYOFFICE_INTERNAL_URL = "http://127.0.0.1:8081";
const DEFAULT_ONLYOFFICE_INTERNAL_URL = "http://127.0.0.1:8082";
const ONLYOFFICE_PROBE_PATH = "/web-apps/apps/api/documents/api.js";
const ONLYOFFICE_RESOLVE_CACHE_TTL_MS = 30_000;
@@ -92,9 +92,9 @@ function listOnlyOfficeInternalUrlCandidates() {
}
push(DEFAULT_ONLYOFFICE_INTERNAL_URL);
push("http://127.0.0.1:8082");
push("http://localhost:8081");
push("http://127.0.0.1:8081");
push("http://localhost:8082");
push("http://localhost:8081");
return candidates.length > 0 ? candidates : [DEFAULT_ONLYOFFICE_INTERNAL_URL];
}
@@ -313,12 +313,12 @@ function proxyConvexUpgrade(req, socket, head) {
socket.on("error", onError);
}
function proxyConvexHttp(req, res) {
const target = resolveConvexInternalUrl();
const incoming = new URL(req.url || "/", "http://localhost");
const rawPath = incoming.pathname || "/";
const stripped = rawPath === CONVEX_PREFIX ? "/" : rawPath.slice(CONVEX_PREFIX.length) || "/";
const upstreamPath = stripped + (incoming.search || "");
function proxyConvexHttp(req, res) {
const target = resolveConvexInternalUrl();
const incoming = new URL(req.url || "/", "http://localhost");
const rawPath = incoming.pathname || "/";
const stripped = rawPath === CONVEX_PREFIX ? "/" : rawPath.slice(CONVEX_PREFIX.length) || "/";
const upstreamPath = stripped + (incoming.search || "");
const isHttps = target.protocol === "https:";
const mod = isHttps ? require("https") : require("http");
@@ -359,19 +359,30 @@ function proxyConvexHttp(req, res) {
},
);
upstreamReq.on("error", (err) => {
upstreamReq.on("error", (err) => {
try {
console.log("[dev-server][convex-http] proxy error", err && err.message ? err.message : String(err || ""));
} catch {}
try {
res.statusCode = 502;
res.end("Bad Gateway");
} catch {}
});
req.pipe(upstreamReq);
}
res.end("Bad Gateway");
} catch {}
});
const method = String(req.method || "GET").toUpperCase();
const hasBody =
!["GET", "HEAD"].includes(method) &&
((typeof req.headers["content-length"] === "string" && req.headers["content-length"] !== "0") ||
String(req.headers["transfer-encoding"] || "").trim().length > 0);
if (!hasBody) {
upstreamReq.end();
return;
}
req.pipe(upstreamReq);
}
async function main() {
const port = resolvePort();