2025-08-19 16:20:37 +08:00
|
|
|
|
import { Card, Col, Row } from "antd"
|
2024-02-07 21:07:41 +05:30
|
|
|
|
|
2025-08-19 16:20:37 +08:00
|
|
|
|
import { useMessageOption } from "@/hooks/useMessageOption.tsx"
|
|
|
|
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
2025-08-21 14:08:07 +08:00
|
|
|
|
import { qaPrompt } from "@/libs/playground.tsx"
|
2024-11-17 12:26:14 +05:30
|
|
|
|
|
2025-08-19 16:20:37 +08:00
|
|
|
|
export const PlaygroundEmpty = () => {
|
2025-08-21 14:08:07 +08:00
|
|
|
|
const { onSubmit } = useMessageOption()
|
2025-08-19 16:20:37 +08:00
|
|
|
|
|
|
|
|
|
|
const queryClient = useQueryClient()
|
2024-02-07 21:07:41 +05:30
|
|
|
|
|
2025-08-19 16:20:37 +08:00
|
|
|
|
const { mutateAsync: sendMessage } = useMutation({
|
|
|
|
|
|
mutationFn: onSubmit,
|
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
|
queryClient.invalidateQueries({
|
|
|
|
|
|
queryKey: ["fetchChatHistory"]
|
|
|
|
|
|
})
|
2024-11-27 12:40:05 +05:30
|
|
|
|
}
|
2025-08-19 16:20:37 +08:00
|
|
|
|
})
|
2024-11-27 12:40:05 +05:30
|
|
|
|
|
2025-08-19 16:20:37 +08:00
|
|
|
|
function handleQuestion(message: string) {
|
2025-08-21 14:08:07 +08:00
|
|
|
|
void sendMessage({ message, image: "" })
|
2024-11-17 12:26:14 +05:30
|
|
|
|
}
|
2024-02-07 21:07:41 +05:30
|
|
|
|
|
2025-08-19 16:20:37 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div className="w-full p-4">
|
|
|
|
|
|
{/* 标题区域 */}
|
|
|
|
|
|
<div className="mb-4">
|
2025-08-21 14:08:07 +08:00
|
|
|
|
<h2
|
|
|
|
|
|
className="text-xl font-bold text-gray-800"
|
|
|
|
|
|
style={{ lineHeight: "0" }}>
|
|
|
|
|
|
数联网科创智能体
|
|
|
|
|
|
</h2>
|
2025-08-19 16:20:37 +08:00
|
|
|
|
<p className="text-sm text-gray-500">您好!请问有什么可以帮您?</p>
|
2024-02-07 21:07:41 +05:30
|
|
|
|
</div>
|
2025-08-19 16:20:37 +08:00
|
|
|
|
|
|
|
|
|
|
{/* 卡片网格布局 */}
|
|
|
|
|
|
<Row gutter={[16, 16]} className="w-full">
|
2025-08-21 14:08:07 +08:00
|
|
|
|
{qaPrompt.map((item, index) => (
|
2025-08-19 16:20:37 +08:00
|
|
|
|
<Col key={index} xs={24} sm={12} md={8}>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
hoverable
|
2025-08-21 14:08:07 +08:00
|
|
|
|
style={{ backgroundColor: "#f3f4f6" }}
|
2025-08-19 16:20:37 +08:00
|
|
|
|
className="border border-gray-200 rounded-lg shadow-sm hover:shadow-md transition-shadow duration-200 cursor-pointer"
|
2025-08-21 14:08:07 +08:00
|
|
|
|
onClick={() => handleQuestion(item.title)}>
|
2025-08-19 16:20:37 +08:00
|
|
|
|
<div className="flex items-center">
|
2025-08-21 14:08:07 +08:00
|
|
|
|
<div className="text-blue-500 mr-2 w-10">{item.icon}</div>
|
|
|
|
|
|
<div className="font-medium text-sm text-gray-800">
|
|
|
|
|
|
{item.title}
|
|
|
|
|
|
</div>
|
2025-08-19 16:20:37 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</Row>
|
2024-02-07 21:07:41 +05:30
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|