测试文章发布基础

作者头像by 管理员
Publish At 2025-07-26T11:11:40.810Z
567 Views
图片1
图片2
图片3
图片4
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
用户12小时前

这篇文章写得很好!

作者头像

管理员

0
Followers
0
Likes
96%
Reviews

Related Articles

相关文章1
相关文章1

1234 Views

相关文章2
相关文章2

567 Views