From dc12b8ba8856386a80d279a5c6671db8866206c8 Mon Sep 17 00:00:00 2001 From: duanshuwen Date: Thu, 16 Jul 2026 22:45:15 +0800 Subject: [PATCH] feat: update TopNavBar and shared work page navigation Add leftAction prop to TopNavBar to support back or home left navigation actions, update left icon accordingly. Add optional chaining to shareDetail.templateName to prevent errors. Modify sharedWork page to use home left action and update back handler to use direct home reLaunch. --- src/components/TopNavBar/index.vue | 20 ++++++++++++++++++-- src/pages-aigc/sharedWork/sharedWork.vue | 18 ++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/components/TopNavBar/index.vue b/src/components/TopNavBar/index.vue index 5b8a8ee..004c42e 100644 --- a/src/components/TopNavBar/index.vue +++ b/src/components/TopNavBar/index.vue @@ -8,9 +8,9 @@ class="flex flex-items-center flex-justify-between border-box pl-8 pr-8" :style="navContentStyle" > - + - + @@ -53,6 +53,12 @@ const props = defineProps({ type: Boolean, default: true, }, + // 左侧按钮行为 + leftAction: { + type: String, + default: "back", + validator: (value) => ["back", "home"].includes(value), + }, // 背景颜色 background: { type: String, @@ -148,6 +154,8 @@ const navContentStyle = computed(() => { }; }); +const leftIconType = computed(() => (props.leftAction === "home" ? "home-filled" : "left")); + const hasBackListener = computed(() => { const vnodeProps = instance?.vnode?.props || {}; return Boolean(vnodeProps.onBack); @@ -159,6 +167,14 @@ const handleBack = () => { emit("back"); return; } + + if (props.leftAction === "home") { + uni.reLaunch({ + url: "/pages/index/index", + }); + return; + } + // 如果没有监听back事件,默认执行返回上一页 uni.navigateBack({ delta: 1, diff --git a/src/pages-aigc/sharedWork/sharedWork.vue b/src/pages-aigc/sharedWork/sharedWork.vue index 417a974..ebec826 100644 --- a/src/pages-aigc/sharedWork/sharedWork.vue +++ b/src/pages-aigc/sharedWork/sharedWork.vue @@ -1,8 +1,9 @@