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:
@@ -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();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* - pnpm start (默认会执行本脚本)
|
||||
*
|
||||
* 依赖环境变量:
|
||||
* - ONLYOFFICE_INTERNAL_URL:可显式指定;未指定或失效时会自动探测 8081/8082
|
||||
* - ONLYOFFICE_INTERNAL_URL:可显式指定;未指定或失效时优先探测 8082,再回退 8081
|
||||
* - CONVEX_INTERNAL_URL:默认 http://127.0.0.1:3210
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,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;
|
||||
|
||||
@@ -93,9 +93,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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user