refactor: update externalName references in widget configuration and SDK
This commit is contained in:
+1
-1
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)}`
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
if (config.position) frameUrl.searchParams.set("position", config.position);
|
||||
if (config.themeColor) frameUrl.searchParams.set("themeColor", config.themeColor);
|
||||
if (config.width) frameUrl.searchParams.set("width", config.width);
|
||||
if (config.subject) frameUrl.searchParams.set("subject", config.subject);
|
||||
if (config.externalName) frameUrl.searchParams.set("externalName", config.externalName);
|
||||
return frameUrl;
|
||||
}
|
||||
|
||||
@@ -360,4 +360,3 @@
|
||||
mount(window.CSAgentConfig);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user