refactor: remove welcomeText field from WebChannelConfig and related components

This commit is contained in:
mlogclub
2026-04-24 22:27:30 +08:00
parent ea94837db2
commit f5da8de49d
9 changed files with 33 additions and 59 deletions
@@ -24,13 +24,12 @@ func (c *ImWidgetController) AnyConfig() *web.JsonResult {
} }
ret := response.WidgetConfigResponse{ ret := response.WidgetConfigResponse{
ChannelID: channel.ChannelID, ChannelID: channel.ChannelID,
Title: cfg.Title, Title: cfg.Title,
Subtitle: cfg.Subtitle, Subtitle: cfg.Subtitle,
WelcomeText: cfg.WelcomeText, ThemeColor: cfg.ThemeColor,
ThemeColor: cfg.ThemeColor, Position: cfg.Position,
Position: cfg.Position, Width: cfg.Width,
Width: cfg.Width,
} }
return web.JsonData(ret) return web.JsonData(ret)
} }
+5 -6
View File
@@ -17,10 +17,9 @@ type WxWorkKFChannelConfig struct {
} }
type WebChannelConfig struct { type WebChannelConfig struct {
Title string `json:"title"` Title string `json:"title"`
Subtitle string `json:"subtitle"` Subtitle string `json:"subtitle"`
WelcomeText string `json:"welcomeText"` ThemeColor string `json:"themeColor"`
ThemeColor string `json:"themeColor"` Position string `json:"position"`
Position string `json:"position"` Width string `json:"width"`
Width string `json:"width"`
} }
+6 -7
View File
@@ -1,11 +1,10 @@
package response package response
type WidgetConfigResponse struct { type WidgetConfigResponse struct {
ChannelID string `json:"channelId"` ChannelID string `json:"channelId"`
Title string `json:"title"` Title string `json:"title"`
Subtitle string `json:"subtitle"` Subtitle string `json:"subtitle"`
WelcomeText string `json:"welcomeText"` ThemeColor string `json:"themeColor"`
ThemeColor string `json:"themeColor"` Position string `json:"position"`
Position string `json:"position"` Width string `json:"width"`
Width string `json:"width"`
} }
+5 -7
View File
@@ -162,12 +162,11 @@ func (s *channelService) ParseWxWorkKFChannelConfig(raw string) (*dto.WxWorkKFCh
func (s *channelService) ParseWebChannelConfig(raw string) (*dto.WebChannelConfig, error) { func (s *channelService) ParseWebChannelConfig(raw string) (*dto.WebChannelConfig, error) {
raw = strings.TrimSpace(raw) raw = strings.TrimSpace(raw)
cfg := &dto.WebChannelConfig{ cfg := &dto.WebChannelConfig{
Title: "在线客服", Title: "在线客服",
Subtitle: "欢迎咨询", Subtitle: "欢迎咨询",
WelcomeText: "", ThemeColor: "#2563eb",
ThemeColor: "#2563eb", Position: "right",
Position: "right", Width: "380px",
Width: "380px",
} }
if raw != "" { if raw != "" {
if err := json.Unmarshal([]byte(raw), cfg); err != nil { if err := json.Unmarshal([]byte(raw), cfg); err != nil {
@@ -179,7 +178,6 @@ func (s *channelService) ParseWebChannelConfig(raw string) (*dto.WebChannelConfi
cfg.Title = "在线客服" cfg.Title = "在线客服"
} }
cfg.Subtitle = strings.TrimSpace(cfg.Subtitle) cfg.Subtitle = strings.TrimSpace(cfg.Subtitle)
cfg.WelcomeText = strings.TrimSpace(cfg.WelcomeText)
cfg.ThemeColor = strings.TrimSpace(cfg.ThemeColor) cfg.ThemeColor = strings.TrimSpace(cfg.ThemeColor)
if cfg.ThemeColor == "" { if cfg.ThemeColor == "" {
cfg.ThemeColor = "#2563eb" cfg.ThemeColor = "#2563eb"
@@ -45,7 +45,6 @@ const widgetPositionOptions = [
type WebChannelConfig = { type WebChannelConfig = {
title?: string title?: string
subtitle?: string subtitle?: string
welcomeText?: string
themeColor?: string themeColor?: string
position?: "left" | "right" position?: "left" | "right"
width?: string width?: string
@@ -54,7 +53,6 @@ type WebChannelConfig = {
const defaultWebChannelConfig: Required<WebChannelConfig> = { const defaultWebChannelConfig: Required<WebChannelConfig> = {
title: "在线客服", title: "在线客服",
subtitle: "欢迎咨询", subtitle: "欢迎咨询",
welcomeText: "",
themeColor: "#2563eb", themeColor: "#2563eb",
position: "right", position: "right",
width: "380px", width: "380px",
@@ -67,7 +65,6 @@ const schema = z.object({
openKfId: z.string().trim(), openKfId: z.string().trim(),
widgetTitle: z.string().trim(), widgetTitle: z.string().trim(),
widgetSubtitle: z.string().trim(), widgetSubtitle: z.string().trim(),
widgetWelcomeText: z.string().trim(),
widgetThemeColor: z.string().trim(), widgetThemeColor: z.string().trim(),
widgetPosition: z.enum(["left", "right"]), widgetPosition: z.enum(["left", "right"]),
widgetWidth: z.string().trim(), widgetWidth: z.string().trim(),
@@ -89,7 +86,6 @@ const emptyForm: EditForm = {
openKfId: "", openKfId: "",
widgetTitle: defaultWebChannelConfig.title, widgetTitle: defaultWebChannelConfig.title,
widgetSubtitle: defaultWebChannelConfig.subtitle, widgetSubtitle: defaultWebChannelConfig.subtitle,
widgetWelcomeText: defaultWebChannelConfig.welcomeText,
widgetThemeColor: defaultWebChannelConfig.themeColor, widgetThemeColor: defaultWebChannelConfig.themeColor,
widgetPosition: defaultWebChannelConfig.position, widgetPosition: defaultWebChannelConfig.position,
widgetWidth: defaultWebChannelConfig.width, widgetWidth: defaultWebChannelConfig.width,
@@ -118,7 +114,6 @@ function parseWebChannelConfig(configJson: string): Required<WebChannelConfig> {
return { return {
title: parsed.title?.trim() || defaultWebChannelConfig.title, title: parsed.title?.trim() || defaultWebChannelConfig.title,
subtitle: parsed.subtitle?.trim() ?? defaultWebChannelConfig.subtitle, subtitle: parsed.subtitle?.trim() ?? defaultWebChannelConfig.subtitle,
welcomeText: parsed.welcomeText?.trim() ?? defaultWebChannelConfig.welcomeText,
themeColor: themeColor:
parsed.themeColor?.trim() || defaultWebChannelConfig.themeColor, parsed.themeColor?.trim() || defaultWebChannelConfig.themeColor,
position, position,
@@ -141,7 +136,6 @@ function buildForm(item: AdminChannel | null): EditForm {
openKfId: parseOpenKfId(item.configJson), openKfId: parseOpenKfId(item.configJson),
widgetTitle: widgetConfig.title, widgetTitle: widgetConfig.title,
widgetSubtitle: widgetConfig.subtitle, widgetSubtitle: widgetConfig.subtitle,
widgetWelcomeText: widgetConfig.welcomeText,
widgetThemeColor: widgetConfig.themeColor, widgetThemeColor: widgetConfig.themeColor,
widgetPosition: widgetConfig.position, widgetPosition: widgetConfig.position,
widgetWidth: widgetConfig.width, widgetWidth: widgetConfig.width,
@@ -157,7 +151,6 @@ function buildPayload(form: EditForm, status: number): CreateAdminChannelPayload
: JSON.stringify({ : JSON.stringify({
title: form.widgetTitle.trim() || defaultWebChannelConfig.title, title: form.widgetTitle.trim() || defaultWebChannelConfig.title,
subtitle: form.widgetSubtitle.trim(), subtitle: form.widgetSubtitle.trim(),
welcomeText: form.widgetWelcomeText.trim(),
themeColor: themeColor:
form.widgetThemeColor.trim() || defaultWebChannelConfig.themeColor, form.widgetThemeColor.trim() || defaultWebChannelConfig.themeColor,
position: form.widgetPosition || defaultWebChannelConfig.position, position: form.widgetPosition || defaultWebChannelConfig.position,
@@ -290,7 +283,15 @@ function ChannelFormBody({
</div> </div>
) : ( ) : (
<form id={formId} onSubmit={handleSubmit(onFormSubmit)} className="space-y-4"> <form id={formId} onSubmit={handleSubmit(onFormSubmit)} className="space-y-4">
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2"> <div className="grid grid-cols-1 gap-4 sm:grid-cols-1">
<Field data-invalid={!!errors.name}>
<FieldLabel htmlFor="channel-name"></FieldLabel>
<FieldContent>
<Input id="channel-name" {...register("name")} />
<FieldError errors={[errors.name]} />
</FieldContent>
</Field>
<Field data-invalid={!!errors.channelType}> <Field data-invalid={!!errors.channelType}>
<FieldLabel></FieldLabel> <FieldLabel></FieldLabel>
<FieldContent> <FieldContent>
@@ -333,14 +334,6 @@ function ChannelFormBody({
</FieldContent> </FieldContent>
</Field> </Field>
<Field data-invalid={!!errors.name}>
<FieldLabel htmlFor="channel-name"></FieldLabel>
<FieldContent>
<Input id="channel-name" {...register("name")} />
<FieldError errors={[errors.name]} />
</FieldContent>
</Field>
{channelType === "wxwork_kf" ? ( {channelType === "wxwork_kf" ? (
<Field data-invalid={!!errors.openKfId}> <Field data-invalid={!!errors.openKfId}>
<FieldLabel htmlFor="channel-open-kf-id">OpenKfID</FieldLabel> <FieldLabel htmlFor="channel-open-kf-id">OpenKfID</FieldLabel>
@@ -418,16 +411,6 @@ function ChannelFormBody({
</FieldContent> </FieldContent>
</Field> </Field>
<Field data-invalid={!!errors.widgetWelcomeText}>
<FieldLabel htmlFor="channel-widget-welcome-text"></FieldLabel>
<FieldContent>
<Input
id="channel-widget-welcome-text"
{...register("widgetWelcomeText")}
/>
<FieldError errors={[errors.widgetWelcomeText]} />
</FieldContent>
</Field>
</div> </div>
) : null} ) : null}
-1
View File
@@ -106,7 +106,6 @@ export type ImWidgetConfig = {
channelId?: string channelId?: string
title?: string title?: string
subtitle?: string subtitle?: string
welcomeText?: string
themeColor?: string themeColor?: string
position?: "left" | "right" position?: "left" | "right"
width?: string width?: string
+1 -1
View File
@@ -77,7 +77,7 @@
merged[key] = config[key]; 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) { for (var i = 0; i < remoteKeys.length; i += 1) {
key = remoteKeys[i]; key = remoteKeys[i];
if ( if (
-3
View File
@@ -118,7 +118,6 @@ function hasMoreAfterLatestSyncMerge(args: {
export type KefuChatStore = { export type KefuChatStore = {
title: string title: string
subtitle: string subtitle: string
welcomeText: string
themeColor: string themeColor: string
conversation: ImConversation | null conversation: ImConversation | null
messages: ImMessage[] messages: ImMessage[]
@@ -300,7 +299,6 @@ export const useKefuChatStore = create<KefuChatStore>((set, get) => {
return { return {
title: "在线客服", title: "在线客服",
subtitle: "", subtitle: "",
welcomeText: "",
themeColor: "#2563eb", themeColor: "#2563eb",
conversation: null, conversation: null,
messages: [], messages: [],
@@ -350,7 +348,6 @@ export const useKefuChatStore = create<KefuChatStore>((set, get) => {
set({ set({
title: widgetConfig.title || "在线客服", title: widgetConfig.title || "在线客服",
subtitle: widgetConfig.subtitle || "", subtitle: widgetConfig.subtitle || "",
welcomeText: widgetConfig.welcomeText || "",
themeColor: widgetConfig.themeColor || "#2563eb", themeColor: widgetConfig.themeColor || "#2563eb",
}) })
+1 -1
View File
@@ -77,7 +77,7 @@
merged[key] = config[key]; 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) { for (var i = 0; i < remoteKeys.length; i += 1) {
key = remoteKeys[i]; key = remoteKeys[i];
if ( if (