|
@@ -187,8 +187,8 @@
|
|
|
<!-- 生成进度 -->
|
|
<!-- 生成进度 -->
|
|
|
<view v-if="generating" class="progress-section">
|
|
<view v-if="generating" class="progress-section">
|
|
|
<view class="progress-header">
|
|
<view class="progress-header">
|
|
|
- <text>正在生成第 {{ currentChapter + 1 }} 章...</text>
|
|
|
|
|
- <text>{{ Math.round((currentChapter + 1) / outline.length * 100) }}%</text>
|
|
|
|
|
|
|
+ <text>{{ generatingProgress }}</text>
|
|
|
|
|
+ <text v-if="currentCharCount > 0">{{ currentCharCount }} 字</text>
|
|
|
</view>
|
|
</view>
|
|
|
<progress
|
|
<progress
|
|
|
:percent="Math.round((currentChapter + 1) / outline.length * 100)"
|
|
:percent="Math.round((currentChapter + 1) / outline.length * 100)"
|
|
@@ -335,6 +335,8 @@ const characters = ref<any[]>([]);
|
|
|
const generating = ref(false);
|
|
const generating = ref(false);
|
|
|
const currentChapter = ref(0);
|
|
const currentChapter = ref(0);
|
|
|
const generatedChapters = ref<string[]>([]);
|
|
const generatedChapters = ref<string[]>([]);
|
|
|
|
|
+const generatingProgress = ref(''); // 当前进度
|
|
|
|
|
+const currentCharCount = ref(0); // 当前已生成字数
|
|
|
|
|
|
|
|
// 质量检测
|
|
// 质量检测
|
|
|
const sensitiveResult = ref<{ isClean: boolean; foundWords: string[] }>({ isClean: true, foundWords: [] });
|
|
const sensitiveResult = ref<{ isClean: boolean; foundWords: string[] }>({ isClean: true, foundWords: [] });
|
|
@@ -415,22 +417,37 @@ async function startGeneration() {
|
|
|
generating.value = true;
|
|
generating.value = true;
|
|
|
currentChapter.value = 0;
|
|
currentChapter.value = 0;
|
|
|
generatedChapters.value = [];
|
|
generatedChapters.value = [];
|
|
|
|
|
+ generatingProgress.value = '准备开始...';
|
|
|
|
|
+ currentCharCount.value = 0;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
for (let i = 0; i < outline.value.length; i++) {
|
|
for (let i = 0; i < outline.value.length; i++) {
|
|
|
currentChapter.value = i;
|
|
currentChapter.value = i;
|
|
|
|
|
+ generatingProgress.value = `正在生成第 ${i + 1}/${outline.value.length} 章...`;
|
|
|
|
|
+ currentCharCount.value = 0;
|
|
|
|
|
+
|
|
|
|
|
+ const chapterTitle = outline.value[i]?.title || `第${i + 1}章`;
|
|
|
|
|
+ const previousContent = i > 0 ? generatedChapters.value[i - 1] : '';
|
|
|
|
|
+
|
|
|
const result = await post<any>('/ai-content/chunk/generate', {
|
|
const result = await post<any>('/ai-content/chunk/generate', {
|
|
|
outlineId: `outline-${Date.now()}`,
|
|
outlineId: `outline-${Date.now()}`,
|
|
|
chapterIndex: i,
|
|
chapterIndex: i,
|
|
|
|
|
+ chapterTitle,
|
|
|
|
|
+ previousContent,
|
|
|
});
|
|
});
|
|
|
- generatedChapters.value.push(result.content || `这是第${i + 1}章的内容...\n\n[模拟生成的内容]`);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ generatedChapters.value.push(result.content || `这是第${i + 1}章的内容...`);
|
|
|
|
|
+ currentCharCount.value = result.wordCount || result.content?.length || 0;
|
|
|
|
|
+ generatingProgress.value = `第 ${i + 1}/${outline.value.length} 章完成 (${currentCharCount.value}字)`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 自动进行质量检测
|
|
// 自动进行质量检测
|
|
|
|
|
+ generatingProgress.value = '进行质量检测...';
|
|
|
await checkQuality();
|
|
await checkQuality();
|
|
|
currentStep.value = 4;
|
|
currentStep.value = 4;
|
|
|
|
|
+ generatingProgress.value = '';
|
|
|
} catch (e: any) {
|
|
} catch (e: any) {
|
|
|
- uni.showToast({ title: '生成失败', icon: 'none' });
|
|
|
|
|
|
|
+ uni.showToast({ title: '生成失败: ' + (e.message || '未知错误'), icon: 'none' });
|
|
|
} finally {
|
|
} finally {
|
|
|
generating.value = false;
|
|
generating.value = false;
|
|
|
}
|
|
}
|