interactive.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. <template>
  2. <view class="page">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar">
  5. <view class="nav-content">
  6. <view class="nav-left" @click="goBack">
  7. <text class="back-icon">←</text>
  8. </view>
  9. <text class="page-title">交互式创建</text>
  10. </view>
  11. <!-- 模式切换独立行 -->
  12. <view class="mode-bar">
  13. <text class="mode-switch" @click="switchToSimple">切换到一键模式</text>
  14. </view>
  15. </view>
  16. <!-- 步骤指示器 -->
  17. <view class="steps-bar">
  18. <view v-for="(step, i) in steps" :key="i" :class="['step-dot', currentStep >= i ? 'active' : '', currentStep > i ? 'done' : '']">
  19. <view class="dot-num">{{ currentStep > i ? '✓' : step.num }}</view>
  20. <text class="dot-label">{{ step.label }}</text>
  21. </view>
  22. <view class="step-line" :style="{ width: (currentStep / (steps.length - 1) * 100) + '%' }"></view>
  23. </view>
  24. <!-- 主内容区 -->
  25. <view class="main-content">
  26. <!-- ============ Step 1: 信息输入 ============ -->
  27. <view v-if="currentStep === 0" class="card">
  28. <view class="card-header">
  29. <text class="card-title">📝 第一步:基本信息</text>
  30. </view>
  31. <view class="form-item">
  32. <text class="form-label">书名 *</text>
  33. <input v-model="form.title" class="form-input" placeholder="例如:《时间是什么》" />
  34. </view>
  35. <view class="form-item">
  36. <text class="form-label">内容描述 *</text>
  37. <textarea v-model="form.description" class="form-textarea" placeholder="描述这本书的内容、主题、写作目的..." :maxlength="500" />
  38. </view>
  39. <view class="form-item">
  40. <text class="form-label">书籍规模 *</text>
  41. <view class="scale-picker">
  42. <view
  43. v-for="scale in bookScales"
  44. :key="scale.value"
  45. :class="['scale-chip', form.bookScale === scale.value ? 'active' : '']"
  46. @click="form.bookScale = scale.value"
  47. >
  48. <text class="scale-label">{{ scale.label }}</text>
  49. <text class="scale-desc">{{ scale.chapters }} · {{ scale.audio }}</text>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 目标人群 -->
  54. <view class="form-item">
  55. <view class="label-with-badge">
  56. <text class="form-label">目标人群</text>
  57. <view class="required-badge">核心</view>
  58. </view>
  59. <text class="form-hint-small">指定读者,AI会据此调整语言风格和深度</text>
  60. <view class="chip-group" style="margin-top: 8rpx;">
  61. <view
  62. v-for="a in audiences"
  63. :key="a.value"
  64. :class="['chip', form.targetAudience === a.value ? 'active' : '']"
  65. @click="form.targetAudience = a.value"
  66. >
  67. <text class="chip-icon">{{ a.icon }}</text>
  68. <text class="chip-text">{{ a.label }}</text>
  69. <text class="chip-desc" style="font-size: 20rpx; margin-left: 4rpx;">{{ a.desc }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="form-item">
  74. <text class="form-label">书籍类型</text>
  75. <view class="chip-group">
  76. <view
  77. v-for="bt in bookTypes"
  78. :key="bt.value"
  79. :class="['chip', form.bookType === bt.value ? 'active' : '']"
  80. @click="form.bookType = bt.value"
  81. >
  82. <text class="chip-icon">{{ bt.icon }}</text>
  83. <text class="chip-text">{{ bt.label }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="form-item">
  88. <text class="form-label">大纲层级</text>
  89. <view class="chip-group">
  90. <view
  91. v-for="opt in outlineLevelOptions"
  92. :key="opt.value"
  93. :class="['chip', form.outlineLevel === opt.value ? 'active' : '']"
  94. @click="form.outlineLevel = opt.value"
  95. >
  96. <text class="chip-text">{{ opt.label }}</text>
  97. </view>
  98. </view>
  99. </view>
  100. <!-- 预估 -->
  101. <view v-if="bookEstimate" class="estimate-card">
  102. <view class="estimate-row">
  103. <text class="estimate-label">预估字数:</text>
  104. <text class="estimate-value">{{ bookEstimate.words.min }}~{{ bookEstimate.words.max }}字</text>
  105. </view>
  106. <view class="estimate-row">
  107. <text class="estimate-label">预估章节:</text>
  108. <text class="estimate-value">约{{ bookEstimate.estimatedChapters }}章</text>
  109. </view>
  110. </view>
  111. <view class="btn-group">
  112. <button class="btn-cancel" @click="goBack">取消</button>
  113. <button class="btn-primary" :disabled="!canProceed || stepLoading" @click="doCreateBook">
  114. {{ stepLoading ? '创建中...' : '下一步:AI分析' }}
  115. </button>
  116. </view>
  117. </view>
  118. <!-- ============ Step 2: Plan 审核 ============ -->
  119. <view v-if="currentStep === 1" class="card">
  120. <view class="card-header">
  121. <text class="card-title">🧠 第二步:AI 深度规划</text>
  122. <text v-if="planLoading" class="loading-hint">AI 正在分析...</text>
  123. </view>
  124. <view v-if="planLoading" class="loading-box">
  125. <view class="loading-spinner"></view>
  126. <text class="loading-text">AI 正在制定书籍规划,请稍候...</text>
  127. </view>
  128. <view v-else-if="planData" class="plan-review">
  129. <!-- 概要信息 -->
  130. <view v-if="planSummaryInfo.length" class="plan-summary">
  131. <text v-for="s in planSummaryInfo" :key="s.label" class="summary-tag">
  132. {{ s.icon }} {{ s.label }}: {{ s.value }}
  133. </text>
  134. </view>
  135. <!-- 黄金主线 -->
  136. <view class="plan-section">
  137. <view class="plan-section-header">
  138. <text class="plan-section-icon">🎯</text>
  139. <text class="plan-section-title">黄金主线</text>
  140. <text class="plan-section-hint">一句话概括本书的核心线索</text>
  141. </view>
  142. <textarea v-model="planData.goldenThread" class="plan-textarea" :maxlength="500" placeholder="AI生成的核心主线..." />
  143. </view>
  144. <!-- 叙事弧 -->
  145. <view class="plan-section">
  146. <view class="plan-section-header">
  147. <text class="plan-section-icon">📈</text>
  148. <text class="plan-section-title">叙事弧</text>
  149. <text class="plan-section-hint">AI将全书拆分为几个大的叙事阶段</text>
  150. </view>
  151. <view v-if="narrativeParts.length" class="narrative-parts">
  152. <view v-for="(part, pi) in narrativeParts" :key="pi" class="narrative-part-card">
  153. <view class="part-badge">{{ part.key }}</view>
  154. <view class="part-body">
  155. <view class="part-field">
  156. <text class="part-label">主题</text>
  157. <input v-model="part.theme" class="form-input-sm" />
  158. </view>
  159. <view class="part-field">
  160. <text class="part-label">覆盖章节</text>
  161. <text class="part-text">{{ (part.chapters || []).join(', ') || '—' }}</text>
  162. </view>
  163. <view class="part-field">
  164. <text class="part-label">目标</text>
  165. <textarea v-model="part.goal" class="form-textarea-xs" :maxlength="300" />
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. <view v-else class="plan-empty">
  171. <text class="empty-text">AI 未生成叙事弧结构</text>
  172. </view>
  173. </view>
  174. <!-- 语调风格 -->
  175. <view class="plan-section">
  176. <view class="plan-section-header">
  177. <text class="plan-section-icon">🎵</text>
  178. <text class="plan-section-title">语调风格</text>
  179. </view>
  180. <view v-if="toneFields" class="tone-fields">
  181. <view class="tone-row">
  182. <text class="tone-label">基础语调</text>
  183. <input v-model="toneFields.base" class="form-input-sm" />
  184. </view>
  185. <view class="tone-row">
  186. <text class="tone-label">示例用语</text>
  187. <textarea v-model="toneFields.examples" class="form-textarea-xs" :maxlength="300" />
  188. </view>
  189. <view v-if="toneFields.avoidPatterns" class="tone-row">
  190. <text class="tone-label">避免模式</text>
  191. <view class="tag-list">
  192. <view v-for="(ap, api) in toneFields.avoidPatterns" :key="api" class="tag-item">
  193. <text class="tag-text">{{ ap }}</text>
  194. <text class="tag-remove" @click="removeAvoidPattern(api)">x</text>
  195. </view>
  196. <view class="tag-add" @click="addAvoidPattern">+ 添加</view>
  197. </view>
  198. </view>
  199. </view>
  200. <view v-else class="plan-empty">
  201. <text class="empty-text">AI 未生成语调配置</text>
  202. </view>
  203. </view>
  204. <!-- 受众校准 -->
  205. <view class="plan-section">
  206. <view class="plan-section-header">
  207. <text class="plan-section-icon">👥</text>
  208. <text class="plan-section-title">受众校准</text>
  209. </view>
  210. <view v-if="audienceFields" class="audience-fields">
  211. <view class="audience-row">
  212. <text class="audience-label">已有知识</text>
  213. <view class="tag-list">
  214. <text v-for="(ak, aki) in audienceFields.assumedKnowledge" :key="aki" class="tag-item-static">{{ ak }}</text>
  215. </view>
  216. </view>
  217. <view class="audience-row">
  218. <text class="audience-label">阅读痛点</text>
  219. <view class="tag-list">
  220. <text v-for="(pp, ppi) in audienceFields.painPoints" :key="ppi" class="tag-item-static">{{ pp }}</text>
  221. </view>
  222. </view>
  223. <view class="audience-row">
  224. <text class="audience-label">期望收获</text>
  225. <textarea v-model="audienceFields.desiredOutcome" class="form-textarea-xs" :maxlength="300" />
  226. </view>
  227. </view>
  228. <view v-else class="plan-empty">
  229. <text class="empty-text">AI 未生成受众校准</text>
  230. </view>
  231. </view>
  232. <!-- 用户自然语言反馈 -->
  233. <view class="plan-section feedback-section">
  234. <view class="plan-section-header">
  235. <text class="plan-section-icon">💬</text>
  236. <text class="plan-section-title">修改意见</text>
  237. <text class="plan-section-hint">用自然语言告诉AI你想怎么调整</text>
  238. </view>
  239. <textarea v-model="userFeedback" class="feedback-textarea" :maxlength="500" placeholder="比如:「语调太严肃了,改得更活泼一点」「再加一章关于水星探索历史的」" />
  240. <view class="feedback-hint">
  241. <text v-if="userFeedback.trim()">点击「重新分析」AI会参考你的意见重新规划</text>
  242. <text v-else>输入修改意见后点击「重新分析」,AI会根据你的反馈调整方案</text>
  243. </view>
  244. </view>
  245. </view>
  246. <view v-if="planError" class="error-box">
  247. <text class="error-text">{{ planError }}</text>
  248. </view>
  249. <view v-if="!planLoading" class="btn-group">
  250. <button class="btn-primary" :disabled="stepLoading" @click="doSavePlan">
  251. {{ stepLoading ? '保存中...' : '确认,生成大纲' }}
  252. </button>
  253. <button class="btn-secondary" :disabled="regeneratingPlan" @click="doRefinePlan">
  254. {{ regeneratingPlan ? '重新分析中...' : '重新分析' }}
  255. </button>
  256. <button class="btn-cancel" @click="currentStep = 0">返回修改</button>
  257. </view>
  258. </view>
  259. <!-- ============ Step 3: 大纲审核 ============ -->
  260. <view v-if="currentStep === 2" class="card">
  261. <view class="card-header">
  262. <text class="card-title">📚 第三步:审核大纲</text>
  263. <text v-if="outlineLoading" class="loading-hint">AI 正在生成大纲...</text>
  264. </view>
  265. <view v-if="outlineLoading" class="loading-box">
  266. <view class="loading-spinner"></view>
  267. <text class="loading-text">AI 正在生成详细大纲,请稍候...</text>
  268. </view>
  269. <view v-else-if="outlineChapters.length > 0" class="outline-review">
  270. <text class="outline-subtitle">共 {{ outlineChapters.length }} 章,点击展开编辑详情</text>
  271. <view v-for="(ch, ci) in outlineChapters" :key="ci" class="chapter-card">
  272. <view class="chapter-header" @click="toggleChapterExpand(ci)">
  273. <text class="chapter-num">第{{ ch.number }}章</text>
  274. <text class="expand-icon">{{ expandedChapters[ci] ? '▼' : '▶' }}</text>
  275. </view>
  276. <view v-if="expandedChapters[ci]" class="chapter-edit">
  277. <view class="form-item">
  278. <text class="form-label-sm">章节标题</text>
  279. <input v-model="ch.title" class="form-input-sm" />
  280. </view>
  281. <view class="form-item">
  282. <text class="form-label-sm">摘要</text>
  283. <textarea v-model="ch.summary" class="form-textarea-sm" :maxlength="500" />
  284. </view>
  285. <view class="form-item">
  286. <text class="form-label-sm">预估字数</text>
  287. <input v-model.number="ch.estimatedWords" class="form-input-sm" type="number" />
  288. </view>
  289. <view class="form-item">
  290. <text class="form-label-sm">写作指令</text>
  291. <textarea v-model="ch.writingInstructions" class="form-textarea-sm" :maxlength="500" placeholder="AI写作时会参考这些指令..." />
  292. </view>
  293. <view class="btn-row-sm">
  294. <button class="btn-delete-sm" @click="removeChapter(ci)">删除此章</button>
  295. <button class="btn-move-sm" :disabled="ci === 0" @click="moveChapter(ci, -1)">↑ 上移</button>
  296. <button class="btn-move-sm" :disabled="ci >= outlineChapters.length - 1" @click="moveChapter(ci, 1)">↓ 下移</button>
  297. </view>
  298. </view>
  299. </view>
  300. <button class="btn-add-chapter" @click="addChapter">+ 添加章节</button>
  301. </view>
  302. <view v-if="outlineError" class="error-box">
  303. <text class="error-text">{{ outlineError }}</text>
  304. </view>
  305. <view v-if="!outlineLoading" class="btn-group">
  306. <button class="btn-cancel" @click="currentStep = 1">返回修改</button>
  307. <button class="btn-secondary" :disabled="regeneratingOutline" @click="doGenerateOutline">
  308. {{ regeneratingOutline ? '重新生成中...' : '重新生成大纲' }}
  309. </button>
  310. <button class="btn-primary" :disabled="stepLoading" @click="doSaveOutline">
  311. {{ stepLoading ? '保存中...' : '确认,开始写内容' }}
  312. </button>
  313. </view>
  314. </view>
  315. <!-- ============ Step 4: 内容生成 ============ -->
  316. <view v-if="currentStep === 3" class="card">
  317. <view class="card-header">
  318. <text class="card-title">✍️ 第四步:生成内容</text>
  319. </view>
  320. <view class="generate-box">
  321. <view class="generate-stage" :class="{ 'completed': genProgress > 0 }">
  322. <text class="stage-icon">{{ genProgress > 0 ? '✅' : '⏳' }}</text>
  323. <view class="stage-info">
  324. <text class="stage-title">并行内容生成</text>
  325. <text class="stage-hint">{{ genProgress > 0 ? '已完成' : '等待开始...' }}</text>
  326. </view>
  327. </view>
  328. <view class="generate-stage" :class="{ 'completed': genProgress >= 100 }">
  329. <text class="stage-icon">{{ genProgress >= 100 ? '✅' : '⏳' }}</text>
  330. <view class="stage-info">
  331. <text class="stage-title">连贯性编辑</text>
  332. <text class="stage-hint">{{ genProgress >= 100 ? '已完成' : '等待中...' }}</text>
  333. </view>
  334. </view>
  335. <view v-if="genStarted && genProgress < 100" class="progress-bar-wrap">
  336. <view class="progress-bar" :style="{ width: genProgress + '%' }"></view>
  337. <text class="progress-text">生成进度 {{ genProgress }}%</text>
  338. </view>
  339. <view v-if="genError" class="error-box">
  340. <text class="error-text">{{ genError }}</text>
  341. </view>
  342. </view>
  343. <view v-if="genStarted && genProgress < 100" class="btn-group">
  344. <button class="btn-cancel" :disabled="true">请等待生成完成...</button>
  345. </view>
  346. <view v-if="genProgress >= 100" class="btn-group">
  347. <button class="btn-primary" @click="goToDetail">查看书籍详情</button>
  348. </view>
  349. </view>
  350. </view>
  351. </view>
  352. </template>
  353. <script setup lang="ts">
  354. import { ref, computed, onMounted } from 'vue';
  355. import * as api from '../../utils/book-generator-api';
  356. import { getApiBaseUrl } from '../../utils/config';
  357. const BASE_URL = getApiBaseUrl();
  358. // ============ 步骤状态 ============
  359. const currentStep = ref(0);
  360. const steps = [
  361. { num: 1, label: '信息输入' },
  362. { num: 2, label: 'AI规划' },
  363. { num: 3, label: '审核大纲' },
  364. { num: 4, label: '生成内容' },
  365. ];
  366. // ============ Step 1: 表单 ============
  367. const stepLoading = ref(false);
  368. const form = ref({
  369. title: '',
  370. description: '',
  371. bookScale: '80000',
  372. bookType: 'auto',
  373. outlineLevel: 'auto',
  374. targetAudience: '',
  375. });
  376. const bookId = ref('');
  377. const bookEstimate = ref<{ words: { min: number; max: number }; audioMinutes: { min: number; max: number }; estimatedChapters: number } | null>(null);
  378. const bookScales = [
  379. { value: '340000', label: '上2', chapters: '170章', audio: '约28小时' },
  380. { value: '210000', label: '上1', chapters: '105章', audio: '约17小时' },
  381. { value: '130000', label: '标准', chapters: '65章', audio: '约11小时' },
  382. { value: '80000', label: '下1', chapters: '40章', audio: '约7小时' },
  383. { value: '50000', label: '下2', chapters: '25章', audio: '约4小时' },
  384. { value: '31000', label: '下3', chapters: '16章', audio: '约2.5小时' },
  385. { value: '19000', label: '下4', chapters: '10章', audio: '约1.5小时' },
  386. { value: '12000', label: '下5', chapters: '6章', audio: '约1小时' },
  387. { value: '7000', label: '下6', chapters: '4章', audio: '约35分钟' },
  388. { value: '4000', label: '下7', chapters: '2章', audio: '约20分钟' },
  389. { value: '1000', label: '下10', chapters: '1章', audio: '约5分钟' },
  390. ];
  391. const bookTypes = [
  392. { value: 'auto', label: '自动检测', icon: '🤖' },
  393. { value: '教材', label: '教材/学术', icon: '📚' },
  394. { value: '技术教程', label: '技术教程', icon: '💻' },
  395. { value: '小说', label: '小说/文学', icon: '📖' },
  396. { value: '商业', label: '商业/经管', icon: '📊' },
  397. { value: '科普', label: '科普/大众', icon: '🔬' },
  398. ];
  399. const audiences = [
  400. { value: '儿童', label: '儿童', icon: '👶', desc: '6-12岁,形象生动' },
  401. { value: '青少年', label: '青少年', icon: '🧑', desc: '13-18岁,通俗易懂' },
  402. { value: '大学生', label: '大学生', icon: '🎓', desc: '系统专业,有理论' },
  403. { value: '专业人士', label: '专业人士', icon: '💼', desc: '从业者,实用深入' },
  404. { value: '研究生', label: '研究生', icon: '🔍', desc: '研究级别,前沿深入' },
  405. { value: '大众读者', label: '大众读者', icon: '👥', desc: '通俗普及,有趣味' },
  406. ];
  407. const outlineLevelOptions = [
  408. { value: 'auto', label: '自动' },
  409. { value: '1', label: '1层' },
  410. { value: '2', label: '2层' },
  411. { value: '3', label: '3层' },
  412. ];
  413. const canProceed = computed(() => form.value.title.trim() && form.value.description.trim());
  414. // ============ Step 2: Plan ============
  415. const planLoading = ref(false);
  416. const planData = ref<any>(null);
  417. const planRaw = ref('');
  418. const planError = ref('');
  419. const regeneratingPlan = ref(false);
  420. const userFeedback = ref('');
  421. // 解析叙事弧为 flat array
  422. const narrativeParts = computed(() => {
  423. const arc = planData.value?.narrativeArc;
  424. if (!arc || typeof arc !== 'object') return [];
  425. return Object.entries(arc).map(([key, val]: [string, any]) => ({
  426. key,
  427. theme: val.theme || '',
  428. chapters: val.chapters || [],
  429. goal: val.goal || '',
  430. }));
  431. });
  432. // 解析语调配置
  433. const toneFields = computed(() => {
  434. const tp = planData.value?.toneProfile;
  435. if (!tp || typeof tp !== 'object') return null;
  436. return {
  437. base: tp.base || '',
  438. examples: tp.examples || '',
  439. avoidPatterns: Array.isArray(tp.avoidPatterns) ? [...tp.avoidPatterns] : [],
  440. };
  441. });
  442. // 解析受众校准
  443. const audienceFields = computed(() => {
  444. const ac = planData.value?.audienceCalibration;
  445. if (!ac || typeof ac !== 'object') return null;
  446. return {
  447. assumedKnowledge: Array.isArray(ac.assumedKnowledge) ? ac.assumedKnowledge : [],
  448. painPoints: Array.isArray(ac.painPoints) ? ac.painPoints : [],
  449. desiredOutcome: ac.desiredOutcome || '',
  450. };
  451. });
  452. // 概要标签
  453. const summaryMeta = [
  454. { key: 'bookType', label: '类型', icon: '📖' },
  455. { key: 'writingStyle', label: '风格', icon: '✏️' },
  456. { key: 'contentDepth', label: '深度', icon: '📊' },
  457. { key: 'targetAudienceAnalysis', label: '目标读者', icon: '🎯' },
  458. { key: 'bookTypeAnalysis', label: '结构分析', icon: '🔍' },
  459. ];
  460. const planSummaryInfo = computed(() =>
  461. summaryMeta
  462. .filter(m => planData.value?.[m.key] && typeof planData.value[m.key] === 'string')
  463. .map(m => ({ ...m, value: planData.value[m.key] }))
  464. );
  465. // ============ Step 3: Outline ============
  466. const outlineLoading = ref(false);
  467. const outlineChapters = ref<any[]>([]);
  468. const outlineError = ref('');
  469. const regeneratingOutline = ref(false);
  470. const expandedChapters = ref<Record<number, boolean>>({});
  471. // ============ Step 4: Generation ============
  472. const genStarted = ref(false);
  473. const genProgress = ref(0);
  474. const genError = ref('');
  475. let progressTimer: any = null;
  476. // ============ 方法 ============
  477. function goBack() {
  478. if (currentStep.value === 0) {
  479. const pages = getCurrentPages();
  480. if (pages.length > 1) {
  481. uni.navigateBack();
  482. } else {
  483. uni.switchTab({ url: '/pages/index/index' });
  484. }
  485. return;
  486. }
  487. currentStep.value--;
  488. }
  489. function switchToSimple() {
  490. uni.redirectTo({ url: '/pages/book-generator/create' });
  491. }
  492. async function fetchEstimate() {
  493. try {
  494. const response = await uni.request({
  495. url: `${BASE_URL}/book-generator/langgraph/estimate?scale=${form.value.bookScale}&userId=1`,
  496. method: 'GET',
  497. });
  498. const res = response.data as any;
  499. if (res.code === 0 && res.data?.words) {
  500. bookEstimate.value = {
  501. words: res.data.words,
  502. audioMinutes: res.data.audioMinutes,
  503. estimatedChapters: res.data.estimatedChapters,
  504. };
  505. }
  506. } catch (e) { /* ignore */ }
  507. }
  508. // Step 1: 创建书籍(不自动生成)
  509. async function doCreateBook() {
  510. if (!canProceed.value) return;
  511. stepLoading.value = true;
  512. try {
  513. const genLevel = form.value.outlineLevel === 'auto' ? undefined : parseInt(form.value.outlineLevel);
  514. const bookType = form.value.bookType === 'auto' ? undefined : form.value.bookType;
  515. const book = await api.createBookInteractive({
  516. title: form.value.title,
  517. description: form.value.targetAudience ? form.value.description + '\n目标人群:' + form.value.targetAudience : form.value.description,
  518. bookScale: form.value.bookScale,
  519. bookType,
  520. genLevel,
  521. });
  522. bookId.value = book.id;
  523. currentStep.value = 1;
  524. // 自动触发 Plan 生成
  525. doGeneratePlan();
  526. } catch (e: any) {
  527. uni.showToast({ title: e.message || '创建失败', icon: 'none' });
  528. } finally {
  529. stepLoading.value = false;
  530. }
  531. }
  532. // Step 2: 生成 Plan (异步轮询)
  533. let planPollTimer: ReturnType<typeof setInterval> | null = null;
  534. function stopPlanPolling() {
  535. if (planPollTimer) { clearInterval(planPollTimer); planPollTimer = null; }
  536. }
  537. async function doGeneratePlan(feedback?: string) {
  538. planLoading.value = true;
  539. planError.value = '';
  540. regeneratingPlan.value = true;
  541. stopPlanPolling();
  542. try {
  543. // 1. 启动异步生成
  544. await api.startInteractivePlan(bookId.value, feedback);
  545. // 2. 轮询等待结果(最多等待 180s)
  546. const startTime = Date.now();
  547. planPollTimer = setInterval(async () => {
  548. try {
  549. const res = await api.pollInteractivePlan(bookId.value);
  550. if (res.genStage === 'plan_failed') {
  551. stopPlanPolling();
  552. planError.value = res.error || 'AI 规划失败';
  553. planLoading.value = false;
  554. regeneratingPlan.value = false;
  555. return;
  556. }
  557. if (res.genStage === 'plan_ready' && res.planData) {
  558. stopPlanPolling();
  559. planRaw.value = res.rawPlan || '';
  560. planData.value = res.planData;
  561. planLoading.value = false;
  562. regeneratingPlan.value = false;
  563. return;
  564. }
  565. // 超时检查
  566. if (Date.now() - startTime > 600000) {
  567. stopPlanPolling();
  568. planError.value = 'AI 规划超时,请重新分析';
  569. planLoading.value = false;
  570. regeneratingPlan.value = false;
  571. }
  572. } catch { /* ignore polling errors */ }
  573. }, 3000);
  574. } catch (e: any) {
  575. planError.value = e.message || '启动失败';
  576. planLoading.value = false;
  577. regeneratingPlan.value = false;
  578. }
  579. }
  580. // Step 2: 保存 Plan
  581. async function doSavePlan() {
  582. stepLoading.value = true;
  583. try {
  584. const dataToSave: any = { ...planData.value };
  585. if (narrativeParts.value.length) {
  586. const arc: any = {};
  587. narrativeParts.value.forEach(p => { arc[p.key] = { theme: p.theme, chapters: p.chapters, goal: p.goal }; });
  588. dataToSave.narrativeArc = arc;
  589. }
  590. if (toneFields.value) dataToSave.toneProfile = { ...toneFields.value };
  591. if (audienceFields.value) dataToSave.audienceCalibration = { ...audienceFields.value };
  592. await api.updateInteractivePlan(bookId.value, JSON.stringify(dataToSave));
  593. currentStep.value = 2;
  594. doGenerateOutline();
  595. } catch (e: any) {
  596. uni.showToast({ title: e.message || '保存失败', icon: 'none' });
  597. } finally {
  598. stepLoading.value = false;
  599. }
  600. }
  601. async function doRefinePlan() {
  602. if (regeneratingPlan.value) return;
  603. const dataToSave: any = { ...planData.value };
  604. if (narrativeParts.value.length) {
  605. const arc: any = {};
  606. narrativeParts.value.forEach(p => { arc[p.key] = { theme: p.theme, chapters: p.chapters, goal: p.goal }; });
  607. dataToSave.narrativeArc = arc;
  608. }
  609. if (toneFields.value) dataToSave.toneProfile = { ...toneFields.value };
  610. if (audienceFields.value) dataToSave.audienceCalibration = { ...audienceFields.value };
  611. try { await api.updateInteractivePlan(bookId.value, JSON.stringify(dataToSave)); } catch { /* ignore */ }
  612. planData.value = null;
  613. planRaw.value = '';
  614. planError.value = '';
  615. doGeneratePlan(userFeedback.value);
  616. }
  617. function removeAvoidPattern(index: number) {
  618. if (toneFields.value?.avoidPatterns) toneFields.value.avoidPatterns.splice(index, 1);
  619. }
  620. function addAvoidPattern() {
  621. if (toneFields.value?.avoidPatterns) toneFields.value.avoidPatterns.push('新避免项');
  622. }
  623. // Step 3: 生成 Outline (异步轮询)
  624. let outlinePollTimer: ReturnType<typeof setInterval> | null = null;
  625. function stopOutlinePolling() {
  626. if (outlinePollTimer) { clearInterval(outlinePollTimer); outlinePollTimer = null; }
  627. }
  628. async function doGenerateOutline() {
  629. outlineLoading.value = true;
  630. outlineError.value = '';
  631. regeneratingOutline.value = true;
  632. stopOutlinePolling();
  633. try {
  634. // 1. 启动异步生成
  635. await api.startInteractiveOutline(bookId.value);
  636. // 2. 轮询等待结果(最多等待 180s)
  637. const startTime = Date.now();
  638. outlinePollTimer = setInterval(async () => {
  639. try {
  640. const res = await api.pollInteractiveOutline(bookId.value);
  641. if (res.genStage === 'outline_failed') {
  642. stopOutlinePolling();
  643. outlineError.value = res.error || '大纲生成失败';
  644. outlineLoading.value = false;
  645. regeneratingOutline.value = false;
  646. return;
  647. }
  648. if (res.genStage === 'outline_ready' && res.outlineData?.chapters) {
  649. stopOutlinePolling();
  650. outlineChapters.value = res.outlineData.chapters.map((ch: any, i: number) => ({
  651. number: ch.number || (i + 1),
  652. title: ch.title || '',
  653. summary: ch.summary || '',
  654. estimatedWords: ch.estimatedWords || 2000,
  655. writingInstructions: ch.writingInstructions || '',
  656. sections: ch.sections || [],
  657. subsections: ch.subsections || [],
  658. }));
  659. // 默认展开前3章
  660. const exp: Record<number, boolean> = {};
  661. outlineChapters.value.forEach((_: any, i: number) => { if (i < 3) exp[i] = true; });
  662. expandedChapters.value = exp;
  663. outlineLoading.value = false;
  664. regeneratingOutline.value = false;
  665. return;
  666. }
  667. // 超时检查
  668. if (Date.now() - startTime > 600000) {
  669. stopOutlinePolling();
  670. outlineError.value = '大纲生成超时,请重新生成';
  671. outlineLoading.value = false;
  672. regeneratingOutline.value = false;
  673. }
  674. } catch { /* ignore polling errors */ }
  675. }, 3000);
  676. } catch (e: any) {
  677. outlineError.value = e.message || '启动失败';
  678. outlineLoading.value = false;
  679. regeneratingOutline.value = false;
  680. }
  681. }
  682. // Step 3: 章节操作
  683. function toggleChapterExpand(i: number) {
  684. expandedChapters.value = { ...expandedChapters.value, [i]: !expandedChapters.value[i] };
  685. }
  686. function removeChapter(i: number) {
  687. outlineChapters.value.splice(i, 1);
  688. // 重新编号
  689. outlineChapters.value.forEach((ch: any, idx: number) => { ch.number = idx + 1; });
  690. }
  691. function moveChapter(i: number, dir: number) {
  692. const target = i + dir;
  693. if (target < 0 || target >= outlineChapters.value.length) return;
  694. const tmp = outlineChapters.value[i];
  695. outlineChapters.value[i] = outlineChapters.value[target];
  696. outlineChapters.value[target] = tmp;
  697. // 重新编号
  698. outlineChapters.value.forEach((ch: any, idx: number) => { ch.number = idx + 1; });
  699. }
  700. function addChapter() {
  701. const newNum = outlineChapters.value.length + 1;
  702. outlineChapters.value.push({
  703. number: newNum,
  704. title: `第${newNum}章`,
  705. summary: '',
  706. estimatedWords: 2000,
  707. writingInstructions: '',
  708. sections: [],
  709. subsections: [],
  710. });
  711. }
  712. // Step 3: 保存 Outline
  713. async function doSaveOutline() {
  714. stepLoading.value = true;
  715. try {
  716. const outlineObj = { chapters: outlineChapters.value };
  717. await api.updateInteractiveOutline(bookId.value, outlineObj);
  718. currentStep.value = 3;
  719. doGenerateContent();
  720. } catch (e: any) {
  721. uni.showToast({ title: e.message || '保存失败', icon: 'none' });
  722. } finally {
  723. stepLoading.value = false;
  724. }
  725. }
  726. // Step 4: 生成内容
  727. async function doGenerateContent() {
  728. genStarted.value = true;
  729. genProgress.value = 0;
  730. genError.value = '';
  731. try {
  732. await api.generateInteractiveContent(bookId.value);
  733. // 开始轮询进度
  734. startProgressPolling();
  735. } catch (e: any) {
  736. genError.value = e.message || '生成失败';
  737. }
  738. }
  739. function startProgressPolling() {
  740. progressTimer = setInterval(async () => {
  741. try {
  742. const response = await uni.request({
  743. url: `${BASE_URL}/book-generator/langgraph/books/${bookId.value}/progress`,
  744. method: 'GET',
  745. });
  746. const res = response.data as any;
  747. if (res.code === 0) {
  748. genProgress.value = Math.min(res.data.progress || 0, 100);
  749. if (res.data.genStage === 'completed' || res.data.status === 'completed' || genProgress.value >= 100) {
  750. genProgress.value = 100;
  751. stopProgressPolling();
  752. }
  753. }
  754. } catch (e) { /* ignore */ }
  755. }, 3000);
  756. }
  757. function stopProgressPolling() {
  758. if (progressTimer) {
  759. clearInterval(progressTimer);
  760. progressTimer = null;
  761. }
  762. }
  763. function goToDetail() {
  764. uni.redirectTo({ url: `/pages/book-generator/detail?id=${bookId.value}` });
  765. }
  766. onMounted(() => {
  767. fetchEstimate();
  768. });
  769. </script>
  770. <style scoped>
  771. .page { min-height: 100vh; background: #f9fafb; }
  772. .nav-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
  773. .nav-content { display: flex; align-items: center; height: 88rpx; padding: 0 32rpx; padding-top: env(safe-area-inset-top); }
  774. .nav-left { width: 60rpx; flex-shrink: 0; }
  775. .page-title { font-size: 32rpx; font-weight: 600; color: #1f2937; text-align: center; flex: 1; }
  776. .back-icon { font-size: 40rpx; color: #1f2937; }
  777. /* 模式切换独立行 */
  778. .mode-bar { padding: 0 32rpx 16rpx 32rpx; }
  779. .mode-switch { display: flex; align-items: center; justify-content: center; width: 100%; height: 72rpx; background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); color: #fff; border-radius: 12rpx; font-size: 26rpx; font-weight: 600; }
  780. /* 覆盖 steps-bar 顶部间距 — nav-bar 现在更高了 */
  781. .steps-bar { display: flex; align-items: center; justify-content: center; padding: 24rpx 32rpx; padding-top: calc(88rpx + 16rpx + 72rpx + 16rpx + env(safe-area-inset-top) + 16rpx); background: #fff; position: relative; gap: 60rpx; }
  782. .step-dot { display: flex; flex-direction: column; align-items: center; gap: 8rpx; z-index: 1; }
  783. .dot-num { width: 48rpx; height: 48rpx; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24rpx; font-weight: 600; background: #e5e7eb; color: #9ca3af; transition: all .3s; }
  784. .step-dot.active .dot-num { background: #4f46e5; color: #fff; }
  785. .step-dot.done .dot-num { background: #10b981; color: #fff; }
  786. .dot-label { font-size: 20rpx; color: #9ca3af; white-space: nowrap; }
  787. .step-dot.active .dot-label { color: #4f46e5; font-weight: 600; }
  788. .step-line { position: absolute; top: calc(48rpx + 12rpx); left: calc(32rpx + 24rpx); height: 4rpx; background: #4f46e5; z-index: 0; transition: width .5s; }
  789. .main-content { padding-top: 16rpx; padding-bottom: 48rpx; }
  790. .card { margin: 24rpx; padding: 32rpx; background: #ffffff; border-radius: 16rpx; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
  791. .card-header { margin-bottom: 32rpx; display: flex; align-items: center; justify-content: space-between; }
  792. .card-title { font-size: 36rpx; font-weight: 700; color: #1f2937; }
  793. .loading-hint { font-size: 24rpx; color: #4f46e5; }
  794. .form-item { margin-bottom: 24rpx; }
  795. .form-label { font-size: 28rpx; font-weight: 600; color: #374151; margin-bottom: 12rpx; display: block; }
  796. .form-hint-small { font-size: 24rpx; color: #9ca3af; margin-bottom: 16rpx; display: block; }
  797. .label-with-badge { display: flex; align-items: center; gap: 12rpx; margin-bottom: 12rpx; }
  798. .required-badge { padding: 4rpx 12rpx; background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); color: white; border-radius: 8rpx; font-size: 20rpx; font-weight: 500; display: inline-block; }
  799. .chip-desc { font-size: 20rpx; color: inherit; }
  800. .form-label-sm { font-size: 24rpx; font-weight: 600; color: #374151; margin-bottom: 8rpx; display: block; }
  801. .form-input { width: 100%; height: 88rpx; padding: 0 24rpx; background: #f9fafb; border: 2rpx solid #e5e7eb; border-radius: 12rpx; font-size: 28rpx; }
  802. .form-input-sm { width: 100%; height: 72rpx; padding: 0 16rpx; background: #f9fafb; border: 2rpx solid #e5e7eb; border-radius: 8rpx; font-size: 26rpx; }
  803. .form-textarea { width: 100%; min-height: 160rpx; padding: 24rpx; background: #f9fafb; border: 2rpx solid #e5e7eb; border-radius: 12rpx; font-size: 28rpx; line-height: 1.6; }
  804. .form-textarea-sm { width: 100%; min-height: 100rpx; padding: 16rpx; background: #f9fafb; border: 2rpx solid #e5e7eb; border-radius: 8rpx; font-size: 24rpx; line-height: 1.5; }
  805. .chip-group { display: flex; flex-wrap: wrap; gap: 12rpx; }
  806. .chip { display: flex; align-items: center; gap: 8rpx; padding: 12rpx 20rpx; background: #f3f4f6; border-radius: 24rpx; font-size: 24rpx; color: #4b5563; transition: all .2s; }
  807. .chip.active { background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); color: white; }
  808. .chip-icon { font-size: 24rpx; }
  809. .chip-text { font-size: 24rpx; }
  810. .scale-picker { display: flex; flex-wrap: wrap; gap: 12rpx; }
  811. .scale-chip { display: flex; flex-direction: column; align-items: center; gap: 4rpx; padding: 12rpx 16rpx; background: #f3f4f6; border-radius: 12rpx; min-width: 100rpx; transition: all .2s; }
  812. .scale-chip.active { background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); color: white; }
  813. .scale-label { font-size: 24rpx; font-weight: 600; }
  814. .scale-desc { font-size: 20rpx; color: #9ca3af; }
  815. .estimate-card { padding: 24rpx; background: rgba(79,70,229,.05); border-radius: 12rpx; margin-bottom: 24rpx; }
  816. .estimate-row { display: flex; justify-content: space-between; padding: 8rpx 0; }
  817. .estimate-label { font-size: 24rpx; color: #6b7280; }
  818. .estimate-value { font-size: 24rpx; color: #4f46e5; font-weight: 600; }
  819. .btn-group { display: flex; flex-direction: column; gap: 12rpx; margin-top: 32rpx; }
  820. .btn-primary { width: 100%; height: 88rpx; background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); color: white; border-radius: 12rpx; font-size: 28rpx; font-weight: 600; border: none; display: flex; align-items: center; justify-content: center; white-space: nowrap; }
  821. .btn-secondary { width: 100%; height: 88rpx; background: #f3f4f6; color: #4b5563; border-radius: 12rpx; font-size: 28rpx; font-weight: 600; border: none; display: flex; align-items: center; justify-content: center; white-space: nowrap; }
  822. .btn-cancel { width: 100%; height: 88rpx; background: #f3f4f6; color: #6b7280; border-radius: 12rpx; font-size: 28rpx; border: none; display: flex; align-items: center; justify-content: center; white-space: nowrap; }
  823. .btn-row-sm { display: flex; gap: 8rpx; margin-top: 12rpx; }
  824. .btn-delete-sm { padding: 8rpx 16rpx; background: #fef2f2; color: #ef4444; border-radius: 8rpx; font-size: 22rpx; border: none; }
  825. .btn-move-sm { padding: 8rpx 16rpx; background: #f3f4f6; color: #6b7280; border-radius: 8rpx; font-size: 22rpx; border: none; }
  826. .btn-add-chapter { width: 100%; height: 72rpx; margin-top: 16rpx; background: #eef2ff; color: #4f46e5; border: 2rpx dashed #c7d2fe; border-radius: 12rpx; font-size: 26rpx; font-weight: 600; display: flex; align-items: center; justify-content: center; }
  827. button[disabled] { opacity: .5; }
  828. /* Plan Review */
  829. .plan-review { margin-top: 16rpx; }
  830. .plan-section { margin-bottom: 24rpx; padding: 20rpx; background: #f9fafb; border-radius: 12rpx; }
  831. .plan-section-header { display: flex; align-items: center; gap: 8rpx; margin-bottom: 12rpx; }
  832. .plan-section-icon { font-size: 28rpx; }
  833. .plan-section-title { font-size: 26rpx; font-weight: 600; color: #374151; }
  834. .plan-section-hint { font-size: 22rpx; color: #9ca3af; margin-left: auto; }
  835. .plan-textarea { width: 100%; min-height: 80rpx; padding: 16rpx; background: #ffffff; border: 2rpx solid #e5e7eb; border-radius: 8rpx; font-size: 26rpx; line-height: 1.6; }
  836. .plan-empty { padding: 24rpx; text-align: center; }
  837. .empty-text { font-size: 24rpx; color: #9ca3af; }
  838. /* Plan Summary Tags */
  839. .plan-summary { display: flex; flex-wrap: wrap; gap: 12rpx; margin-bottom: 24rpx; }
  840. .summary-tag { font-size: 22rpx; padding: 8rpx 16rpx; background: #eef2ff; color: #4338ca; border-radius: 8rpx; line-height: 1.5; }
  841. /* Narrative Arc */
  842. .narrative-parts { display: flex; flex-direction: column; gap: 16rpx; }
  843. .narrative-part-card { background: #ffffff; border: 2rpx solid #e5e7eb; border-radius: 12rpx; overflow: hidden; }
  844. .part-badge { padding: 10rpx 20rpx; background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); color: #fff; font-size: 24rpx; font-weight: 600; }
  845. .part-body { padding: 20rpx; display: flex; flex-direction: column; gap: 16rpx; }
  846. .part-field { display: flex; flex-direction: column; gap: 6rpx; }
  847. .part-label { font-size: 22rpx; color: #6b7280; font-weight: 600; }
  848. .part-text { font-size: 24rpx; color: #374151; }
  849. /* Tone Fields */
  850. .tone-fields { display: flex; flex-direction: column; gap: 16rpx; }
  851. .tone-row { display: flex; flex-direction: column; gap: 8rpx; }
  852. .tone-label { font-size: 24rpx; color: #6b7280; font-weight: 600; }
  853. /* Audience Fields */
  854. .audience-fields { display: flex; flex-direction: column; gap: 16rpx; }
  855. .audience-row { display: flex; flex-direction: column; gap: 8rpx; }
  856. .audience-label { font-size: 24rpx; color: #6b7280; font-weight: 600; }
  857. /* Tag List (avoidPatterns etc) */
  858. .tag-list { display: flex; flex-wrap: wrap; gap: 10rpx; }
  859. .tag-item { display: flex; align-items: center; gap: 6rpx; padding: 8rpx 14rpx; background: #fee2e2; border-radius: 8rpx; font-size: 22rpx; }
  860. .tag-item-static { padding: 8rpx 14rpx; background: #eef2ff; color: #4338ca; border-radius: 8rpx; font-size: 22rpx; }
  861. .tag-text { color: #dc2626; }
  862. .tag-remove { color: #ef4444; font-weight: 700; font-size: 24rpx; padding: 0 4rpx; }
  863. .tag-add { padding: 8rpx 14rpx; background: #f3f4f6; color: #6b7280; border-radius: 8rpx; font-size: 22rpx; border: 2rpx dashed #d1d5db; }
  864. /* Feedback Section */
  865. .feedback-section { background: #fef9c3; }
  866. .feedback-textarea { width: 100%; min-height: 120rpx; padding: 16rpx; background: #ffffff; border: 2rpx solid #fde68a; border-radius: 8rpx; font-size: 26rpx; line-height: 1.6; }
  867. .feedback-hint { font-size: 22rpx; color: #a16207; margin-top: 10rpx; }
  868. /* Form textarea xs (compact) */
  869. .form-textarea-xs { width: 100%; min-height: 72rpx; padding: 12rpx 16rpx; background: #ffffff; border: 2rpx solid #e5e7eb; border-radius: 8rpx; font-size: 24rpx; line-height: 1.5; }
  870. /* Outline Review */
  871. .outline-review { margin-top: 16rpx; }
  872. .outline-subtitle { font-size: 24rpx; color: #9ca3af; margin-bottom: 16rpx; display: block; }
  873. .chapter-card { margin-bottom: 16rpx; background: #f9fafb; border-radius: 12rpx; overflow: hidden; }
  874. .chapter-header { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; cursor: pointer; }
  875. .chapter-num { font-size: 26rpx; font-weight: 600; color: #374151; }
  876. .expand-icon { font-size: 24rpx; color: #9ca3af; }
  877. .chapter-edit { padding: 0 24rpx 24rpx; }
  878. /* Loading */
  879. .loading-box { display: flex; flex-direction: column; align-items: center; padding: 64rpx 0; gap: 24rpx; }
  880. .loading-spinner { width: 56rpx; height: 56rpx; border: 4rpx solid #e5e7eb; border-top-color: #4f46e5; border-radius: 50%; animation: spin 1s linear infinite; }
  881. @keyframes spin { to { transform: rotate(360deg); } }
  882. .loading-text { font-size: 26rpx; color: #6b7280; }
  883. /* Error */
  884. .error-box { padding: 24rpx; background: #fef2f2; border-radius: 12rpx; margin-top: 16rpx; }
  885. .error-text { font-size: 24rpx; color: #ef4444; }
  886. /* Step 4 Generate */
  887. .generate-box { display: flex; flex-direction: column; gap: 32rpx; padding: 32rpx 0; }
  888. .generate-stage { display: flex; align-items: center; gap: 16rpx; opacity: .4; }
  889. .generate-stage.completed { opacity: 1; }
  890. .stage-icon { font-size: 40rpx; }
  891. .stage-info { display: flex; flex-direction: column; gap: 4rpx; }
  892. .stage-title { font-size: 28rpx; font-weight: 600; color: #374151; }
  893. .stage-hint { font-size: 22rpx; color: #9ca3af; }
  894. .progress-bar-wrap { padding: 16rpx 0; }
  895. .progress-bar { height: 12rpx; background: linear-gradient(90deg, #4f46e5, #6366f1); border-radius: 6rpx; transition: width .5s; }
  896. .progress-text { font-size: 24rpx; color: #4f46e5; text-align: center; display: block; margin-top: 12rpx; }
  897. </style>