qwe
This commit is contained in:
19
app/page.tsx
19
app/page.tsx
@ -26,7 +26,8 @@ import { Sidebar } from './components/Sidebar';
|
||||
const welcomeMessage: MessageType = {
|
||||
id: '1',
|
||||
content: '终于等到你了!我是你的爆款文案策划师,开始之前,我需要你提供一些简单的信息,让我能给你更有针对性的运营方案。\n1. 你的行业/背调/产品/服务(即使没有现有产品,可以说想要的产品/服务)\n2. 你的目标用户(根据你从业经验描绘的目标用户)',
|
||||
sender: 'bot',
|
||||
role: 'assistant',
|
||||
content_type: 'text',
|
||||
timestamp: new Date(Date.now() - 60000),
|
||||
};
|
||||
|
||||
@ -85,7 +86,8 @@ const ChatInterface: React.FC = () => {
|
||||
const userMessage: MessageType = {
|
||||
id: Date.now().toString(),
|
||||
content: input,
|
||||
sender: 'user',
|
||||
role: 'user',
|
||||
content_type: 'text',
|
||||
timestamp: new Date(),
|
||||
};
|
||||
|
||||
@ -107,12 +109,12 @@ const ChatInterface: React.FC = () => {
|
||||
// 更新消息列表,找到临时消息或创建新消息
|
||||
setMessages(prev => {
|
||||
// 检查是否已存在临时bot消息
|
||||
const hasTempMessage = prev.some(msg => msg.id === tempBotMessageId && msg.sender === 'bot');
|
||||
const hasTempMessage = prev.some(msg => msg.id === tempBotMessageId && msg.role === 'assistant');
|
||||
|
||||
if (hasTempMessage) {
|
||||
// 更新已存在的临时消息
|
||||
return prev.map(msg =>
|
||||
msg.id === tempBotMessageId && msg.sender === 'bot'
|
||||
msg.id === tempBotMessageId && msg.role === 'assistant'
|
||||
? { ...msg, content: partialText }
|
||||
: msg
|
||||
);
|
||||
@ -121,7 +123,8 @@ const ChatInterface: React.FC = () => {
|
||||
const tempBotMessage: MessageType = {
|
||||
id: tempBotMessageId,
|
||||
content: partialText,
|
||||
sender: 'bot',
|
||||
role: 'assistant',
|
||||
content_type: 'text',
|
||||
timestamp: new Date(),
|
||||
};
|
||||
return [...prev, tempBotMessage];
|
||||
@ -137,7 +140,8 @@ const ChatInterface: React.FC = () => {
|
||||
const mockBotMessage: MessageType = {
|
||||
id: (Date.now() + 1).toString(),
|
||||
content: '您的消息已收到!这是一条智能回复,为您提供专业的文案建议。\n\n根据您的需求,我可以为您提供:\n- 吸引人的标题创意\n- 产品描述优化\n- 社交媒体文案\n- 广告标语设计\n\n请继续告诉我更多关于您的产品或服务信息,我会提供更有针对性的建议!',
|
||||
sender: 'bot',
|
||||
role: 'assistant',
|
||||
content_type: 'text',
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages(prev => [...prev, mockBotMessage]);
|
||||
@ -149,7 +153,8 @@ const ChatInterface: React.FC = () => {
|
||||
const errorMessage: MessageType = {
|
||||
id: (Date.now() + 2).toString(),
|
||||
content: `抱歉,处理您的请求时遇到了问题。请稍后再试,或刷新页面重试。`,
|
||||
sender: 'bot',
|
||||
role: 'assistant',
|
||||
content_type: 'text',
|
||||
timestamp: new Date(),
|
||||
};
|
||||
setMessages(prev => [...prev, errorMessage]);
|
||||
|
||||
Reference in New Issue
Block a user