|
@@ -42,6 +42,7 @@
|
|
|
class="form-textarea"
|
|
class="form-textarea"
|
|
|
placeholder="描述这本书的内容、主题、写作目的..."
|
|
placeholder="描述这本书的内容、主题、写作目的..."
|
|
|
:maxlength="500"
|
|
:maxlength="500"
|
|
|
|
|
+ @blur="detectScaleFromDesc"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -658,6 +659,33 @@ function switchToInteractive() {
|
|
|
uni.redirectTo({ url: '/pages/book-generator/interactive' });
|
|
uni.redirectTo({ url: '/pages/book-generator/interactive' });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// AI 预览检测规模(用户未手动选时,描述失焦自动触发)
|
|
|
|
|
+let detectTimer: any = null;
|
|
|
|
|
+async function detectScaleFromDesc() {
|
|
|
|
|
+ const desc = newBook.value.description?.trim();
|
|
|
|
|
+ if (!desc || newBook.value.bookScale) return; // 已手动选过,不覆盖
|
|
|
|
|
+ clearTimeout(detectTimer);
|
|
|
|
|
+ detectTimer = setTimeout(async () => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const response = await uni.request({
|
|
|
|
|
+ url: `${BASE_URL}/book-generator/langgraph/detect-scale`,
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ data: { description: desc }
|
|
|
|
|
+ });
|
|
|
|
|
+ const res = response.data as any;
|
|
|
|
|
+ if (res.code === 0 && res.data) {
|
|
|
|
|
+ newBook.value.bookScale = res.data.bookScale;
|
|
|
|
|
+ bookEstimate.value = {
|
|
|
|
|
+ scale: res.data.bookScale,
|
|
|
|
|
+ words: { min: res.data.totalWords, max: res.data.totalWords, avg: res.data.totalWords },
|
|
|
|
|
+ audioMinutes: { min: 0, max: 0, avg: 0 },
|
|
|
|
|
+ estimatedChapters: res.data.chapters,
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch { /* AI 调用失败不影响用户操作 */ }
|
|
|
|
|
+ }, 800);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function goBack() {
|
|
function goBack() {
|
|
|
const pages = getCurrentPages();
|
|
const pages = getCurrentPages();
|
|
|
if (pages.length > 1) {
|
|
if (pages.length > 1) {
|