|
@@ -9,16 +9,9 @@ import {
|
|
|
AttachmentsProps,
|
|
|
} from "@ant-design/x";
|
|
|
import { useChat } from "@/hooks/useChat";
|
|
|
+import "./index.less";
|
|
|
|
|
|
-import {
|
|
|
- Card,
|
|
|
- Flex,
|
|
|
- message,
|
|
|
- Button,
|
|
|
- Space,
|
|
|
- Spin,
|
|
|
- Typography,
|
|
|
-} from "antd";
|
|
|
+import { Card, Flex, message, Button, Space, Spin, Typography } from "antd";
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
import {
|
|
|
BulbOutlined,
|
|
@@ -29,6 +22,7 @@ import {
|
|
|
CopyOutlined,
|
|
|
RedoOutlined,
|
|
|
ReadOutlined,
|
|
|
+ FireOutlined,
|
|
|
} from "@ant-design/icons";
|
|
|
import type { GetProp, GetRef } from "antd";
|
|
|
import MarkdownViewer from "@/components/ai/MarkdownViewer";
|
|
@@ -58,6 +52,12 @@ const roles: GetProp<typeof Bubble.List, "roles"> = {
|
|
|
);
|
|
|
},
|
|
|
header: "易码工坊AI助手",
|
|
|
+ styles: {
|
|
|
+ content: {
|
|
|
+ background: "#fff",
|
|
|
+ width: "100%",
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
user: {
|
|
|
placement: "end",
|
|
@@ -65,6 +65,11 @@ const roles: GetProp<typeof Bubble.List, "roles"> = {
|
|
|
messageRender: (content) => {
|
|
|
return <div style={{ whiteSpace: "pre-wrap" }}>{content}</div>;
|
|
|
},
|
|
|
+ styles: {
|
|
|
+ content: {
|
|
|
+ background: "#fff",
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
};
|
|
|
|
|
@@ -81,7 +86,7 @@ export default () => {
|
|
|
loading,
|
|
|
loadingSession,
|
|
|
addConversation,
|
|
|
- setConversationList
|
|
|
+ setConversationList,
|
|
|
} = useChat({
|
|
|
app_name: "normal_ask",
|
|
|
onSuccess: (msg) => {
|
|
@@ -274,16 +279,17 @@ export default () => {
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
- <Card
|
|
|
- className="w-full h-full"
|
|
|
- styles={{
|
|
|
- body: {
|
|
|
- height: "calc(100vh - 48px)",
|
|
|
- },
|
|
|
+ <div
|
|
|
+ className="w-[100vw] h-[100vh] overflow-hidden box-border p-12px"
|
|
|
+ style={{
|
|
|
+ backgroundImage: "linear-gradient(137deg, #e5f4ff 0%, #efe7ff 100%)",
|
|
|
}}
|
|
|
>
|
|
|
<XProvider direction="ltr">
|
|
|
- <Flex style={{ height: "100%" }} gap={12}>
|
|
|
+ <Flex
|
|
|
+ style={{ height: "100%", maxWidth: 1200, margin: "0 auto" }}
|
|
|
+ gap={12}
|
|
|
+ >
|
|
|
<Flex
|
|
|
vertical
|
|
|
style={{ flex: 1, overflow: "hidden", height: "100%" }}
|
|
@@ -296,68 +302,88 @@ export default () => {
|
|
|
>
|
|
|
{!messages.length ? (
|
|
|
<>
|
|
|
- <div className="mt-20 mb-10">
|
|
|
- <Welcome
|
|
|
- icon={
|
|
|
- <img
|
|
|
- src={''}
|
|
|
- className="rounded-8px"
|
|
|
- />
|
|
|
- }
|
|
|
- title={`你好!我是AI易搭`}
|
|
|
- description={`我可以帮你一句话生成应用`}
|
|
|
- />
|
|
|
+ <div className="mt-20 mb-10 flex items-center justify-center">
|
|
|
+ <div className="w-50px">
|
|
|
+ <svg className="icon h-32px w-32px" aria-hidden="true">
|
|
|
+ <use xlinkHref="#icon-AI1"></use>
|
|
|
+ </svg>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div className="ai-title">
|
|
|
+ 你好,我是易码工坊AI助手
|
|
|
+ </div>
|
|
|
+ <div className="text-18px text-#666">
|
|
|
+ 说出你的需求,我可以帮你生成应用~
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<Prompts
|
|
|
- title={
|
|
|
- "✨ 你可以这样问我:"
|
|
|
- }
|
|
|
- items={[]}
|
|
|
- wrap
|
|
|
+ // title={"✨ 你可以这样问我:"}
|
|
|
+ items={[
|
|
|
+ {
|
|
|
+ key: "1",
|
|
|
+ icon: <FireOutlined style={{ color: '#FF4D4F' }} />,
|
|
|
+ label: "创建客户管理系统",
|
|
|
+ description: '123'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: "2",
|
|
|
+ icon: <FireOutlined style={{ color: '#FF4D4F' }} />,
|
|
|
+ label: "创建资产管理系统",
|
|
|
+ description: '123'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: "3",
|
|
|
+ icon: <FireOutlined style={{ color: '#FF4D4F' }} />,
|
|
|
+ label: "创建项目管理系统",
|
|
|
+ description: '123'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: "4",
|
|
|
+ icon: <FireOutlined style={{ color: '#FF4D4F' }} />,
|
|
|
+ label: "创建OA办公自动化管理系统",
|
|
|
+ description: '123'
|
|
|
+ },
|
|
|
+ ]}
|
|
|
onItemClick={handlePromptItem}
|
|
|
+ wrap
|
|
|
+ styles={{
|
|
|
+ item: {
|
|
|
+ flex: "none",
|
|
|
+ width: "calc(50% - 6px)",
|
|
|
+ },
|
|
|
+ }}
|
|
|
/>
|
|
|
</>
|
|
|
) : (
|
|
|
<Bubble.List
|
|
|
- style={{ maxHeight: contentHeight, padding: '0 20px' }}
|
|
|
+ style={{ maxHeight: contentHeight, padding: "0 20px" }}
|
|
|
autoScroll
|
|
|
roles={roles}
|
|
|
items={messages}
|
|
|
/>
|
|
|
)}
|
|
|
</div>
|
|
|
- <Prompts
|
|
|
+ <Suggestion
|
|
|
items={[
|
|
|
- {
|
|
|
- key: "1",
|
|
|
- icon: <BulbOutlined style={{ color: "#FFD700" }} />,
|
|
|
- label: "写需求",
|
|
|
- },
|
|
|
- {
|
|
|
- key: "2",
|
|
|
- icon: <SmileOutlined style={{ color: "#52C41A" }} />,
|
|
|
- label: "生成代码",
|
|
|
- },
|
|
|
- {
|
|
|
- key: "3",
|
|
|
- icon: <ReadOutlined style={{ color: "#52C41A" }} />,
|
|
|
- label: "问题解答",
|
|
|
- },
|
|
|
+ { label: "创建客户管理系统", value: "report" },
|
|
|
+ { label: "创建资产管理系统", value: "report" },
|
|
|
+ { label: "创建客户管理系统", value: "report" },
|
|
|
+ { label: "创建客户管理系统", value: "report" },
|
|
|
]}
|
|
|
- onItemClick={handlePromptItem}
|
|
|
- />
|
|
|
-
|
|
|
- <Suggestion
|
|
|
- items={[{ label: "写一个应用介绍", value: "report" }]}
|
|
|
onSelect={submitMessage}
|
|
|
+ className="relative overflow-hidden"
|
|
|
>
|
|
|
{({ onTrigger, onKeyDown }) => {
|
|
|
return (
|
|
|
+ <>
|
|
|
+ <div className="sender-wrapper"/>
|
|
|
+ <div className="w-full p-1px">
|
|
|
<Sender
|
|
|
+ submitType="shiftEnter"
|
|
|
ref={senderRef}
|
|
|
header={senderHeader}
|
|
|
- loading={loading}
|
|
|
prefix={
|
|
|
<Button
|
|
|
type="text"
|
|
@@ -381,17 +407,36 @@ export default () => {
|
|
|
setSenderVal(nextVal);
|
|
|
}}
|
|
|
onKeyDown={onKeyDown}
|
|
|
- placeholder="输入/获取快捷提示"
|
|
|
+ placeholder="请输入应用名称以及需求描述"
|
|
|
onSubmit={submitMessage}
|
|
|
onCancel={handleStop}
|
|
|
+ actions={(_, info) => {
|
|
|
+ const { SendButton, LoadingButton, ClearButton } = info.components;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Space size="small">
|
|
|
+ <Typography.Text type="secondary">
|
|
|
+ <small>`Shift + Enter`提交</small>
|
|
|
+ </Typography.Text>
|
|
|
+ <ClearButton />
|
|
|
+ {loading ? (
|
|
|
+ <LoadingButton type="default" disabled />
|
|
|
+ ) : (
|
|
|
+ <SendButton type="primary" disabled={false} />
|
|
|
+ )}
|
|
|
+ </Space>
|
|
|
+ );
|
|
|
+ }}
|
|
|
/>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
);
|
|
|
}}
|
|
|
</Suggestion>
|
|
|
</Flex>
|
|
|
</Flex>
|
|
|
</XProvider>
|
|
|
- </Card>
|
|
|
+ </div>
|
|
|
</>
|
|
|
);
|
|
|
};
|