This commit is contained in:
董宏凯 committed 2026-08-14 11:15:37 +08:00
commit c4d244881f
14 files changed
+1194 -107

No files matched your search

@@ -55,6 +55,23 @@ function postThemeToFrame(frame: HTMLIFrameElement | null) {
frame.contentWindow.postMessage(collectThemePayload(), targetOrigin);
}
const WEKNORA_BACKEND_PREFIX = "/deerflow";
function buildFrameUrl(framePath: string) {
const backendBase = getBackendBaseURL().replace(/\/+$/, "");
const backendOrigin = backendBase
? new URL(backendBase, window.location.origin).origin
: window.location.origin;
if (/^https?:\/\//i.test(framePath)) return new URL(framePath);
if (framePath.startsWith("/")) {
const path = !framePath.startsWith(`${WEKNORA_BACKEND_PREFIX}/`)
? `${WEKNORA_BACKEND_PREFIX}${framePath}`
: framePath;
return new URL(path, backendOrigin);
}
return new URL(`${backendBase || backendOrigin}/${framePath.replace(/^\/+/, "")}`);
}
export function WeKnoraKnowledgeDetailPage() {
const {
knowledge_base_id: strategyKnowledgeBaseId,
@@ -87,11 +104,8 @@ export function WeKnoraKnowledgeDetailPage() {
void createLlmWikiWeKnoraEmbedSession(knowledgeBaseId, preferredTab)
.then((session) => {
if (cancelled) return;
const base = getBackendBaseURL().replace(/\/+$/, "");
const path = session.frame_path.startsWith("/")
? session.frame_path
: `/${session.frame_path}`;
const nextUrl = new URL(`${base}${path}`);
const framePath = session.frame_path || "";
const nextUrl = buildFrameUrl(framePath);
nextUrl.searchParams.set("theme", collectThemePayload().theme);
setFrameSrc(nextUrl.toString());
})
+28 -28
View File
@@ -5,22 +5,22 @@ import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import sourceIdentifierPlugin from "vite-plugin-source-identifier";
const rootDir = fileURLToPath(new URL(".", import.meta.url));
// Tailwind 4 emits CSS cascade layers, which require Chrome 99+. Chrome 100
// is therefore the practical lower bound for this Win7 legacy build.
const LEGACY_CHROME = 100 << 16;
const rootDir = fileURLToPath(new URL(".", import.meta.url));
// Tailwind 4 emits CSS cascade layers, which require Chrome 99+. Chrome 100
// is therefore the practical lower bound for this Win7 legacy build.
const LEGACY_CHROME = 100 << 16;
export default defineConfig({
plugins: [sourceIdentifierPlugin(), react()],
css: {
// Also used by the production CSS minifier. Development CSS is handled
// by the matching PostCSS compatibility pass in postcss.config.js.
lightningcss: {
targets: {
chrome: LEGACY_CHROME,
},
},
},
export default defineConfig({
plugins: [sourceIdentifierPlugin(), react()],
css: {
// Also used by the production CSS minifier. Development CSS is handled
// by the matching PostCSS compatibility pass in postcss.config.js.
lightningcss: {
targets: {
chrome: LEGACY_CHROME,
},
},
},
resolve: {
alias: [
{
@@ -45,19 +45,19 @@ export default defineConfig({
},
],
},
// Keep the current portable-file default, while allowing container builds to
// emit absolute asset URLs. The latter is required for BrowserRouter pages
// behind Nginx: a request to /page/... must still load /assets/... rather
// than /page/assets/....
base: process.env.VITE_ASSET_BASE ?? "./",
build: {
cssMinify: "lightningcss",
target: "chrome100",
},
// Keep the current portable-file default, while allowing container builds to
// emit absolute asset URLs. The latter is required for BrowserRouter pages
// behind Nginx: a request to /page/... must still load /assets/... rather
// than /page/assets/....
base: process.env.VITE_ASSET_BASE ?? "./",
build: {
cssMinify: "lightningcss",
target: "chrome100",
},
server: {
// 与 scripts/env.sh FRONTEND_PORT=5174、圆桌 wujie 嵌入文档一致。
port: 5173,
// 无界宿主跨域 fetch 子应用静态资源时,Vite 需回显请求的 Origin。
cors: true,
// 与 scripts/env.sh FRONTEND_PORT=5174、圆桌 wujie 嵌入文档一致。
port: 5173,
// 无界宿主跨域 fetch 子应用静态资源时,Vite 需回显请求的 Origin。
cors: true,
},
});