|
|
@@ -1,5 +1,5 @@
|
|
|
import React, { useState } from "react";
|
|
|
-import { Button, Input, Typography } from "antd";
|
|
|
+import { Button, Input, Space, Typography } from "antd";
|
|
|
import { EditOutlined, CopyOutlined } from "@ant-design/icons";
|
|
|
import { UserMessageProps } from "../../types/chat";
|
|
|
import { VersionSwitcher } from "./VersionSwitcher";
|
|
|
@@ -34,67 +34,69 @@ const UserMessage = ({
|
|
|
}
|
|
|
return (
|
|
|
<div className="user-message">
|
|
|
- <div className="message-content" style={{ maxWidth: "90%" }}>
|
|
|
- {isEditing ? (
|
|
|
- <div className="edit-area">
|
|
|
- <TextArea
|
|
|
- value={editContent}
|
|
|
- onChange={(e) => setEditContent(e.target.value)}
|
|
|
- autoSize={{ minRows: 2, maxRows: 8 }}
|
|
|
- autoFocus
|
|
|
- />
|
|
|
- <div className="edit-actions">
|
|
|
- <Button size="small" onClick={handleCancel}>
|
|
|
- 取消
|
|
|
- </Button>
|
|
|
- <Button size="small" type="primary" onClick={handleEdit}>
|
|
|
- 保存
|
|
|
- </Button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- ) : (
|
|
|
- <div className="message-text">
|
|
|
- <Text>{message.content}</Text>
|
|
|
- {message.save_status === "pending" && (
|
|
|
- <span className="status-indicator pending">发送中...</span>
|
|
|
- )}
|
|
|
- {message.save_status === "failed" && (
|
|
|
- <span className="status-indicator failed">发送失败</span>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- <div className="message-header">
|
|
|
- <span className="role-label"></span>
|
|
|
- <div className="message-actions" style={{ display: "flex" }}>
|
|
|
- {!isEditing && (
|
|
|
- <>
|
|
|
- <Button
|
|
|
- size="small"
|
|
|
- type="text"
|
|
|
- icon={<EditOutlined />}
|
|
|
- onClick={() => setIsEditing(true)}
|
|
|
+ <div style={{ maxWidth: "90%" }}>
|
|
|
+ <div className="message-content">
|
|
|
+ {isEditing ? (
|
|
|
+ <div className="edit-area">
|
|
|
+ <TextArea
|
|
|
+ value={editContent}
|
|
|
+ onChange={(e) => setEditContent(e.target.value)}
|
|
|
+ autoSize={{ minRows: 2, maxRows: 8 }}
|
|
|
+ autoFocus
|
|
|
/>
|
|
|
- <Button
|
|
|
- size="small"
|
|
|
- type="text"
|
|
|
- icon={<CopyOutlined />}
|
|
|
- onClick={onCopy}
|
|
|
- />
|
|
|
- {/* 版本切换器 */}
|
|
|
- {session.versions && session.versions.length > 1 && (
|
|
|
- <VersionSwitcher
|
|
|
- versions={session.versions}
|
|
|
- currentVersion={session.current_version}
|
|
|
- onSwitch={(versionIndex) =>
|
|
|
- onVersionSwitch &&
|
|
|
- onVersionSwitch(session.versions[versionIndex].message_id)
|
|
|
- }
|
|
|
- />
|
|
|
+ <div className="edit-actions">
|
|
|
+ <Button size="small" onClick={handleCancel}>
|
|
|
+ 取消
|
|
|
+ </Button>
|
|
|
+ <Button size="small" type="primary" onClick={handleEdit}>
|
|
|
+ 保存
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div className="message-text">
|
|
|
+ <Text>{message.content}</Text>
|
|
|
+ {message.save_status === "pending" && (
|
|
|
+ <span className="status-indicator pending">发送中...</span>
|
|
|
+ )}
|
|
|
+ {message.save_status === "failed" && (
|
|
|
+ <span className="status-indicator failed">发送失败</span>
|
|
|
)}
|
|
|
- </>
|
|
|
+ </div>
|
|
|
)}
|
|
|
</div>
|
|
|
+ <div className="message-header">
|
|
|
+ <span className="role-label"></span>
|
|
|
+ <div className="message-actions">
|
|
|
+ {!isEditing && (
|
|
|
+ <Space size="small">
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ type="text"
|
|
|
+ icon={<EditOutlined />}
|
|
|
+ onClick={() => setIsEditing(true)}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ type="text"
|
|
|
+ icon={<CopyOutlined />}
|
|
|
+ onClick={onCopy}
|
|
|
+ />
|
|
|
+ {/* 版本切换器 */}
|
|
|
+ {session.versions && session.versions.length > 1 && (
|
|
|
+ <VersionSwitcher
|
|
|
+ versions={session.versions}
|
|
|
+ currentVersion={session.current_version}
|
|
|
+ onSwitch={(versionIndex) =>
|
|
|
+ onVersionSwitch &&
|
|
|
+ onVersionSwitch(session.versions[versionIndex].message_id)
|
|
|
+ }
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </Space>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|