mirror of https://github.com/halo-dev/halo
fix: cannot upload image when creating a new post in UC editor (#5114)
#### What type of PR is this? /area console /kind bug /milestone 2.12.x #### What this PR does / why we need it: 修复在个人中心的文章编辑器中创建新文章时无法上传图片的问题 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/5035 #### Special notes for your reviewer: 测试在 UC 新建文章,在未保存时是否能上传图片。 #### Does this PR introduce a user-facing change? ```release-note 修复个人中心创建新文章时无法上传图片的问题 ```pull/5078/head
parent
e7789929ec
commit
285ac6a77f
|
@ -229,11 +229,11 @@ function handleSaveClick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCreatePostSuccess(data: Post) {
|
async function onCreatePostSuccess(data: Post) {
|
||||||
formState.value = data;
|
formState.value = data;
|
||||||
// Update route query params
|
// Update route query params
|
||||||
name.value = data.metadata.name;
|
name.value = data.metadata.name;
|
||||||
handleFetchContent();
|
await handleFetchContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save post
|
// Save post
|
||||||
|
@ -344,9 +344,19 @@ async function handleUploadImage(file: File) {
|
||||||
[contentAnnotations.CONTENT_JSON]: JSON.stringify(content.value),
|
[contentAnnotations.CONTENT_JSON]: JSON.stringify(content.value),
|
||||||
};
|
};
|
||||||
|
|
||||||
await apiClient.uc.post.createMyPost({
|
if (!formState.value.spec.title) {
|
||||||
|
formState.value.spec.title = t("core.post_editor.untitled");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formState.value.spec.slug) {
|
||||||
|
formState.value.spec.slug = new Date().getTime().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await apiClient.uc.post.createMyPost({
|
||||||
post: formState.value,
|
post: formState.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await onCreatePostSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await apiClient.uc.attachment.createAttachmentForPost({
|
const { data } = await apiClient.uc.attachment.createAttachmentForPost({
|
||||||
|
|
Loading…
Reference in New Issue