diff --git a/src/app/chat/bot/create/page.tsx b/src/app/chat/bot/create/page.tsx new file mode 100644 index 0000000..e37f91e --- /dev/null +++ b/src/app/chat/bot/create/page.tsx @@ -0,0 +1,199 @@ +'use client'; + +import React, { useState, } from 'react'; + +import ReturnBtn from '@/components/ReturnBtn'; +import { useStyles } from './styles'; +import { Button, Flex, Form, Upload, Input, Select, Tag, Dropdown } from 'antd'; +import type { UploadFile, MenuProps } from 'antd'; +import { LoadingOutlined, PlusOutlined, FolderFilled, LockOutlined, GlobalOutlined, LinkOutlined } from '@ant-design/icons'; + +interface AgentClassification { + value: string; + text: string; +} +const AGENT_CLASSIFICATION_MAP:AgentClassification[] = [ + { text: '通用对话', value: '通用对话'}, + { text: '工作学习', value: '工作学习'}, + { text: '内容创作', value: '内容创作'}, + { text: 'AI 绘画', value: 'AI 绘画'}, + { text: '影音生成', value: '影音生成'}, + { text: '角色扮演', value: '角色扮演'}, + { text: '生活趣味', value: '生活趣味'}, + { text: '其他', value: '其他'}, +] +const normFile = (e: any) => { + if (Array.isArray(e)) { + return e; + } + if (!e?.fileList?.length) { + return []; + } + return [e?.fileList[e?.fileList?.length - 1]]; +}; + +const getBase64 = (img: any, callback: (url: string) => void) => { + const reader = new FileReader(); + reader.addEventListener('load', () => callback(reader.result as string)); + reader.readAsDataURL(img); +}; + + +const BotCreate = React.memo(() => { + const { styles } = useStyles(); + const [form] = Form.useForm() + const [loading, setLoading] = useState(false); + const [imageUrl, setImageUrl] = useState(); + const onClick: MenuProps['onClick'] = ({ key }) => { + form.validateFields().then(values => { + const params = { + values, + key + } + console.warn(params) + }) + }; + + const items: MenuProps['items'] = [ + { + label: + + 私密 · 仅自己可对话 + , + key: 'private', + }, + { + label: + + 通过链接访问 · 获得链接的用户可对话 + , + key: 'linked', + }, + { + label: + + 公开 · 所有人可对话 + , + key: 'public', + }, + ]; + return ( +
+ + + + } + isLeftTitle + title="创建 AI 智能体" + /> + +
+
+ + { + // const isLt10M = file.size / 1024 / 1024 <= 5; + // if (!isLt10M) { + // notification.warn({ + // message: '不能大于 5MB!', + // }); + // return Promise.reject(); + // } + return Promise.resolve(file); + }} + className={styles.uploadAvatar} + customRequest={(options: any) => { + const { onSuccess, file } = options; + file.status = 'done'; + onSuccess(file.uid); + getBase64(file as UploadFile, url => { + setLoading(false); + setImageUrl(url); + }); + }} + listType="picture-circle" + onChange={({ file }) => { + file.status = 'done'; + }} + showUploadList={false} + > + {imageUrl ? ( + avatar + ) : ( +
+ {loading ? : } +
上传头像
+
+ )} +
+
+ + + + + + + + + + + + + + { + return false; + }} + showUploadList={true} + > +
+ 上传文件 +
+
+
+
+
+
+ 预览 +
+
+
+ ); +}); + +export default BotCreate; diff --git a/src/app/chat/bot/create/styles.ts b/src/app/chat/bot/create/styles.ts new file mode 100644 index 0000000..b3b0821 --- /dev/null +++ b/src/app/chat/bot/create/styles.ts @@ -0,0 +1,57 @@ +import { createStyles } from 'antd-style'; + +export const useStyles = createStyles(({ token }) => { + return ({ + BotCreate: { + 'width': '100%', + 'background': token.colorBgLayout, + 'position': 'relative', + }, + content: { + paddingTop: '64px', + paddingBottom: '24px', + '.ant-input, .ant-select-selector': { + borderColor: 'transparent !important', + }, + '.ant-input:focus, .ant-select-focused >.ant-select-selector': { + borderColor: `${token.colorPrimaryActive} !important`, + }, + }, + uploadText: { + 'border': 0, + 'background': 'none', + '& > div': { + marginTop: 4, + }, + }, + leftContent: { + width: '40%', + padding: "24px 40px 0 60px" + }, + rightContent: { + width: '60%', + background: token.colorWhite, + }, + tag:{ + position: "relative", + top: "20px", + left: "40px", + }, + uploadAvatar: { + textAlign: 'center' + }, + uploadFile: { + background: token.colorWhite, + color: token.colorTextPlaceholder, + padding: "10px 20px 10px 20px", + borderRadius: token.borderRadius, + }, + uploadIcon: { + marginRight: '4px', + }, + menuIcon: { + marginRight: '4px', + color: token.colorPrimary + }, + }) +}); diff --git a/src/components/ReturnBtn/index.tsx b/src/components/ReturnBtn/index.tsx index fa42d9d..3810832 100644 --- a/src/components/ReturnBtn/index.tsx +++ b/src/components/ReturnBtn/index.tsx @@ -33,22 +33,37 @@ export const useStyles = createStyles(() => ({ flexDirection: 'column', marginLeft: '-40px', }, + leftTitle: { + fontWeight: 590, + fontSize: 16, + }, + layout: { + width: '100%' + } })); interface ReturnBtnProps { to?: string; title?: string; + isLeftTitle?: boolean; + extra?: React.ReactNode; } const ReturnBtn = React.memo(props => { - const { to } = props; + const { to, extra, isLeftTitle } = props; const { styles } = useStyles(); return ( -
{props.title}
+ {isLeftTitle + ? +
{props.title}
+ {extra} +
+ :
{props.title}
+ }
); }); diff --git a/src/layout/AppLayout/SideBar/SideBarHeader/index.tsx b/src/layout/AppLayout/SideBar/SideBarHeader/index.tsx index feb2380..7b08e6c 100644 --- a/src/layout/AppLayout/SideBar/SideBarHeader/index.tsx +++ b/src/layout/AppLayout/SideBar/SideBarHeader/index.tsx @@ -16,7 +16,7 @@ const SidebarHeader = () => { AgileGPT - + 创建智能体