feat(aigc): add shared work top bar and back fixes

- add leftAction prop to AigcTopBar to switch between back arrow and home icon
- pass source=sharedWork query param when reLaunching home from shared work page
- update home page to detect shared work source, adjust top bar and back behavior
- add CSS styling for home top bar icon
- update root page back handler to exit WeChat mini program
This commit is contained in:
duanshuwen
2026-07-17 09:29:38 +08:00
parent 767ecb197b
commit b04e3a4613
5 changed files with 36 additions and 4 deletions

View File

@@ -152,6 +152,17 @@ const hasBackListener = computed(() => {
// 处理返回事件 // 处理返回事件
const handleBack = () => { const handleBack = () => {
const pages = getCurrentPages();
if (pages.length <= 1) {
// #ifdef MP-WEIXIN
if (typeof wx !== "undefined" && typeof wx.exitMiniProgram === "function") {
wx.exitMiniProgram();
return;
}
// #endif
}
if (hasBackListener.value) { if (hasBackListener.value) {
emit("back"); emit("back");
return; return;

View File

@@ -2,7 +2,9 @@
<view class="aigc-topbar" :style="topbarStyle"> <view class="aigc-topbar" :style="topbarStyle">
<view class="aigc-nav-row"> <view class="aigc-nav-row">
<view class="aigc-topbar-back" @tap="emit('back')"> <view class="aigc-topbar-back" @tap="emit('back')">
<uni-icons class="aigc-back-icon" fontFamily="znicons" size="22" color="#172033"> <uni-icons v-if="leftAction === 'home'" class="aigc-back-icon is-home" type="home-filled" size="20"
color="#172033" />
<uni-icons v-else class="aigc-back-icon" fontFamily="znicons" size="22" color="#172033">
{{ zniconsMap["zn-nav-arrow-left"] }} {{ zniconsMap["zn-nav-arrow-left"] }}
</uni-icons> </uni-icons>
</view> </view>
@@ -43,6 +45,11 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
leftAction: {
type: String,
default: "back",
validator: (value) => ["back", "home"].includes(value),
},
}); });
const emit = defineEmits(["back", "history", "recharge"]); const emit = defineEmits(["back", "history", "recharge"]);

View File

@@ -48,6 +48,10 @@
transform: translateX(-1px); transform: translateX(-1px);
} }
.aigc-back-icon.is-home {
transform: none;
}
.aigc-topbar-actions { .aigc-topbar-actions {
flex: 1 1 auto; flex: 1 1 auto;
width: auto; width: auto;

View File

@@ -1,6 +1,7 @@
<template> <template>
<view class="aigc-home-page"> <view class="aigc-home-page">
<AigcTopBar :points="pointBalance" @back="handleBack" @history="handleHistory" @recharge="handleRecharge" /> <AigcTopBar :points="pointBalance" :left-action="isSharedWorkEntry ? 'home' : 'back'" @back="handleBack"
@history="handleHistory" @recharge="handleRecharge" />
<view class="aigc-home-browser"> <view class="aigc-home-browser">
<GiftPointsToast :visible="giftToastVisible" @close="handleCloseGiftToast" /> <GiftPointsToast :visible="giftToastVisible" @close="handleCloseGiftToast" />
@@ -38,6 +39,7 @@ import FlowSteps from "./components/FlowSteps/index.vue";
const { pointBalance, fetchCurrentCredit } = useCurrentCredit(); const { pointBalance, fetchCurrentCredit } = useCurrentCredit();
const activeIndex = ref(0); const activeIndex = ref(0);
const aigcConsentVisible = ref(false); const aigcConsentVisible = ref(false);
const isSharedWorkEntry = ref(false);
const giftToastVisible = ref(!getAigcGiftPointsToastClosed()); const giftToastVisible = ref(!getAigcGiftPointsToastClosed());
const templates = ref([]); const templates = ref([]);
const steps = ["选模板", "传素材", "添积分", "出结果"]; const steps = ["选模板", "传素材", "添积分", "出结果"];
@@ -54,7 +56,8 @@ const fetchTemplateList = async () => {
} }
}; };
onLoad(() => { onLoad((query = {}) => {
isSharedWorkEntry.value = query.source === "sharedWork";
aigcConsentVisible.value = !getAigcConsentAgreed(); aigcConsentVisible.value = !getAigcConsentAgreed();
fetchTemplateList(); fetchTemplateList();
}); });
@@ -64,6 +67,13 @@ onShow(() => {
}); });
const handleBack = () => { const handleBack = () => {
if (isSharedWorkEntry.value) {
uni.reLaunch({
url: "/pages/index/index"
});
return;
}
const pages = getCurrentPages(); const pages = getCurrentPages();
if (pages.length > 1) { if (pages.length > 1) {
uni.navigateBack(); uni.navigateBack();

View File

@@ -100,7 +100,7 @@ onLoad((query = {}) => {
const openAigcHome = () => { const openAigcHome = () => {
uni.reLaunch({ uni.reLaunch({
url: "/pages-aigc/home/home", url: "/pages-aigc/home/home?source=sharedWork",
fail: () => showToast("打开模板列表失败"), fail: () => showToast("打开模板列表失败"),
}); });
}; };