'use client'; import Form, { FormItem } from '@/components/ui/radix-form'; import React from 'react'; import { cn } from '@/lib'; import { Select, Switch, Number, FontSize } from '@/components/ui/inputs'; import Background from './Background'; import { AddIcon } from '@/assets/common'; import ModelSelectDialog from '@/components/feature/ModelSelectDialog'; import VoiceActorSelectDialog from '@/components/feature/VoiceActorSelectDialog'; import BubbleSelectDialog from '@/components/feature/BubbleSelectDialog'; import IconFont from '@/components/ui/iconFont'; // 表单数据类型定义 type SettingFormValues = { model?: string; short_text?: boolean; voiceActor?: string; dialogueOnly?: boolean; max_tokens?: number; fontSize?: number; chat_mode?: string; chat_bubble?: string; background?: string; }; const Title: React.FC< { text?: string; children?: React.ReactNode; } & React.HTMLAttributes > = (props) => { const { text, children, ...rest } = props; return (
{text}
{children}
); }; const SettingForm = React.memo(() => { return (
Setting
onChange={(values) => { console.log(values); }} > <FormItem<SettingFormValues> name="model" render={({ value, onChange }) => ( <ModelSelectDialog value={value} onChange={onChange} /> )} /> <FormItem<SettingFormValues> name="short_text" render={({ value, onChange }) => ( <Switch icon={'/character/model_long_text.svg'} text="Short Text Mode" value={value} onChange={onChange} /> )} /> <FormItem<SettingFormValues> name="voiceActor" render={({ value, onChange }) => ( <VoiceActorSelectDialog value={value} onChange={onChange} /> )} /> <FormItem<SettingFormValues> name="dialogueOnly" render={({ value, onChange }) => ( <Switch icon={'/character/play_dialogue_only.svg'} text="Play dialogue only" value={value} onChange={onChange} /> )} /> <FormItem<SettingFormValues> name="max_tokens" render={({ value, onChange }) => ( <Number value={value} onChange={onChange} /> )} /> <FormItem<SettingFormValues> name="fontSize" render={({ value, onChange }) => { return <FontSize value={value} onChange={onChange} />; }} /> <FormItem<SettingFormValues> name="chat_mode" render={({ value, onChange }) => ( <Select value={value} onChange={onChange} placeholder="Chat Mode" icon={'/character/chat_mode.svg'} options={[ { label: 'Chat Mode', value: 'chat_mode' }, { label: 'Chat Bubble', value: 'chat_bubble' }, ]} /> )} /> {/* TODO: BubbleSelectDialog 需要支持受控模式 */} <div> <BubbleSelectDialog /> </div> <FormItem<SettingFormValues> name="background" render={({ value, onChange }) => ( <Background value={value} onChange={onChange} /> )} />
Delete
START NEW CHAT
); }); export default SettingForm;