解决已知问题
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = () => {
|
||||
<>
|
||||
<Title value="创作">
|
||||
<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>
|
||||
</Title>
|
||||
|
||||
Reference in New Issue
Block a user