feat(embed): add widget, visitor chat, and management UI (#1657)

Add embed.html entrypoint, floating widget SDK, secure-mode snippets,
management panel with preview, visitor chat composables, citation rendering,
and integration docs for subdomain and server-side token exchange.
This commit is contained in:
wizardchen
2026-06-12 22:40:18 +08:00
committed by lyingbug
parent ed9802ff2b
commit 08852ab19d
41 changed files with 10186 additions and 745 deletions
+24
View File
@@ -0,0 +1,24 @@
/** Resolve the public origin used in embed iframe / widget URLs. */
export function resolveEmbedBaseUrl(): string {
if (typeof window === 'undefined') return ''
const runtime = (window as Window & { __RUNTIME_CONFIG__?: { EMBED_BASE_URL?: string } }).__RUNTIME_CONFIG__
const fromRuntime = runtime?.EMBED_BASE_URL?.trim()
if (fromRuntime) {
try {
const u = new URL(fromRuntime, window.location.href)
if (u.protocol === 'http:' || u.protocol === 'https:') return u.origin
} catch {
// fall through
}
}
const fromEnv = import.meta.env.VITE_EMBED_BASE_URL?.trim()
if (fromEnv) {
try {
const u = new URL(fromEnv, window.location.href)
if (u.protocol === 'http:' || u.protocol === 'https:') return u.origin
} catch {
// fall through
}
}
return window.location.origin
}