Интегрирован wesp в сайт
CI / quality (push) Canceled after 0s

This commit is contained in:
влад
2026-07-17 12:57:18 +03:00
parent 5dfa06ddbe
commit 355c0ef9f1
883 changed files with 194576 additions and 177 deletions
+24 -1
View File
@@ -31,6 +31,9 @@ const WESP_PAGE_ROUTES: Record<string, string> = {
};
function injectOrchestratorScripts(html: string, urlPath: string): string {
const favicon =
'<link rel="icon" href="/favicon.svg" type="image/svg+xml">\n' +
'<link rel="icon" href="/favicon-32.png" type="image/png" sizes="32x32">';
const scripts =
urlPath === "/login"
? [
@@ -41,8 +44,11 @@ function injectOrchestratorScripts(html: string, urlPath: string): string {
'<script src="/static/js/wesp-orchestrator-auth-bridge.js"></script>',
'<script src="/static/js/wesp-orchestrator-boot.js"></script>',
];
const block = scripts.join("\n");
const block = [favicon, ...scripts].join("\n");
if (html.includes("wesp-orchestrator-auth-bridge.js")) {
if (!html.includes('rel="icon"') && html.includes("</head>")) {
return html.replace("</head>", `${favicon}\n</head>`);
}
return html;
}
if (html.includes("</head>")) {
@@ -85,6 +91,23 @@ function createWespMiddleware(root: string): Connect.NextHandleFunction {
return;
}
if (urlPath === "/favicon.ico") {
const pngPath = resolve(root, "favicon-32.png");
if (existsSync(pngPath) && statSync(pngPath).isFile()) {
res.setHeader("Content-Type", "image/png");
sendFile(res, pngPath);
return;
}
}
if (urlPath === "/favicon.svg") {
const svgPath = resolve(root, "favicon.svg");
if (existsSync(svgPath) && statSync(svgPath).isFile()) {
res.setHeader("Content-Type", "image/svg+xml");
sendFile(res, svgPath);
return;
}
}
const pageFile = WESP_PAGE_ROUTES[urlPath];
if (pageFile) {
const htmlPath = resolve(root, pageFile);