feat(aigc/detail): add share preview popup
create reusable SharePreviewPopup component for share preview update ResultActions to emit share event instead of direct native share add share preview flow in aigc detail page update native share config with correct image and fallback title
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<template v-if="taskDetail">
|
||||
<ResultPreview v-if="result.cover" :result="result" />
|
||||
<ResultMeta :items="metaItems" />
|
||||
<ResultActions :saving="isSaving" @save="handleSave" />
|
||||
<ResultActions :saving="isSaving" @save="handleSave" @share="handleOpenSharePreview" />
|
||||
|
||||
<view class="aigc-detail-text-actions">
|
||||
<view class="aigc-detail-text-action" @tap="handleRegenerate">再生成一版</view>
|
||||
@@ -15,23 +15,30 @@
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<SharePreviewPopup ref="sharePreviewPopup" :app-name="currentClientName" :title="result.title"
|
||||
:variant-label="result.variantLabel" :image-url="sharePreviewImage" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onLoad, onShareAppMessage, onShow } from "@dcloudio/uni-app";
|
||||
import { getCurrentConfig } from "@/constant/base.js";
|
||||
import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue";
|
||||
import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js";
|
||||
import { getAigcGeneratorTaskDetail } from "@/request/api/AigcApi.js";
|
||||
import ResultActions from "./components/ResultActions/index.vue";
|
||||
import ResultMeta from "./components/ResultMeta/index.vue";
|
||||
import ResultPreview from "./components/ResultPreview/index.vue";
|
||||
import SharePreviewPopup from "./components/SharePreviewPopup/index.vue";
|
||||
|
||||
const { pointBalance, fetchCurrentCredit } = useCurrentCredit();
|
||||
const taskId = ref("");
|
||||
const taskDetail = ref(null);
|
||||
const isSaving = ref(false);
|
||||
const sharePreviewPopup = ref(null);
|
||||
const currentClientName = String(getCurrentConfig()?.name || "").trim() || "微信小程序";
|
||||
|
||||
const GENERATOR_TYPE_TEXT = {
|
||||
0: "图片版",
|
||||
@@ -102,6 +109,8 @@ const metaItems = computed(() => {
|
||||
];
|
||||
});
|
||||
|
||||
const sharePreviewImage = computed(() => taskDetail.value?.imageResultUrl || "");
|
||||
|
||||
const showPlaceholderToast = (title) => {
|
||||
uni.showToast({
|
||||
title,
|
||||
@@ -147,15 +156,14 @@ onShow(() => {
|
||||
fetchCurrentCredit();
|
||||
});
|
||||
|
||||
|
||||
onShareAppMessage(() => {
|
||||
const shareInfo = {
|
||||
title: taskDetail.value?.itemTitle,
|
||||
title: taskDetail.value?.itemTitle || "分享旅行作品",
|
||||
path: taskId.value
|
||||
? `/pages-aigc/detail/detail?taskId=${encodeURIComponent(taskId.value)}`
|
||||
: "/pages-aigc/home/home",
|
||||
};
|
||||
const imageUrl = taskDetail.value?.imageResultUrl || "";
|
||||
const imageUrl = sharePreviewImage.value;
|
||||
|
||||
if (imageUrl) {
|
||||
shareInfo.imageUrl = imageUrl;
|
||||
@@ -164,6 +172,9 @@ onShareAppMessage(() => {
|
||||
return shareInfo;
|
||||
});
|
||||
|
||||
const handleOpenSharePreview = () => {
|
||||
sharePreviewPopup.value?.open();
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
const pages = getCurrentPages();
|
||||
|
||||
Reference in New Issue
Block a user