From 6bc81a9866d788ac10d6539e3345c0c83a093ef2 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sat, 20 Sep 2025 23:35:36 +0800 Subject: [PATCH] Improve navigation logic after publishing content (#7775) --- .../modules/contents/pages/SinglePageEditor.vue | 10 ++++++++-- ui/console-src/modules/contents/posts/PostEditor.vue | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ui/console-src/modules/contents/pages/SinglePageEditor.vue b/ui/console-src/modules/contents/pages/SinglePageEditor.vue index b177208d9..8241b9a40 100644 --- a/ui/console-src/modules/contents/pages/SinglePageEditor.vue +++ b/ui/console-src/modules/contents/pages/SinglePageEditor.vue @@ -220,9 +220,15 @@ const handlePublish = async () => { }); if (returnToView.value && permalink) { + handleClearCache(routeQueryName.value); window.location.href = permalink; - } else { + return; + } + + if (router.options.history.state.back === null) { router.push({ name: "SinglePages" }); + } else { + router.back(); } } else { formState.value.page.spec.publish = true; @@ -237,7 +243,7 @@ const handlePublish = async () => { } Toast.success(t("core.common.toast.publish_success")); - handleClearCache(routeQueryName.value as string); + handleClearCache(routeQueryName.value); } catch (error) { console.error("Failed to publish single page", error); Toast.error(t("core.common.toast.publish_failed_and_retry")); diff --git a/ui/console-src/modules/contents/posts/PostEditor.vue b/ui/console-src/modules/contents/posts/PostEditor.vue index 271432d56..4cd7101e5 100644 --- a/ui/console-src/modules/contents/posts/PostEditor.vue +++ b/ui/console-src/modules/contents/posts/PostEditor.vue @@ -262,9 +262,15 @@ const handlePublish = async () => { }); if (returnToView.value === "true" && permalink) { + handleClearCache(name.value); window.location.href = permalink; - } else { + return; + } + + if (router.options.history.state.back === null) { router.push({ name: "Posts" }); + } else { + router.back(); } } else { const { data } = await consoleApiClient.content.post.draftPost({