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{
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)
}
+5 -6
View File
@@ -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"`
}
+6 -7
View File
@@ -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"`
}
+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) {
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"
@@ -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<WebChannelConfig> = {
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<WebChannelConfig> {
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({
</div>
) : (
<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}>
<FieldLabel></FieldLabel>
<FieldContent>
@@ -333,14 +334,6 @@ function ChannelFormBody({
</FieldContent>
</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" ? (
<Field data-invalid={!!errors.openKfId}>
<FieldLabel htmlFor="channel-open-kf-id">OpenKfID</FieldLabel>
@@ -418,16 +411,6 @@ function ChannelFormBody({
</FieldContent>
</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>
) : null}
-1
View File
@@ -106,7 +106,6 @@ export type ImWidgetConfig = {
channelId?: string
title?: string
subtitle?: string
welcomeText?: string
themeColor?: string
position?: "left" | "right"
width?: string
+1 -1
View File
@@ -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 (
-3
View File
@@ -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<KefuChatStore>((set, get) => {
return {
title: "在线客服",
subtitle: "",
welcomeText: "",
themeColor: "#2563eb",
conversation: null,
messages: [],
@@ -350,7 +348,6 @@ export const useKefuChatStore = create<KefuChatStore>((set, get) => {
set({
title: widgetConfig.title || "在线客服",
subtitle: widgetConfig.subtitle || "",
welcomeText: widgetConfig.welcomeText || "",
themeColor: widgetConfig.themeColor || "#2563eb",
})
+1 -1
View File
@@ -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 (