feat(aigc): add standalone AIGC task progress page

- Add dedicated progress page for viewing AIGC generation task status
- Extract reusable GeneratingProgressPanel component
- Update task record cards to link to progress page for pending tasks
- Rework useTemplate flow to redirect to progress page post task creation
- Remove unused inline generating code and styles from useTemplate
- Adjust quick access menu item order
This commit is contained in:
duanshuwen
2026-07-15 11:24:28 +08:00
parent d6c82204d4
commit c7785e55d7
10 changed files with 229 additions and 114 deletions

View File

@@ -4,26 +4,19 @@
@recharge="handleRecharge" />
<view class="aigc-use-template-body">
<view class="aigc-use-template-content" :class="{ 'is-generating': currentStep === 'generating' }">
<GeneratingProgressPanel v-if="currentStep === 'generating'" :cost="currentCost" :progress="8"
:generator-type="currentTemplateItem.generatorType"
:item-title="currentTemplateItem.itemTitle || currentTemplate.templateTitle" :task-id="createdTaskId"
:task-status="taskStatus" @continue="handleContinueTemplates" @view="handleHistory" />
<view class="aigc-use-template-content">
<TemplateVersionHero :template="currentTemplate" />
<GenerateConfirmPanel v-if="currentStep === 'generateConfirm'" :cost="currentCost"
:balance="pointBalance" @generate="handleGenerate" @recharge="handleRecharge" />
<template v-else>
<TemplateVersionHero :template="currentTemplate" />
<VersionOptionList :options="templateItems" :selected-value="selectedTemplateItemId"
@select="handleSelectTemplateItem" />
<GenerateConfirmPanel v-if="currentStep === 'generateConfirm'" :cost="currentCost"
:balance="pointBalance" @generate="handleGenerate" @recharge="handleRecharge" />
<template v-else>
<VersionOptionList :options="templateItems" :selected-value="selectedTemplateItemId"
@select="handleSelectTemplateItem" />
<text class="aigc-use-template-note">
动效视频版会先生图再升级为 5 秒内动效视频
</text>
</template>
<text class="aigc-use-template-note">
动效视频版会先生图再升级为 5 秒内动效视频
</text>
</template>
</view>
</view>
@@ -55,14 +48,12 @@ import AigcTopBar from "@/pages-aigc/components/AigcTopBar/index.vue";
import { useCurrentCredit } from "@/pages-aigc/hooks/useCurrentCredit.js";
import {
createAigcGeneratorTask,
getAigcGeneratorTaskDetail,
getAigcTemplateItemList,
getAigcTemplateList,
} from "@/request/api/AigcApi.js";
import { updateImageFile } from "@/request/api/UpdateFile.js";
import guideAvatar from "./assets/xiaoqi-avatar.png";
import GenerateConfirmPanel from "./components/GenerateConfirmPanel/index.vue";
import GeneratingProgressPanel from "./components/GeneratingProgressPanel/index.vue";
import PhotoConfirmDrawer from "./components/PhotoConfirmDrawer/index.vue";
import PhotoGuidePanel from "./components/PhotoGuidePanel/index.vue";
import PhotoPickDrawer from "./components/PhotoPickDrawer/index.vue";
@@ -78,8 +69,6 @@ const templateItems = ref([]);
const selectedTemplateItemId = ref("");
const selectedImageLocalPath = ref("");
const uploadedImageUrl = ref("");
const createdTaskId = ref("");
const taskStatus = ref(null);
const currentStep = ref("version");
const pointDialogVisible = ref(false);
const isUploading = ref(false);
@@ -338,19 +327,6 @@ const handleConfirmPhoto = () => {
currentStep.value = "generateConfirm";
};
const fetchCreatedTaskStatus = async () => {
if (!createdTaskId.value) return;
try {
const res = await getAigcGeneratorTaskDetail({ taskId: createdTaskId.value });
if (res?.code === 0 && res.data) {
taskStatus.value = res.data.taskStatus;
}
} catch (error) {
console.warn("获取AIGC生成任务状态失败", error);
}
};
const handleGenerate = async () => {
if (isCreatingTask.value) return;
@@ -375,9 +351,10 @@ const handleGenerate = async () => {
}
isCreatingTask.value = true;
createdTaskId.value = "";
taskStatus.value = null;
currentStep.value = "generating";
uni.showLoading({
title: "创建中",
mask: true,
});
try {
const res = await createAigcGeneratorTask({
@@ -385,37 +362,25 @@ const handleGenerate = async () => {
imageUrlList: [uploadedImageUrl.value],
});
if (res?.code === 0 && res.data) {
createdTaskId.value = res.data;
const taskId = String(res?.data || "").trim();
if (res?.code === 0 && taskId) {
fetchCurrentCredit();
await fetchCreatedTaskStatus();
uni.redirectTo({
url: `/pages-aigc/progress/progress?taskId=${encodeURIComponent(taskId)}`,
fail: () => showPlaceholderToast("打开任务进度失败"),
});
} else {
currentStep.value = "generateConfirm";
showPlaceholderToast(res?.msg || "创建任务失败");
}
} catch (error) {
console.warn("创建AIGC生成任务失败", error);
currentStep.value = "generateConfirm";
showPlaceholderToast("创建任务失败");
} finally {
uni.hideLoading();
isCreatingTask.value = false;
}
};
const handleContinueTemplates = () => {
const pages = getCurrentPages();
const previousPage = pages[pages.length - 2];
if (previousPage?.route === "pages-aigc/home/home") {
uni.navigateBack();
return;
}
uni.redirectTo({
url: "/pages-aigc/home/home",
fail: () => showPlaceholderToast("继续生成其他模板"),
});
};
const handleClosePointDialog = () => {
pointDialogVisible.value = false;
};