diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index c4f90f4..3c087e0 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -1,5 +1,5 @@ import type { Message } from 'ai'; -import React, { type RefCallback } from 'react'; +import React, { type RefCallback, useState } from 'react'; import { ClientOnly } from 'remix-utils/client-only'; import { Menu } from '~/components/sidebar/Menu.client'; import { IconButton } from '~/components/ui/IconButton'; @@ -7,6 +7,8 @@ import { Workbench } from '~/components/workbench/Workbench.client'; import { classNames } from '~/utils/classNames'; import { Messages } from './Messages.client'; import { SendButton } from './SendButton.client'; +import { TemplateSelector } from '~/components/workbench/TemplateSelector'; +import { type TemplateName } from '~/utils/templates'; import styles from './BaseChat.module.scss'; @@ -28,11 +30,11 @@ interface BaseChatProps { } const EXAMPLE_PROMPTS = [ - { text: 'Build a todo app in React using Tailwind' }, - { text: 'Build a simple blog using Astro' }, - { text: 'Create a cookie consent form using Material UI' }, - { text: 'Make a space invaders game' }, - { text: 'How do I center a div?' }, + { text: '使用 React 和 Tailwind 构建一个待办事项应用' }, + { text: '使用 Astro 构建一个简单的博客' }, + { text: '使用 Material UI 创建一个 cookie 同意表单' }, + { text: '制作一个太空入侵者游戏' }, + { text: '如何让一个 div 居中?' }, ]; const TEXTAREA_MIN_HEIGHT = 76; @@ -58,6 +60,18 @@ export const BaseChat = React.forwardRef( ref, ) => { const TEXTAREA_MAX_HEIGHT = chatStarted ? 400 : 200; + const [selectedTemplate, setSelectedTemplate] = useState('basic'); + + const handleTemplateChange = async (templateName: TemplateName) => { + setSelectedTemplate(templateName); + try { + console.log('templateName', templateName); + // await workbenchStore.changeTemplate(templateName); + } catch (error) { + console.error('Failed to change template:', error); + // 可以在这里添加错误处理,比如显示一个错误提示 + } + }; return (
( {!chatStarted && (

- Where ideas begin + 创意的起点

- Bring ideas to life in seconds or get help on existing projects. + 在几秒钟内将想法变为现实,或获取现有项目的帮助。

+ + {() =>
123
}
)}
( minHeight: TEXTAREA_MIN_HEIGHT, maxHeight: TEXTAREA_MAX_HEIGHT, }} - placeholder="How can Bolt help you today?" + placeholder="Bolt 今天能为您做些什么?" translate="no" /> @@ -152,7 +172,7 @@ export const BaseChat = React.forwardRef(
( {enhancingPrompt ? ( <>
-
Enhancing prompt...
+
正在增强提示...
) : ( <>
- {promptEnhanced &&
Prompt enhanced
} + {promptEnhanced &&
提示已增强
} )}
{input.length > 3 ? (
- Use Shift + Return for a new line + 使用 Shift + 回车 换行
) : null}
-
{/* Ghost Element */}
+
{/* 幽灵元素 */}
{!chatStarted && ( diff --git a/app/components/ui/Select.tsx b/app/components/ui/Select.tsx new file mode 100644 index 0000000..a614e79 --- /dev/null +++ b/app/components/ui/Select.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { classNames } from '~/utils/classNames'; + +interface SelectOption { + value: string; + label: string; +} + +interface SelectProps { + options: SelectOption[]; + value: string; + onChange: (value: string) => void; + className?: string; + placeholder?: string; +} + +export const Select: React.FC = ({ options, value, onChange, className, placeholder }) => { + return ( + + ); +}; diff --git a/app/components/workbench/TemplateSelector.tsx b/app/components/workbench/TemplateSelector.tsx new file mode 100644 index 0000000..1b80089 --- /dev/null +++ b/app/components/workbench/TemplateSelector.tsx @@ -0,0 +1,21 @@ +import { memo } from 'react'; +import { templates, type TemplateName } from '~/utils/templates'; +import { Select } from '~/components/ui/Select'; + +interface TemplateSelectorProps { + className?: string; + value: TemplateName; + onChange: (templateName: TemplateName) => void; +} + +export const TemplateSelector = memo(({ className, value, onChange }: TemplateSelectorProps) => { + return ( +