Skip to content

Commit

Permalink
[release-2.11] fix: cannot upload image when creating a new post in U…
Browse files Browse the repository at this point in the history
…C editor (#5115)

Signed-off-by: Ryan Wang <i@ryanc.cc>
Co-authored-by: Ryan Wang <i@ryanc.cc>
  • Loading branch information
halo-dev-bot and ruibaby committed Dec 27, 2023
1 parent 0e030e8 commit 8e9b07d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions console/uc-src/modules/contents/posts/PostEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ function handleSaveClick() {
}
}
function onCreatePostSuccess(data: Post) {
async function onCreatePostSuccess(data: Post) {
formState.value = data;
// Update route query params
name.value = data.metadata.name;
handleFetchContent();
await handleFetchContent();
}
// Save post
Expand Down Expand Up @@ -344,9 +344,19 @@ async function handleUploadImage(file: File) {
[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,
});
await onCreatePostSuccess(data);
}
const { data } = await apiClient.uc.attachment.createAttachmentForPost({
Expand Down

0 comments on commit 8e9b07d

Please sign in to comment.