From 1ecc04fee7cc4e8d6b3bda4a091d0fd51cb43c25 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Tue, 7 Apr 2026 22:14:20 +0800 Subject: [PATCH] fix(web): chat content labelPosition & markdown support edit --- web/src/components/Chat/ChatContent.tsx | 8 ++--- web/src/components/Markdown/index.tsx | 35 ++++++++++--------- .../ApplicationConfig/TestChat/index.tsx | 4 +-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/web/src/components/Chat/ChatContent.tsx b/web/src/components/Chat/ChatContent.tsx index 4b5a83a8..7ff9f9f5 100644 --- a/web/src/components/Chat/ChatContent.tsx +++ b/web/src/components/Chat/ChatContent.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2025-12-10 16:46:17 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-04-07 21:29:59 + * @Last Modified time: 2026-04-07 22:13:47 */ import { type FC, useRef, useEffect, useState } from 'react' import clsx from 'clsx' @@ -284,7 +284,7 @@ const ChatContent: FC = ({ } {/* Bottom label (such as timestamp, username, etc.) */} - {labelPosition === 'bottom' && + {(labelPosition === 'bottom' || item.meta_data?.audio_url) && {item.meta_data?.audio_url && <> {playingIndex !== item.meta_data?.audio_url && item.meta_data?.audio_status === 'pending' ? @@ -299,9 +299,9 @@ const ChatContent: FC = ({ /> } } -
+ {labelPosition === 'bottom' &&
{labelFormat(item)} -
+
}
} diff --git a/web/src/components/Markdown/index.tsx b/web/src/components/Markdown/index.tsx index 10cf177b..4f48e655 100644 --- a/web/src/components/Markdown/index.tsx +++ b/web/src/components/Markdown/index.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-02 15:17:31 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-04-07 15:14:02 + * @Last Modified time: 2026-04-07 21:56:00 */ /** * RbMarkdown Component @@ -97,47 +97,48 @@ const buildComponents = (onFormSubmit?: (values: Record) => void) = const ctx = useContext(FormContext) return ctx?.onSubmit?.(ctx.values)}>{[children]} }, - input: ({ children, ...props }: any) => { + input: ({ children, value, ...props }: any) => { const ctx = useContext(FormContext) const handleChange = useCallback((val: any) => { if (props.name) ctx?.setValue(props.name, val) }, [ctx, props.name]) + console.log('props', props) switch (props.type) { case 'color': - return + return case 'time': - return + return case 'date': - return + return case 'datetime': case 'datetime-local': - return + return case 'week': - return + return case 'month': - return + return case 'number': - return + return case 'search': - return handleChange(e.target.value)} /> + return handleChange(e.target.value)} /> case 'range': - return + return case 'submit': case 'button': - return ctx?.onSubmit?.(ctx.values)}>{[props.value || children]} + return ctx?.onSubmit?.(ctx.values)}>{[props.value || children]} case 'checkbox': - return handleChange(e.target.checked)}>{children} + return handleChange(e.target.checked)}>{children} case 'password': - return handleChange(e.target.value)} /> + return handleChange(e.target.value)} /> case 'radio': - return handleChange(e.target.value)}>{children} + return handleChange(e.target.value)}>{children} case 'select': { const raw = props['data-options'] const options = (typeof raw === 'string' ? JSON.parse(raw) : raw || []).map((v: string) => ({ label: v, value: v })) - return { if (props.name) ctx?.setValue(props.name, val) }} /> } default: - return handleChange(e.target.value)} /> + return handleChange(e.target.value)} /> } }, select: ({ children, ...props }: any) => { diff --git a/web/src/views/ApplicationConfig/TestChat/index.tsx b/web/src/views/ApplicationConfig/TestChat/index.tsx index 563fb2d4..bfb9b569 100644 --- a/web/src/views/ApplicationConfig/TestChat/index.tsx +++ b/web/src/views/ApplicationConfig/TestChat/index.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-03-13 17:27:52 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-04-07 21:31:19 + * @Last Modified time: 2026-04-07 21:48:30 */ import { type FC, useState, useRef, useEffect } from 'react' import { useTranslation } from 'react-i18next' @@ -95,7 +95,7 @@ const TestChat: FC = ({ useEffect(() => { getVariables() - }, [application, config]) + }, [application, JSON.stringify(config)]) useEffect(() => { return () => {