From 389556264009803d47a983dd1211716924935405 Mon Sep 17 00:00:00 2001 From: LIlGG <1103069291@qq.com> Date: Mon, 19 Feb 2024 12:42:21 +0800 Subject: [PATCH 1/2] fix: fix the error when saving settings for articles in the uc --- .../modules/contents/posts/PostEditor.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/console/uc-src/modules/contents/posts/PostEditor.vue b/console/uc-src/modules/contents/posts/PostEditor.vue index a75bbcf844..0416a1de32 100644 --- a/console/uc-src/modules/contents/posts/PostEditor.vue +++ b/console/uc-src/modules/contents/posts/PostEditor.vue @@ -121,12 +121,7 @@ const name = useRouteQuery("name"); onMounted(async () => { if (name.value) { - const { data: post } = await apiClient.uc.post.getMyPost({ - name: name.value, - }); - - formState.value = post; - + await getLatestPost(); await handleFetchContent(); handleResetCache(); return; @@ -189,6 +184,17 @@ useAutoSaveContent(currentCache, toRef(content.value, "raw"), async () => { } }); +async function getLatestPost() { + if (!name.value) { + return; + } + const { data: latestPost } = await apiClient.uc.post.getMyPost({ + name: name.value, + }); + + formState.value = latestPost; +} + /** * Fetch content from the head snapshot. */ @@ -374,6 +380,7 @@ const postSettingEditModal = ref(false); function handleOpenPostSettingEditModal() { handleSave({ mute: true }); + getLatestPost(); postSettingEditModal.value = true; } From d3d3ca437a47812aa3174ccfd498feb648c0c961 Mon Sep 17 00:00:00 2001 From: LIlGG <1103069291@qq.com> Date: Mon, 19 Feb 2024 16:09:02 +0800 Subject: [PATCH 2/2] ensure sync acquisition of latestpost --- console/uc-src/modules/contents/posts/PostEditor.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/uc-src/modules/contents/posts/PostEditor.vue b/console/uc-src/modules/contents/posts/PostEditor.vue index 0416a1de32..e41894cdf6 100644 --- a/console/uc-src/modules/contents/posts/PostEditor.vue +++ b/console/uc-src/modules/contents/posts/PostEditor.vue @@ -378,9 +378,9 @@ const { mutateAsync: handlePublish, isLoading: isPublishing } = useMutation({ // Post setting const postSettingEditModal = ref(false); -function handleOpenPostSettingEditModal() { +async function handleOpenPostSettingEditModal() { handleSave({ mute: true }); - getLatestPost(); + await getLatestPost(); postSettingEditModal.value = true; }