PicArt
Home
PicArt
PICAPICA
Profile
测试文章发布基础
by 管理员
Publish At 2025-07-26T11:11:40.810Z
567 Views
const onSubmit = async () => { try { const { parentCategory, ...data } = await schema.parseAsync(state); // 删除不需要的数据 // 分离现有标签ID和新标签名称 const existingTagIds: number[] = []; const newTagNames: string[] = []; state.tagIds?.forEach(id => { const tag = tagsOptions.value.find((t: TagMenuItem) => t.id === id); if (tag?.flag) { // 临时标签,使用名称 newTagNames.push(tag.label as string); } else { // 现有标签,使用ID const numericId = typeof id === 'string' ? parseInt(id) : id; if (!isNaN(numericId)) { existingTagIds.push(numericId); } } }); await articleControllerCreate({ composable: '$fetch', body: { ...data, tagIds: existingTagIds.length > 0 ? existingTagIds : undefined, tagNames: newTagNames.length > 0 ? newTagNames : undefined } }); console.log('文章创建成功'); } catch (error) { console.error('提交失败:', error); } };
Comments
发表评论
用户1
2小时前
这篇文章写得很好!
5
回复
管理员
0
Followers
0
Likes
96%
Reviews
Follow Author
Related Articles
相关文章1
1234 Views
相关文章2
567 Views