diff --git a/src/pages/CreateRecord/index.tsx b/src/pages/CreateRecord/index.tsx index 297847c..07b6abb 100644 --- a/src/pages/CreateRecord/index.tsx +++ b/src/pages/CreateRecord/index.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; import { useNavigate, useSearchParams } from "react-router-dom"; -import { Button, Card, Image, message } from "antd" +import { Button, Card, Dropdown, Image, Input, message, Modal } from "antd" import TextArea from "antd/es/input/TextArea" import { addRecordDataAPI, editRecordDataAPI, getRecordDataAPI } from '@/api/Record' @@ -63,6 +63,46 @@ export default () => { if (id) getRecordData() }, [id]) + // 添加下拉菜单项配置 + const dropdownItems = { + items: [ + { + key: 'upload', + label: '上传图片', + onClick: () => setIsModalOpen(true) + }, + { + key: 'input', + label: '输入链接', + onClick: () => { + let inputUrl = ''; + Modal.confirm({ + title: '输入图片链接', + content: ( + { + inputUrl = e.target.value; + }} + /> + ), + okText: '确认', + cancelText: '取消', + onOk: () => { + if (!inputUrl.startsWith('http://') && !inputUrl.startsWith('https://')) { + message.error('链接必须以 http:// 或 https:// 开头'); + return Promise.reject(); + } + setImageList([...imageList, inputUrl]); + return Promise.resolve(); + } + }); + } + } + ] + }; + return ( <>