From f5da8de49d9bcabb95c9d1b823934b2cd7866100 Mon Sep 17 00:00:00 2001 From: mlogclub Date: Fri, 24 Apr 2026 22:27:30 +0800 Subject: [PATCH] refactor: remove welcomeText field from WebChannelConfig and related components --- .../controllers/open/im_widget_controller.go | 13 ++++--- internal/pkg/dto/dto.go | 11 +++--- internal/pkg/dto/response/widget_response.go | 13 ++++--- internal/services/channel_service.go | 12 +++---- .../dashboard/channels/_components/edit.tsx | 35 +++++-------------- web/lib/api/im.ts | 1 - web/lib/sdk/cs-ai-agent-sdk.js | 2 +- web/lib/stores/kefu-chat.ts | 3 -- web/public/sdk/cs-ai-agent-sdk.min.js | 2 +- 9 files changed, 33 insertions(+), 59 deletions(-) diff --git a/internal/controllers/open/im_widget_controller.go b/internal/controllers/open/im_widget_controller.go index 56d8cdb..9be6e5a 100644 --- a/internal/controllers/open/im_widget_controller.go +++ b/internal/controllers/open/im_widget_controller.go @@ -24,13 +24,12 @@ func (c *ImWidgetController) AnyConfig() *web.JsonResult { } ret := response.WidgetConfigResponse{ - ChannelID: channel.ChannelID, - Title: cfg.Title, - Subtitle: cfg.Subtitle, - WelcomeText: cfg.WelcomeText, - ThemeColor: cfg.ThemeColor, - Position: cfg.Position, - Width: cfg.Width, + ChannelID: channel.ChannelID, + Title: cfg.Title, + Subtitle: cfg.Subtitle, + ThemeColor: cfg.ThemeColor, + Position: cfg.Position, + Width: cfg.Width, } return web.JsonData(ret) } diff --git a/internal/pkg/dto/dto.go b/internal/pkg/dto/dto.go index 1cfaa98..cc14d13 100644 --- a/internal/pkg/dto/dto.go +++ b/internal/pkg/dto/dto.go @@ -17,10 +17,9 @@ type WxWorkKFChannelConfig struct { } type WebChannelConfig struct { - Title string `json:"title"` - Subtitle string `json:"subtitle"` - WelcomeText string `json:"welcomeText"` - ThemeColor string `json:"themeColor"` - Position string `json:"position"` - Width string `json:"width"` + Title string `json:"title"` + Subtitle string `json:"subtitle"` + ThemeColor string `json:"themeColor"` + Position string `json:"position"` + Width string `json:"width"` } diff --git a/internal/pkg/dto/response/widget_response.go b/internal/pkg/dto/response/widget_response.go index 7b3e505..99b7338 100644 --- a/internal/pkg/dto/response/widget_response.go +++ b/internal/pkg/dto/response/widget_response.go @@ -1,11 +1,10 @@ package response type WidgetConfigResponse struct { - ChannelID string `json:"channelId"` - Title string `json:"title"` - Subtitle string `json:"subtitle"` - WelcomeText string `json:"welcomeText"` - ThemeColor string `json:"themeColor"` - Position string `json:"position"` - Width string `json:"width"` + ChannelID string `json:"channelId"` + Title string `json:"title"` + Subtitle string `json:"subtitle"` + ThemeColor string `json:"themeColor"` + Position string `json:"position"` + Width string `json:"width"` } diff --git a/internal/services/channel_service.go b/internal/services/channel_service.go index 2d5b5be..b4a4126 100644 --- a/internal/services/channel_service.go +++ b/internal/services/channel_service.go @@ -162,12 +162,11 @@ func (s *channelService) ParseWxWorkKFChannelConfig(raw string) (*dto.WxWorkKFCh func (s *channelService) ParseWebChannelConfig(raw string) (*dto.WebChannelConfig, error) { raw = strings.TrimSpace(raw) cfg := &dto.WebChannelConfig{ - Title: "在线客服", - Subtitle: "欢迎咨询", - WelcomeText: "", - ThemeColor: "#2563eb", - Position: "right", - Width: "380px", + Title: "在线客服", + Subtitle: "欢迎咨询", + ThemeColor: "#2563eb", + Position: "right", + Width: "380px", } if raw != "" { if err := json.Unmarshal([]byte(raw), cfg); err != nil { @@ -179,7 +178,6 @@ func (s *channelService) ParseWebChannelConfig(raw string) (*dto.WebChannelConfi cfg.Title = "在线客服" } cfg.Subtitle = strings.TrimSpace(cfg.Subtitle) - cfg.WelcomeText = strings.TrimSpace(cfg.WelcomeText) cfg.ThemeColor = strings.TrimSpace(cfg.ThemeColor) if cfg.ThemeColor == "" { cfg.ThemeColor = "#2563eb" diff --git a/web/app/dashboard/channels/_components/edit.tsx b/web/app/dashboard/channels/_components/edit.tsx index f102d77..e8eab2b 100644 --- a/web/app/dashboard/channels/_components/edit.tsx +++ b/web/app/dashboard/channels/_components/edit.tsx @@ -45,7 +45,6 @@ const widgetPositionOptions = [ type WebChannelConfig = { title?: string subtitle?: string - welcomeText?: string themeColor?: string position?: "left" | "right" width?: string @@ -54,7 +53,6 @@ type WebChannelConfig = { const defaultWebChannelConfig: Required = { title: "在线客服", subtitle: "欢迎咨询", - welcomeText: "", themeColor: "#2563eb", position: "right", width: "380px", @@ -67,7 +65,6 @@ const schema = z.object({ openKfId: z.string().trim(), widgetTitle: z.string().trim(), widgetSubtitle: z.string().trim(), - widgetWelcomeText: z.string().trim(), widgetThemeColor: z.string().trim(), widgetPosition: z.enum(["left", "right"]), widgetWidth: z.string().trim(), @@ -89,7 +86,6 @@ const emptyForm: EditForm = { openKfId: "", widgetTitle: defaultWebChannelConfig.title, widgetSubtitle: defaultWebChannelConfig.subtitle, - widgetWelcomeText: defaultWebChannelConfig.welcomeText, widgetThemeColor: defaultWebChannelConfig.themeColor, widgetPosition: defaultWebChannelConfig.position, widgetWidth: defaultWebChannelConfig.width, @@ -118,7 +114,6 @@ function parseWebChannelConfig(configJson: string): Required { return { title: parsed.title?.trim() || defaultWebChannelConfig.title, subtitle: parsed.subtitle?.trim() ?? defaultWebChannelConfig.subtitle, - welcomeText: parsed.welcomeText?.trim() ?? defaultWebChannelConfig.welcomeText, themeColor: parsed.themeColor?.trim() || defaultWebChannelConfig.themeColor, position, @@ -141,7 +136,6 @@ function buildForm(item: AdminChannel | null): EditForm { openKfId: parseOpenKfId(item.configJson), widgetTitle: widgetConfig.title, widgetSubtitle: widgetConfig.subtitle, - widgetWelcomeText: widgetConfig.welcomeText, widgetThemeColor: widgetConfig.themeColor, widgetPosition: widgetConfig.position, widgetWidth: widgetConfig.width, @@ -157,7 +151,6 @@ function buildPayload(form: EditForm, status: number): CreateAdminChannelPayload : JSON.stringify({ title: form.widgetTitle.trim() || defaultWebChannelConfig.title, subtitle: form.widgetSubtitle.trim(), - welcomeText: form.widgetWelcomeText.trim(), themeColor: form.widgetThemeColor.trim() || defaultWebChannelConfig.themeColor, position: form.widgetPosition || defaultWebChannelConfig.position, @@ -290,7 +283,15 @@ function ChannelFormBody({ ) : (
-
+
+ + 渠道名称 + + + + + + 渠道类型 @@ -333,14 +334,6 @@ function ChannelFormBody({ - - 渠道名称 - - - - - - {channelType === "wxwork_kf" ? ( OpenKfID @@ -418,16 +411,6 @@ function ChannelFormBody({ - - 欢迎语 - - - - -
) : null} diff --git a/web/lib/api/im.ts b/web/lib/api/im.ts index ff2eb63..842dfaf 100644 --- a/web/lib/api/im.ts +++ b/web/lib/api/im.ts @@ -106,7 +106,6 @@ export type ImWidgetConfig = { channelId?: string title?: string subtitle?: string - welcomeText?: string themeColor?: string position?: "left" | "right" width?: string diff --git a/web/lib/sdk/cs-ai-agent-sdk.js b/web/lib/sdk/cs-ai-agent-sdk.js index d37383f..846aac0 100644 --- a/web/lib/sdk/cs-ai-agent-sdk.js +++ b/web/lib/sdk/cs-ai-agent-sdk.js @@ -77,7 +77,7 @@ merged[key] = config[key]; } } - var remoteKeys = ["title", "subtitle", "welcomeText", "themeColor", "position", "width"]; + var remoteKeys = ["title", "subtitle", "themeColor", "position", "width"]; for (var i = 0; i < remoteKeys.length; i += 1) { key = remoteKeys[i]; if ( diff --git a/web/lib/stores/kefu-chat.ts b/web/lib/stores/kefu-chat.ts index bc48dae..33185da 100644 --- a/web/lib/stores/kefu-chat.ts +++ b/web/lib/stores/kefu-chat.ts @@ -118,7 +118,6 @@ function hasMoreAfterLatestSyncMerge(args: { export type KefuChatStore = { title: string subtitle: string - welcomeText: string themeColor: string conversation: ImConversation | null messages: ImMessage[] @@ -300,7 +299,6 @@ export const useKefuChatStore = create((set, get) => { return { title: "在线客服", subtitle: "", - welcomeText: "", themeColor: "#2563eb", conversation: null, messages: [], @@ -350,7 +348,6 @@ export const useKefuChatStore = create((set, get) => { set({ title: widgetConfig.title || "在线客服", subtitle: widgetConfig.subtitle || "", - welcomeText: widgetConfig.welcomeText || "", themeColor: widgetConfig.themeColor || "#2563eb", }) diff --git a/web/public/sdk/cs-ai-agent-sdk.min.js b/web/public/sdk/cs-ai-agent-sdk.min.js index d37383f..846aac0 100644 --- a/web/public/sdk/cs-ai-agent-sdk.min.js +++ b/web/public/sdk/cs-ai-agent-sdk.min.js @@ -77,7 +77,7 @@ merged[key] = config[key]; } } - var remoteKeys = ["title", "subtitle", "welcomeText", "themeColor", "position", "width"]; + var remoteKeys = ["title", "subtitle", "themeColor", "position", "width"]; for (var i = 0; i < remoteKeys.length; i += 1) { key = remoteKeys[i]; if (