From 9353053a238dd57f191ddceb273dc7b0d7b5441b Mon Sep 17 00:00:00 2001 From: zhaoying Date: Mon, 19 Jan 2026 14:08:31 +0800 Subject: [PATCH 1/3] feat(web): extract and replace Switch Form components --- web/src/components/FormItem/DescWrapper.tsx | 12 +++++ web/src/components/FormItem/LabelWrapper.tsx | 13 ++++++ .../components/FormItem/SwitchFormItem.tsx | 45 +++++++++++++++++++ web/src/views/EmotionEngine/index.tsx | 25 +++++------ web/src/views/ForgettingEngine/index.tsx | 31 ++++--------- .../views/MemoryExtractionEngine/index.tsx | 22 ++++----- web/src/views/SelfReflectionEngine/index.tsx | 24 +++++----- 7 files changed, 106 insertions(+), 66 deletions(-) create mode 100644 web/src/components/FormItem/DescWrapper.tsx create mode 100644 web/src/components/FormItem/LabelWrapper.tsx create mode 100644 web/src/components/FormItem/SwitchFormItem.tsx diff --git a/web/src/components/FormItem/DescWrapper.tsx b/web/src/components/FormItem/DescWrapper.tsx new file mode 100644 index 00000000..300fc2b6 --- /dev/null +++ b/web/src/components/FormItem/DescWrapper.tsx @@ -0,0 +1,12 @@ +import clsx from "clsx"; +import type { FC, ReactNode } from "react"; + +const DescWrapper: FC<{desc: string | ReactNode, className?: string}> = ({desc, className}) => { + return ( +
+ {desc} +
+ ) +} + +export default DescWrapper \ No newline at end of file diff --git a/web/src/components/FormItem/LabelWrapper.tsx b/web/src/components/FormItem/LabelWrapper.tsx new file mode 100644 index 00000000..461250d8 --- /dev/null +++ b/web/src/components/FormItem/LabelWrapper.tsx @@ -0,0 +1,13 @@ +import clsx from "clsx"; +import type { FC, ReactNode } from "react"; + +const LabelWrapper: FC<{ title: string | ReactNode, className?: string; children?: ReactNode}> = ({title, className, children}) => { + return ( +
+
{title}
+ {children} +
+ ) +} + +export default LabelWrapper \ No newline at end of file diff --git a/web/src/components/FormItem/SwitchFormItem.tsx b/web/src/components/FormItem/SwitchFormItem.tsx new file mode 100644 index 00000000..e17a8728 --- /dev/null +++ b/web/src/components/FormItem/SwitchFormItem.tsx @@ -0,0 +1,45 @@ +import { Switch, Form, ConfigProvider } from "antd"; +import useSize from 'antd/lib/config-provider/hooks/useSize' +import type { FC, ReactNode } from "react"; +import { useContext } from "react"; + +import LabelWrapper from './LabelWrapper' +import DescWrapper from './DescWrapper' + +interface SwitchFormItemProps { + title: string | ReactNode; + desc?: string | ReactNode; + name: string | string[]; + size?: 'small' | 'default' + className?: string; + disabled?: boolean; +} + +const SwitchFormItem: FC = ({ + title, + desc, + name, + size = 'default', + className, + disabled +}) => { + const componentSize = useSize() + console.log('componentSize', componentSize) + + return ( +
+ + {desc && } + + + + +
+ ) +} + +export default SwitchFormItem \ No newline at end of file diff --git a/web/src/views/EmotionEngine/index.tsx b/web/src/views/EmotionEngine/index.tsx index ae1cd4c6..73bfd376 100644 --- a/web/src/views/EmotionEngine/index.tsx +++ b/web/src/views/EmotionEngine/index.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Row, Col, Form, Slider, Button, Alert, message, Switch, Space } from 'antd'; +import { Row, Col, Form, Slider, Button, Alert, message, Space } from 'antd'; import { useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import RbCard from '@/components/RbCard/Card'; @@ -9,6 +9,7 @@ import type { ConfigForm } from './types' import CustomSelect from '@/components/CustomSelect'; import { getModelListUrl } from '@/api/models' import Tag from '@/components/Tag' +import SwitchFormItem from '@/components/FormItem/SwitchFormItem' const configList = [ { @@ -158,23 +159,17 @@ const EmotionEngine: React.FC = () => { ) } - return ( -
-
- {t(`emotionEngine.${config.key}`)} + {config.hasSubTitle &&
{t(`emotionEngine.${config.key}_subTitle`)}
}
{t(`emotionEngine.${config.key}_desc`)}
-
- - - -
+ } + className="rb:mb-6" + disabled={!values?.emotion_enabled && config.key !== 'emotion_enabled'} + /> ) })} diff --git a/web/src/views/ForgettingEngine/index.tsx b/web/src/views/ForgettingEngine/index.tsx index fed71da1..05745b4b 100644 --- a/web/src/views/ForgettingEngine/index.tsx +++ b/web/src/views/ForgettingEngine/index.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Row, Col, Form, Slider, Button, Space, message, Switch } from 'antd'; +import { Row, Col, Form, Slider, Button, Space, message } from 'antd'; import { useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import RbCard from '@/components/RbCard/Card'; @@ -7,6 +7,7 @@ import strategyImpactSimulator from '@/assets/images/memory/strategyImpactSimula import LineChart from './components/LineChart' import { getMemoryForgetConfig, updateMemoryForgetConfig } from '@/api/memory' import type { ConfigForm } from './types' +import SwitchFormItem from '@/components/FormItem/SwitchFormItem' const configList = [ { @@ -155,26 +156,12 @@ const ForgettingEngine: React.FC = () => { {configList.map(config => { if (config.type === 'button') { return ( -
-
-
- {t(`forgettingEngine.${config.key}`)} -
- - - -
-
- - {config.range && {t(`forgettingEngine.range`)}: {config.range?.join('-')}} - {config.type && {t(`forgettingEngine.type`)}: {config.type}} - -
-
+ {t(`forgettingEngine.type`)}: {config.type}} + className="rb:mb-2" + /> ) } return ( @@ -191,8 +178,6 @@ const ForgettingEngine: React.FC = () => { > {config.type === 'decimal' ? - : config.type === 'button' - ? : null } diff --git a/web/src/views/MemoryExtractionEngine/index.tsx b/web/src/views/MemoryExtractionEngine/index.tsx index adade5da..3d67270c 100644 --- a/web/src/views/MemoryExtractionEngine/index.tsx +++ b/web/src/views/MemoryExtractionEngine/index.tsx @@ -11,6 +11,7 @@ import { getModelList } from '@/api/models'; import type { Model } from '@/views/ModelManagement/types' import { configList } from './constant' import Result from './components/Result' +import SwitchFormItem from '@/components/FormItem/SwitchFormItem' const keys = [ // 'example', @@ -173,25 +174,18 @@ const MemoryExtractionEngine: FC = () => { } )} > -
{t(`memoryExtractionEngine.${vo.title}`)}
+
{t(`memoryExtractionEngine.${vo.title}`)}
{t(`memoryExtractionEngine.${vo.title}SubTitle`)}
{vo.list.map(config => (
{config.control === 'button' && -
-
- -{t(`memoryExtractionEngine.${config.label}`)} - -
- - - -
+ -{t(`memoryExtractionEngine.${config.label}`)}} + name={config.variableName} + desc={} + className="rb:mt-6" + /> } {config.control === 'select' && <> diff --git a/web/src/views/SelfReflectionEngine/index.tsx b/web/src/views/SelfReflectionEngine/index.tsx index 952450b2..784f066c 100644 --- a/web/src/views/SelfReflectionEngine/index.tsx +++ b/web/src/views/SelfReflectionEngine/index.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Row, Col, Form, App, Button, Switch, Space, Select } from 'antd'; +import { Row, Col, Form, App, Button, Space, Select } from 'antd'; import { useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; @@ -11,6 +11,7 @@ import CustomSelect from '@/components/CustomSelect'; import { getModelListUrl } from '@/api/models' import Tag from '@/components/Tag' import { useI18n } from '@/store/locale'; +import SwitchFormItem from '@/components/FormItem/SwitchFormItem' const configList = [ // 启用反思引擎 @@ -219,21 +220,16 @@ const SelfReflectionEngine: React.FC = () => { } return ( -
-
- {t(`reflectionEngine.${config.key}`)} + {(config as any).hasSubTitle &&
{t(`reflectionEngine.${config.key}_subTitle`)}
}
{t(`reflectionEngine.${config.key}_desc`)}
-
- - - -
+ } + className="rb:mb-6" + disabled={!values?.reflection_enabled && config.key !== 'reflection_enabled'} + /> ) })} From 2891f2c0680d4c0becb6d806f36881dbe2acfd47 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Mon, 19 Jan 2026 14:10:29 +0800 Subject: [PATCH 2/3] feat(web): markdown support copy --- web/src/components/Markdown/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/src/components/Markdown/index.tsx b/web/src/components/Markdown/index.tsx index d16b72e4..58650207 100644 --- a/web/src/components/Markdown/index.tsx +++ b/web/src/components/Markdown/index.tsx @@ -150,9 +150,19 @@ const RbMarkdown: FC = ({ ) } + // 处理键盘快捷键 + const handleKeyDown = (e: React.KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'c') { + const selection = window.getSelection() + if (selection && selection.toString()) { + navigator.clipboard.writeText(selection.toString()) + } + } + } + // 预览模式 return ( -
+