refactor: update externalName references in widget configuration and SDK

This commit is contained in:
mlogclub
2026-04-27 16:51:13 +08:00
parent cd9de63860
commit bc98fc572f
6 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ function getRuntimeImConfig() {
externalSource:
(widgetConfig.externalSource || OPEN_IM_EXTERNAL_SOURCE).trim() || "web_chat",
externalId: (widgetConfig.externalId || "").trim(),
externalName: (widgetConfig.subject || "").trim(),
externalName: (widgetConfig.externalName || "").trim(),
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ export function createImRealtimeConnection() {
(config.externalSource ?? "web_chat").trim() || "web_chat"
)
const channelId = encodeURIComponent(config.channelId || "")
const externalName = (config.subject ?? "").trim()
const externalName = (config.externalName ?? "").trim()
const nameQuery =
externalName !== ""
? `&externalName=${encodeURIComponent(externalName)}`
+3 -3
View File
@@ -6,13 +6,13 @@ export type KefuWidgetHostConfig = {
externalSource?: string
/** 外部访客稳定标识;未传时使用浏览器本地访客 ID */
externalId?: string
/** 访客展示名,随请求以 X-External-Name / WS query externalName 传给后端 */
externalName?: string
title?: string
subtitle?: string
position?: "left" | "right"
themeColor?: string
width?: string
/** 访客展示名,随请求以 X-External-Name / WS query externalName 传给后端 */
subject?: string
}
declare global {
@@ -51,12 +51,12 @@ export function readKefuWidgetConfig(): KefuWidgetHostConfig {
process.env.NEXT_PUBLIC_OPEN_IM_EXTERNAL_SOURCE?.trim() ??
undefined,
externalId: query.get("externalId") ?? undefined,
externalName: query.get("externalName") ?? undefined,
title: query.get("title") ?? undefined,
subtitle: query.get("subtitle") ?? undefined,
position: (query.get("position") as "left" | "right" | null) ?? undefined,
themeColor: query.get("themeColor") ?? undefined,
width: query.get("width") ?? undefined,
subject: query.get("subject") ?? undefined,
}
return window.__CS_AGENT_WIDGET_CONFIG__ ?? window.CSAgentConfig ?? fallback
+1 -1
View File
@@ -66,7 +66,7 @@
frameUrl.searchParams.set("baseUrl", config.baseUrl);
if (config.apiBaseUrl) frameUrl.searchParams.set("apiBaseUrl", config.apiBaseUrl);
if (config.externalSource) frameUrl.searchParams.set("externalSource", config.externalSource);
if (config.subject) frameUrl.searchParams.set("subject", config.subject);
if (config.externalName) frameUrl.searchParams.set("externalName", config.externalName);
return frameUrl;
}