From 4b5f77f1641903894a1ee5fdc9b24753c207de6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liu=20=E5=AE=87=E9=98=B3?= Date: Tue, 5 Nov 2024 15:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Create/components/PublishForm/index.tsx | 32 ++++++++++--------- src/pages/Create/index.tsx | 13 +++----- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/pages/Create/components/PublishForm/index.tsx b/src/pages/Create/components/PublishForm/index.tsx index 207c6fc..ca94c65 100644 --- a/src/pages/Create/components/PublishForm/index.tsx +++ b/src/pages/Create/components/PublishForm/index.tsx @@ -87,23 +87,25 @@ const PublishForm = ({ data, closeModel }: { data: Article, closeModel: () => vo // 如果是文章标签,则先判断是否存在,如果不存在则添加 let tagIds: number[] = [] - for (const item of values.tagIds) { - if (typeof item === "string") { - // 如果已经有这个标签了,就没必要再创建一个了 - const tag1 = tagList.find(t => t.name === item)?.id; + if (values.tagIds) { + for (const item of values.tagIds) { + if (typeof item === "string") { + // 如果已经有这个标签了,就没必要再创建一个了 + const tag1 = tagList.find(t => t.name === item)?.id; - if (tag1) { - tagIds.push(tag1) - continue + if (tag1) { + tagIds.push(tag1) + continue + } + + await addTagDataAPI({ name: item }); + const { data: list } = await getTagListAPI(); + // 添加成功后查找对应的标签id + const tag2 = list.find(t => t.name === item)?.id; + if (tag2) tagIds.push(tag2); + } else { + tagIds.push(item); } - - await addTagDataAPI({ name: item }); - const { data: list } = await getTagListAPI(); - // 添加成功后查找对应的标签id - const tag2 = list.find(t => t.name === item)?.id; - if (tag2) tagIds.push(tag2); - } else { - tagIds.push(item); } } diff --git a/src/pages/Create/index.tsx b/src/pages/Create/index.tsx index 2c02718..c181d7d 100644 --- a/src/pages/Create/index.tsx +++ b/src/pages/Create/index.tsx @@ -10,7 +10,7 @@ import { Article } from '@/types/app/article'; import { getArticleDataAPI } from '@/api/Article' import { BiSave } from "react-icons/bi"; -import { GrFormNext } from "react-icons/gr"; +import { AiOutlineEdit, AiOutlineSend } from 'react-icons/ai'; const CreatePage = () => { const [params] = useSearchParams() @@ -20,11 +20,6 @@ const CreatePage = () => { const [content, setContent] = useState(''); const [publishOpen, setPublishOpen] = useState(false) - // 获取编辑器的内容 - const getVditorData = (value: string) => { - setContent(value) - } - // 保存文章 const saveBtn = () => { if (content.trim().length >= 1) { @@ -152,14 +147,16 @@ const CreatePage = () => { <> <div className='flex items-center space-x-4'> - <Dropdown.Button menu={{ items }}>创作神器</Dropdown.Button> + <Dropdown.Button menu={{ items }}> + <AiOutlineEdit className='text-base' /> 创作神器 + </Dropdown.Button> <Button className='w-full flex justify-between' onClick={saveBtn} > <BiSave className='text-base' /> 保存 </Button> <Button size='large' type="primary" className='w-full flex justify-between' onClick={nextBtn} > - <GrFormNext className='text-2xl' /> 下一步 + <AiOutlineSend className='text-2xl' /> 发布 </Button> </div>