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
@@ -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 (