DialogueChatView.vue 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. <template>
  2. <div class="dialogue-chat-view">
  3. <!-- ── HEADER ── -->
  4. <div class="chat-header">
  5. <div class="header-left">
  6. <div
  7. class="ai-avatar"
  8. :class="{ breathing: state === 'idle' || state === 'ai_thinking' }"
  9. >{{ aiAvatar }}</div>
  10. <span class="ai-name">{{ aiName }}</span>
  11. <span v-if="state === 'idle' && showIdleHint" class="idle-hint fade-in">
  12. 在等你的回答...
  13. </span>
  14. <span
  15. v-else-if="state !== 'idle' && state !== 'ai_thinking'"
  16. class="online-dot"
  17. title="在线"
  18. />
  19. </div>
  20. <div class="header-right">
  21. <span class="round-indicator">{{ currentRound }} / {{ totalRounds }} 轮</span>
  22. <span v-if="engine.countdownSeconds.value != null" class="total-time">
  23. {{ formatSeconds(engine.countdownSeconds.value) }}
  24. </span>
  25. <button class="icon-btn" title="更多操作" @click="showExitConfirm = true">
  26. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  27. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  28. <circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />
  29. </svg>
  30. </button>
  31. </div>
  32. </div>
  33. <!-- 麦克风权限引导 -->
  34. <div v-if="recorder.permissionState.value === 'denied'" class="permission-banner">
  35. <span class="permission-icon">🎤</span>
  36. <span>麦克风权限已被拒绝,请在浏览器设置中开启后刷新页面</span>
  37. </div>
  38. <!-- ── CHAT AREA ── -->
  39. <div ref="chatContainerRef" class="chat-area">
  40. <template v-for="message in engine.messages.value" :key="message.id">
  41. <!-- AI 消息 -->
  42. <div v-if="message.role === 'ai'" class="msg-row msg-ai fade-in">
  43. <div class="avatar-sm">{{ aiAvatar }}</div>
  44. <div class="msg-col">
  45. <!-- 音频条 -->
  46. <div v-if="message.content || message.status === 'done'" class="voice-bar voice-ai">
  47. <button
  48. class="play-btn play-ai"
  49. :class="{ 'play-btn-error': player.errorId.value === message.id }"
  50. @click="togglePlay(message.id)"
  51. >
  52. <svg
  53. v-if="player.loadingId.value === message.id"
  54. class="play-spinner"
  55. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  56. stroke-width="2" stroke-linecap="round"
  57. >
  58. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  59. </svg>
  60. <svg
  61. v-else-if="player.playingId.value === message.id"
  62. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  63. >
  64. <rect x="6" y="4" width="4" height="16" /><rect x="14" y="4" width="4" height="16" />
  65. </svg>
  66. <svg
  67. v-else-if="player.errorId.value === message.id"
  68. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  69. stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  70. >
  71. <path d="M12 9v4" />
  72. <path d="M12 17h.01" />
  73. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
  74. </svg>
  75. <svg
  76. v-else
  77. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  78. >
  79. <polygon points="5 3 19 12 5 21 5 3" />
  80. </svg>
  81. </button>
  82. <div class="wave-bar-group">
  83. <div
  84. v-for="i in 14"
  85. :key="i"
  86. class="wave-bar wave-ai"
  87. :style="{ height: `${Math.abs(Math.sin(i * 0.7)) * 8 + 3}px` }"
  88. />
  89. </div>
  90. <span
  91. v-if="player.errorId.value === message.id"
  92. class="play-error-hint"
  93. >点击重试</span>
  94. <span
  95. v-else
  96. class="voice-duration voice-duration-ai"
  97. >0:04</span>
  98. </div>
  99. <!-- 英文文本 -->
  100. <div v-if="showEnglishText && message.content" class="bubble bubble-ai">
  101. {{ message.content }}
  102. </div>
  103. <!-- 流式加载中 -->
  104. <div v-if="message.status === 'loading' && !message.content" class="typing-bubble">
  105. <span class="typing-dot" style="animation-delay: 0ms" />
  106. <span class="typing-dot" style="animation-delay: 150ms" />
  107. <span class="typing-dot" style="animation-delay: 300ms" />
  108. </div>
  109. <!-- AI 错误 -->
  110. <div v-if="message.status === 'error'" class="error-card">
  111. <span class="error-text">{{ message.error || '生成失败' }}</span>
  112. <button
  113. v-if="hasRetryButton(message)"
  114. class="retry-btn"
  115. :disabled="engine.greetingInflight.value"
  116. @click="handleRetry(message)"
  117. >{{ retryButtonLabel(message) }}</button>
  118. </div>
  119. </div>
  120. </div>
  121. <!-- 学生消息 -->
  122. <div v-else class="msg-row msg-student fade-in">
  123. <!-- 音频条(橙色) -->
  124. <div v-if="message.content || message.status !== 'loading'" class="voice-bar voice-student">
  125. <span
  126. v-if="player.errorId.value === message.id"
  127. class="play-error-hint play-error-hint-student"
  128. >点击重试</span>
  129. <span
  130. v-else
  131. class="voice-duration voice-duration-student"
  132. >0:04</span>
  133. <div class="wave-bar-group">
  134. <div
  135. v-for="i in 14"
  136. :key="i"
  137. class="wave-bar wave-student"
  138. :style="{ height: `${Math.abs(Math.sin(i * 0.7)) * 8 + 3}px` }"
  139. />
  140. </div>
  141. <button
  142. class="play-btn play-student"
  143. :class="{ 'play-btn-error': player.errorId.value === message.id }"
  144. @click="togglePlay(message.id)"
  145. >
  146. <svg
  147. v-if="player.loadingId.value === message.id"
  148. class="play-spinner"
  149. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  150. stroke-width="2" stroke-linecap="round"
  151. >
  152. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  153. </svg>
  154. <svg
  155. v-else-if="player.playingId.value === message.id"
  156. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  157. >
  158. <rect x="6" y="4" width="4" height="16" /><rect x="14" y="4" width="4" height="16" />
  159. </svg>
  160. <svg
  161. v-else-if="player.errorId.value === message.id"
  162. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  163. stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  164. >
  165. <path d="M12 9v4" />
  166. <path d="M12 17h.01" />
  167. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
  168. </svg>
  169. <svg
  170. v-else
  171. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  172. >
  173. <polygon points="5 3 19 12 5 21 5 3" />
  174. </svg>
  175. </button>
  176. </div>
  177. <!-- 学生 STT 加载中(与 AI typing-bubble 对称,避免按完成后 student 侧空白) -->
  178. <div v-if="message.status === 'loading' && !message.content" class="typing-bubble typing-bubble-student">
  179. <span class="typing-dot" style="animation-delay: 0ms" />
  180. <span class="typing-dot" style="animation-delay: 150ms" />
  181. <span class="typing-dot" style="animation-delay: 300ms" />
  182. </div>
  183. <!-- 英文识别文本(带高亮) -->
  184. <div v-if="showEnglishText && message.content" class="bubble bubble-student">
  185. <template v-if="message.evaluation?.wordAnalysis">
  186. <template v-for="(word, idx) in message.content.split(' ')" :key="idx">
  187. <span
  188. v-if="getWordAnalysis(message, word)?.status === 'improvable'"
  189. class="improvable-word"
  190. @click="openPhonemeDetail(getWordAnalysis(message, word)!)"
  191. >{{ word }}</span>
  192. <span v-else>{{ word }}</span>
  193. {{ ' ' }}
  194. </template>
  195. </template>
  196. <template v-else>{{ message.content }}</template>
  197. </div>
  198. <!-- 学生错误 -->
  199. <div v-if="message.status === 'error'" class="error-card">
  200. <span class="error-text">{{ message.error || '发送失败' }}</span>
  201. <button
  202. v-if="hasRetryButton(message)"
  203. class="retry-btn"
  204. @click="handleRetry(message)"
  205. >{{ retryButtonLabel(message) }}</button>
  206. <button
  207. v-if="hasRerecordButton(message)"
  208. class="rerecord-btn"
  209. @click="handleRerecord(message)"
  210. >重录</button>
  211. </div>
  212. <!-- L1 评分卡 -->
  213. <div v-if="message.evaluation" class="eval-card">
  214. <div class="eval-l1">
  215. <div class="dim-row">
  216. <span class="dim-label">准确</span>
  217. <DimBadge :level="message.evaluation.dimensions.accuracy" />
  218. <span class="dim-sep">|</span>
  219. <span class="dim-label">流畅</span>
  220. <DimBadge :level="message.evaluation.dimensions.fluency" />
  221. <span class="dim-sep">|</span>
  222. <span class="dim-label">完整</span>
  223. <DimBadge :level="message.evaluation.dimensions.completeness" />
  224. <span class="dim-sep">|</span>
  225. <span class="dim-label">节奏</span>
  226. <DimBadge :level="message.evaluation.dimensions.rhythm" />
  227. </div>
  228. <div class="sugg-row">
  229. <p class="sugg-text">
  230. <span class="sugg-icon">💡</span>
  231. <span class="truncate">{{ message.evaluation.suggestion }}</span>
  232. </p>
  233. <button class="detail-toggle" @click="toggleExpand(message.id)">
  234. {{ expandedMessageId === message.id ? '收起' : '详情' }}
  235. <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  236. stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  237. :class="{ 'chev-up': expandedMessageId === message.id }">
  238. <polyline points="6 9 12 15 18 9" />
  239. </svg>
  240. </button>
  241. </div>
  242. </div>
  243. <div v-if="expandedMessageId === message.id" class="eval-l2 fade-in">
  244. <div v-if="message.evaluation.betterExpression" class="better-exp">
  245. <p class="detail-label"><span>✨</span> Better expression:</p>
  246. <p class="detail-content">{{ message.evaluation.betterExpression }}</p>
  247. </div>
  248. <div v-if="message.evaluation.suggestedWords?.length" class="suggested-words">
  249. <p class="detail-label"><span>🎯</span> Try these words:</p>
  250. <div class="word-tags">
  251. <span v-for="(w, i) in message.evaluation.suggestedWords" :key="i" class="word-tag">{{ w }}</span>
  252. </div>
  253. </div>
  254. </div>
  255. </div>
  256. </div>
  257. </template>
  258. </div>
  259. <!-- 沉默提示浮层 -->
  260. <div v-if="state === 'recording' && silenceHintText" class="silence-hint-wrap">
  261. <div class="silence-hint fade-in">
  262. <span class="silence-icon">💡</span>
  263. <p class="silence-text">{{ silenceHintText }}</p>
  264. <button class="silence-close" @click="silenceHintText = ''">
  265. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  266. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  267. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  268. </svg>
  269. </button>
  270. </div>
  271. </div>
  272. <!-- ── CONTROL ZONE ── -->
  273. <div class="control-zone">
  274. <!-- 进度条(仅录音时可见) -->
  275. <div class="progress-wrap">
  276. <div
  277. class="progress-track"
  278. :style="{ background: state === 'recording' ? '#f3f4f6' : 'transparent' }"
  279. >
  280. <div
  281. class="progress-fill"
  282. :class="{ 'near-limit': isNearLimit }"
  283. :style="{
  284. width: state === 'recording' ? `${progressPct}%` : '0%',
  285. opacity: state === 'recording' ? 1 : 0,
  286. }"
  287. />
  288. </div>
  289. </div>
  290. <!-- 状态叠放区 -->
  291. <div class="state-stack">
  292. <!-- idle -->
  293. <div
  294. class="state-layer state-idle"
  295. :style="stateStyle('idle')"
  296. >
  297. <button class="hint-btn" @click="openTaskHint">
  298. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  299. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  300. <path d="M9 18h6" /><path d="M10 22h4" />
  301. <path d="M15.09 14c.18-.98.65-1.74 1.41-2.5A4.65 4.65 0 0 0 18 8 6 6 0 0 0 6 8c0 1 .23 2.23 1.5 3.5A4.61 4.61 0 0 1 8.91 14" />
  302. </svg>
  303. 提示
  304. </button>
  305. <button
  306. class="mic-btn"
  307. :disabled="!engine.canRecord.value"
  308. @click="handleStartRecording"
  309. >
  310. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  311. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  312. <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" />
  313. <path d="M19 10v2a7 7 0 0 1-14 0v-2" />
  314. <line x1="12" y1="19" x2="12" y2="23" />
  315. <line x1="8" y1="23" x2="16" y2="23" />
  316. </svg>
  317. 开始录音
  318. </button>
  319. </div>
  320. <!-- starting -->
  321. <div class="state-layer state-starting" :style="stateStyle('starting')">
  322. <div class="record-capsule">
  323. <button class="cancel-btn" @click="handleCancelStarting">
  324. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  325. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  326. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  327. </svg>
  328. 取消
  329. </button>
  330. <div class="record-meter">
  331. <svg class="spinner" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  332. stroke-width="2" stroke-linecap="round">
  333. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  334. </svg>
  335. <span class="record-time">准备录音中...</span>
  336. </div>
  337. <button class="finish-btn" disabled>
  338. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  339. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  340. <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
  341. <polyline points="22 4 12 14.01 9 11.01" />
  342. </svg>
  343. 完成
  344. </button>
  345. </div>
  346. </div>
  347. <!-- recording -->
  348. <div class="state-layer state-recording" :style="stateStyle('recording')">
  349. <div class="record-capsule">
  350. <button class="cancel-btn" @click="handleCancelRecording">
  351. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  352. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  353. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  354. </svg>
  355. 取消
  356. </button>
  357. <div class="record-meter">
  358. <div class="animated-wave">
  359. <div
  360. v-for="i in 7"
  361. :key="i"
  362. class="aw-bar"
  363. :class="{ 'near-limit': isNearLimit }"
  364. :style="{
  365. height: `${Math.abs(Math.sin(i * 0.9)) * 9 + 3}px`,
  366. animationDelay: `${(i - 1) * 0.1}s`,
  367. }"
  368. />
  369. </div>
  370. <span class="record-time" :class="{ 'near-limit': isNearLimit }">
  371. {{ formatSeconds(recorder.recordingDuration.value) }}
  372. </span>
  373. <span class="record-time-max">/ {{ formatSeconds(MAX_RECORDING_SECONDS) }}</span>
  374. </div>
  375. <button class="finish-btn" @click="handleFinishRecording">
  376. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  377. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  378. <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
  379. <polyline points="22 4 12 14.01 9 11.01" />
  380. </svg>
  381. 完成
  382. </button>
  383. </div>
  384. </div>
  385. <!-- stt -->
  386. <div class="state-layer state-center" :style="stateStyle('stt')">
  387. <svg class="spinner" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  388. stroke-width="2" stroke-linecap="round">
  389. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  390. </svg>
  391. <span class="center-text">正在识别语音...</span>
  392. </div>
  393. <!-- ai_thinking -->
  394. <div class="state-layer state-center" :style="stateStyle('ai_thinking')">
  395. <div class="mini-avatar">{{ aiAvatar }}</div>
  396. <span class="center-text">{{ aiName }} 正在回复...</span>
  397. </div>
  398. <!-- error -->
  399. <div class="state-layer state-error" :style="stateStyle('error')">
  400. <div class="error-info">
  401. <span class="warn-icon">⚠️</span>
  402. <span class="warn-text">{{ lastErrorText }}</span>
  403. </div>
  404. <button
  405. v-if="lastErroredMessage && hasRetryButton(lastErroredMessage)"
  406. class="retry-pill"
  407. @click="handleRetry(lastErroredMessage)"
  408. >{{ retryButtonLabel(lastErroredMessage) }}</button>
  409. </div>
  410. <!-- finalizing -->
  411. <div class="state-layer state-center" :style="stateStyle('finalizing')">
  412. <svg class="spinner" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  413. stroke-width="2" stroke-linecap="round">
  414. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  415. </svg>
  416. <span class="center-text">正在生成你的本次对话报告...</span>
  417. </div>
  418. </div>
  419. </div>
  420. <!-- ─────── OVERLAYS ─────── -->
  421. <!-- 任务提示弹窗 -->
  422. <TaskHintModal
  423. :visible="showHintModal"
  424. :loading="taskHintLoading"
  425. :error="taskHintError"
  426. :hint="taskHint"
  427. :ai-name="aiName"
  428. @close="showHintModal = false"
  429. @retry="loadTaskHint"
  430. />
  431. <!-- 音素详情弹窗 -->
  432. <div v-if="phonemeDetail" class="modal-mask" @click.self="phonemeDetail = null">
  433. <div class="modal phoneme-modal scale-in">
  434. <div class="modal-head">
  435. <div>
  436. <h3 class="phoneme-word">{{ phonemeDetail.word }}</h3>
  437. <p class="phoneme-sub">发音详情</p>
  438. </div>
  439. <button class="close-btn" @click="phonemeDetail = null">
  440. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  441. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  442. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  443. </svg>
  444. </button>
  445. </div>
  446. <div class="phoneme-body">
  447. <div class="pho-card pho-user">
  448. <div>
  449. <p class="pho-label">你的发音</p>
  450. <p class="pho-value">{{ phonemeDetail.userPronunciation }}</p>
  451. </div>
  452. <button class="pho-play pho-play-user">
  453. <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3" /></svg>
  454. </button>
  455. </div>
  456. <div class="pho-card pho-standard">
  457. <div>
  458. <p class="pho-label">标准发音</p>
  459. <p class="pho-value pho-value-green">{{ phonemeDetail.standardPronunciation }}</p>
  460. </div>
  461. <button class="pho-play pho-play-standard">
  462. <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3" /></svg>
  463. </button>
  464. </div>
  465. <div v-if="phonemeDetail.tip" class="pho-card pho-tip">
  466. <p class="pho-label">小提示</p>
  467. <p class="pho-tip-text">{{ phonemeDetail.tip }}</p>
  468. </div>
  469. <button class="pho-practice-btn" @click="practiceThisWord">
  470. 针对这个词重练一次
  471. </button>
  472. </div>
  473. </div>
  474. </div>
  475. <!-- 退出/重开确认弹窗 -->
  476. <div v-if="showExitConfirm" class="modal-mask" @click.self="showExitConfirm = false">
  477. <div class="modal exit-modal scale-in">
  478. <div class="modal-head">
  479. <h3 class="modal-title">选择操作</h3>
  480. <button class="close-btn" @click="showExitConfirm = false">
  481. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  482. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  483. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  484. </svg>
  485. </button>
  486. </div>
  487. <p class="exit-hint">请选择你的操作:</p>
  488. <div class="exit-actions">
  489. <button class="exit-secondary" @click="showExitConfirm = false">继续练习</button>
  490. <button class="exit-secondary" @click="handleRestart">重新开始</button>
  491. <button class="exit-primary" @click="handleExitConfirm">结束并查看报告</button>
  492. </div>
  493. </div>
  494. </div>
  495. <!-- 徽章弹窗 -->
  496. <div v-if="showBadge" class="badge-popup scale-in">
  497. <div class="badge-card">
  498. <span class="badge-icon">{{ showBadge.icon }}</span>
  499. <div>
  500. <p class="badge-name">{{ showBadge.name }}</p>
  501. <p class="badge-desc">{{ showBadge.description }}</p>
  502. </div>
  503. </div>
  504. </div>
  505. </div>
  506. </template>
  507. <script lang="ts" setup>
  508. import { ref, computed, watch, onMounted, onUnmounted, nextTick, h, defineComponent } from 'vue'
  509. import type { PropType } from 'vue'
  510. import type { PreviewChatMessage, BadgeAchievement, DialogueReport, SessionStartInfo, TaskHint } from '@/types/englishSpeaking'
  511. import { useDialogueEngine } from '../composables/useDialogueEngine'
  512. import { useAudioRecorder } from '../composables/useAudioRecorder'
  513. import { useAudioPlayer } from '../composables/useAudioPlayer'
  514. import TaskHintModal from './TaskHintModal.vue'
  515. import { createDialogueApi } from '../services/llmService'
  516. import { SPEAKING_TRANSPORT } from '../services/speakingApiConfig'
  517. // ─────────────────────────────────────────────
  518. // Props / Emits
  519. // ─────────────────────────────────────────────
  520. interface Props {
  521. topic?: string
  522. keywords?: string[]
  523. aiName?: string
  524. aiAvatar?: string
  525. totalRounds?: number
  526. showEnglishText?: boolean
  527. showChineseText?: boolean
  528. sessionInfo?: SessionStartInfo | null
  529. }
  530. const props = withDefaults(defineProps<Props>(), {
  531. topic: '',
  532. keywords: () => ['animal', 'zoo', 'cute', 'favorite'],
  533. aiName: 'Tom',
  534. aiAvatar: '😊',
  535. totalRounds: 3,
  536. showEnglishText: true,
  537. showChineseText: false,
  538. sessionInfo: null,
  539. })
  540. const emit = defineEmits<{
  541. complete: [report: DialogueReport | null]
  542. restart: []
  543. }>()
  544. // ─────────────────────────────────────────────
  545. // Config
  546. // ─────────────────────────────────────────────
  547. const MAX_RECORDING_SECONDS = 60
  548. // 学生录音上送方式:'websocket'(默认,流式)或 'http'(单次 POST /speak)。
  549. // 由环境变量 VITE_SPEAKING_TRANSPORT 控制;未配置时默认 websocket。
  550. const speakTransport = SPEAKING_TRANSPORT
  551. const SILENCE_HINTS = [
  552. 'You could say: "I really like pandas because they are so cute!"',
  553. 'Try: "My favorite animal is the elephant. It\'s very smart."',
  554. 'You could say: "I went to the zoo last weekend with my family."',
  555. ]
  556. const BADGE_CONFIG: Record<string, BadgeAchievement> = {
  557. smooth_talker: { id: 'smooth_talker', name: '流畅达人', nameEn: 'Smooth Talker', icon: '💬', description: '连续3句流畅度优秀' },
  558. pronunciation_pro: { id: 'pronunciation_pro', name: '发音专家', nameEn: 'Pronunciation Pro', icon: '🎯', description: '连续5句发音准确' },
  559. perfect_round: { id: 'perfect_round', name: '完美一轮', nameEn: 'Perfect Round', icon: '⭐', description: '单轮四维度全优' },
  560. }
  561. // ─────────────────────────────────────────────
  562. // Composables
  563. // ─────────────────────────────────────────────
  564. const engine = useDialogueEngine()
  565. const recorder = useAudioRecorder()
  566. const player = useAudioPlayer()
  567. // ─────────────────────────────────────────────
  568. // Local UI State
  569. // ─────────────────────────────────────────────
  570. const chatContainerRef = ref<HTMLDivElement>()
  571. const expandedMessageId = ref<string | null>(null)
  572. const showHintModal = ref(false)
  573. const taskHint = ref<TaskHint | null>(null)
  574. const taskHintLoading = ref(false)
  575. const taskHintError = ref<string | null>(null)
  576. const taskHintApi = createDialogueApi()
  577. const showExitConfirm = ref(false)
  578. const phonemeDetail = ref<{
  579. word: string
  580. userPronunciation?: string
  581. standardPronunciation?: string
  582. tip?: string
  583. } | null>(null)
  584. const silenceHintText = ref('')
  585. const showIdleHint = ref(false)
  586. let idleHintTimer: ReturnType<typeof setTimeout> | null = null
  587. const isStarting = ref(false)
  588. const reportFetchInflight = ref(false)
  589. let startAbortController: AbortController | null = null
  590. // 徽章
  591. const showBadge = ref<BadgeAchievement | null>(null)
  592. const consecutiveFluent = ref(0)
  593. const consecutiveAccurate = ref(0)
  594. let badgeTimer: ReturnType<typeof setTimeout> | null = null
  595. // ─────────────────────────────────────────────
  596. // Derived State
  597. // ─────────────────────────────────────────────
  598. const currentRound = computed(() => engine.currentRound.value)
  599. // 状态机:starting → recording → stt → ai_thinking → idle / error / finalizing / done
  600. const state = computed<
  601. 'idle' | 'starting' | 'recording' | 'stt' | 'ai_thinking' | 'finalizing' | 'error' | 'done'
  602. >(() => {
  603. if (isStarting.value) return 'starting'
  604. if (recorder.isRecording.value) return 'recording'
  605. if (engine.isComplete.value) return reportFetchInflight.value ? 'finalizing' : 'done'
  606. const msgs = engine.messages.value
  607. const last = msgs[msgs.length - 1]
  608. if (last?.status === 'error') return 'error'
  609. // 学生消息 loading 且无 content → 正在 STT
  610. if (last?.role === 'student' && last.status === 'loading' && !last.content) return 'stt'
  611. if (engine.isProcessing.value) return 'ai_thinking'
  612. return 'idle'
  613. })
  614. const progressPct = computed(() => Math.min((recorder.recordingDuration.value / MAX_RECORDING_SECONDS) * 100, 100))
  615. const isNearLimit = computed(() => recorder.recordingDuration.value >= MAX_RECORDING_SECONDS * 0.8)
  616. const lastErrorText = computed(() => {
  617. const msgs = engine.messages.value
  618. const last = msgs[msgs.length - 1]
  619. return last?.error || '请求异常,请稍后再试'
  620. })
  621. // ─────────────────────────────────────────────
  622. // Sub-Component: DimBadge
  623. // ─────────────────────────────────────────────
  624. const DimBadge = defineComponent({
  625. props: { level: { type: String as PropType<'excellent' | 'good' | 'improve'>, required: true } },
  626. setup(p) {
  627. return () => {
  628. if (p.level === 'excellent') return h('span', { class: 'dim-badge dim-excellent' }, '✓✓')
  629. if (p.level === 'good') return h('span', { class: 'dim-badge dim-good' }, '✓')
  630. return h('span', { class: 'dim-badge dim-improve' }, '△')
  631. }
  632. },
  633. })
  634. // ─────────────────────────────────────────────
  635. // Helpers
  636. // ─────────────────────────────────────────────
  637. function formatSeconds(s: number): string {
  638. const m = Math.floor(s / 60)
  639. const sec = s % 60
  640. return `${m}:${sec.toString().padStart(2, '0')}`
  641. }
  642. function getWordAnalysis(message: PreviewChatMessage, word: string) {
  643. const clean = word.replace(/[.,!?]/g, '')
  644. return message.evaluation?.wordAnalysis?.find(w => w.word === clean)
  645. }
  646. function stateStyle(target: string) {
  647. const active = state.value === target
  648. return {
  649. opacity: active ? 1 : 0,
  650. pointerEvents: active ? 'auto' : 'none',
  651. transition: 'opacity 0.18s ease-out',
  652. } as const
  653. }
  654. // ─────────────────────────────────────────────
  655. // Actions
  656. // ─────────────────────────────────────────────
  657. // 当前流式会话控制器(开始录音时打开 WebSocket,结束时收尾)
  658. let streamCtl: ReturnType<typeof engine.beginStudentStream> = null
  659. async function handleStartRecording() {
  660. if (!engine.canRecord.value || recorder.isRecording.value || isStarting.value) return
  661. player.stop()
  662. isStarting.value = true
  663. startAbortController = new AbortController()
  664. try {
  665. await recorder.startRecording(startAbortController.signal)
  666. // 学生录音上送方式由 speakingApiConfig.SPEAKING_TRANSPORT 决定:
  667. // - websocket(默认):开 WS 流式推 PCM;失败由 useDialogueEngine 暴露 error,用户点"重试"才走 HTTP。
  668. // - http:跳过 WS,handleFinishRecording 直接走 sendStudentMessage → /speak。
  669. if (speakTransport === 'websocket') {
  670. streamCtl = engine.beginStudentStream({
  671. sampleRate: recorder.sampleRate.value,
  672. bits: 16,
  673. channels: 1,
  674. })
  675. if (streamCtl) {
  676. recorder.onChunk.value = streamCtl.pushChunk
  677. }
  678. }
  679. } catch (err: any) {
  680. if (err.name === 'AbortError') {
  681. // User cancelled during getUserMedia. State naturally returns to idle.
  682. } else {
  683. console.error('Failed to start recording:', err)
  684. }
  685. } finally {
  686. isStarting.value = false
  687. startAbortController = null
  688. }
  689. }
  690. function handleCancelStarting() {
  691. startAbortController?.abort()
  692. // recorder.startRecording will reject with AbortError; no further cleanup needed.
  693. }
  694. function handleCancelRecording() {
  695. // 停止录音 + 中止流式会话(丢弃本次录音)
  696. recorder.onChunk.value = null
  697. if (streamCtl) {
  698. streamCtl.abort() // close WS; nothing on the message list to clean
  699. streamCtl = null
  700. }
  701. if (recorder.isRecording.value) {
  702. recorder.stopRecording().catch(() => {})
  703. }
  704. recorder.cleanup()
  705. }
  706. async function handleFinishRecording() {
  707. if (!recorder.isRecording.value) return
  708. const ctl = streamCtl
  709. streamCtl = null
  710. try {
  711. const blob = await recorder.stopRecording()
  712. recorder.onChunk.value = null
  713. if (ctl) {
  714. ctl.commit(blob) // pushes placeholders, attaches blob, sends 'stop'
  715. } else {
  716. // Fallback: direct HTTP path
  717. await engine.sendStudentMessage(blob, crypto.randomUUID())
  718. }
  719. } catch (err) {
  720. console.error('Recording/send failed:', err)
  721. }
  722. }
  723. function hasRetryButton(m: PreviewChatMessage): boolean {
  724. return m.recovery === 'retry' || m.recovery === 'restart'
  725. }
  726. function hasRerecordButton(m: PreviewChatMessage): boolean {
  727. return m.role === 'student' && (m.recovery === 'retry' || m.recovery === 'rerecord')
  728. }
  729. function retryButtonLabel(m: PreviewChatMessage): string {
  730. if (m.recovery === 'restart') return '返回重开'
  731. return '重试'
  732. }
  733. async function handleRetry(m: PreviewChatMessage) {
  734. if (m.recovery === 'restart') {
  735. emit('restart')
  736. return
  737. }
  738. if (m.role === 'student') {
  739. await engine.retryMessage(m.id)
  740. } else {
  741. // greeting case: first AI message with no prior student
  742. const idx = engine.messages.value.indexOf(m)
  743. const isGreeting = !engine.messages.value
  744. .slice(0, idx)
  745. .some(x => x.role === 'student')
  746. if (isGreeting) {
  747. await engine.retryGreeting()
  748. } else {
  749. await engine.regenerateAiMessage(m.id)
  750. }
  751. }
  752. }
  753. function handleRerecord(m: PreviewChatMessage) {
  754. engine.discardCurrentTurn(m.id)
  755. }
  756. const lastErroredMessage = computed<PreviewChatMessage | null>(() => {
  757. const msgs = engine.messages.value
  758. for (let i = msgs.length - 1; i >= 0; i--) {
  759. if (msgs[i].status === 'error') return msgs[i]
  760. }
  761. return null
  762. })
  763. function toggleExpand(id: string) {
  764. expandedMessageId.value = expandedMessageId.value === id ? null : id
  765. }
  766. function openTaskHint() {
  767. showHintModal.value = true
  768. if (!taskHint.value && !taskHintLoading.value) {
  769. loadTaskHint()
  770. }
  771. }
  772. async function loadTaskHint() {
  773. if (!props.sessionInfo?.sessionId) {
  774. taskHintError.value = '当前会话未准备好,请稍后重试'
  775. return
  776. }
  777. taskHintLoading.value = true
  778. taskHintError.value = null
  779. try {
  780. taskHint.value = await taskHintApi.generateTaskHint(props.sessionInfo.sessionId)
  781. } catch {
  782. taskHintError.value = '生成任务提示失败,请重试'
  783. } finally {
  784. taskHintLoading.value = false
  785. }
  786. }
  787. function togglePlay(id: string) {
  788. // Same id is currently playing or loading → stop.
  789. if (player.playingId.value === id || player.loadingId.value === id) {
  790. player.stop()
  791. return
  792. }
  793. const msg = engine.messages.value.find(m => m.id === id)
  794. if (!msg) return
  795. if (msg.role === 'student' && msg.audioBlob) {
  796. player.play(id, { kind: 'blob', blob: msg.audioBlob })
  797. }
  798. else if (msg.role === 'ai' && msg.content) {
  799. player.play(id, { kind: 'tts', text: msg.content })
  800. }
  801. }
  802. function openPhonemeDetail(wa: NonNullable<NonNullable<PreviewChatMessage['evaluation']>['wordAnalysis']>[0]) {
  803. phonemeDetail.value = {
  804. word: wa.word,
  805. userPronunciation: wa.userPronunciation,
  806. standardPronunciation: wa.standardPronunciation,
  807. tip: wa.tip,
  808. }
  809. }
  810. function practiceThisWord() {
  811. phonemeDetail.value = null
  812. handleStartRecording()
  813. }
  814. async function handleExitConfirm() {
  815. showExitConfirm.value = false
  816. emit('complete', await fetchReportSafe())
  817. }
  818. async function fetchReportSafe(): Promise<DialogueReport | null> {
  819. reportFetchInflight.value = true
  820. try {
  821. await engine.completeSession()
  822. return await engine.getReport()
  823. } catch (err) {
  824. console.warn('[speaking] getReport failed:', err)
  825. return null
  826. } finally {
  827. reportFetchInflight.value = false
  828. }
  829. }
  830. function handleRestart() {
  831. showExitConfirm.value = false
  832. engine.abort()
  833. player.stop()
  834. emit('restart')
  835. }
  836. // ─────────────────────────────────────────────
  837. // Badge detection
  838. // ─────────────────────────────────────────────
  839. function triggerBadge(id: string) {
  840. const badge = BADGE_CONFIG[id]
  841. if (!badge) return
  842. showBadge.value = badge
  843. if (badgeTimer) clearTimeout(badgeTimer)
  844. badgeTimer = setTimeout(() => { showBadge.value = null }, 2800)
  845. }
  846. function checkBadges(ev: NonNullable<PreviewChatMessage['evaluation']>) {
  847. const d = ev.dimensions
  848. if (d.fluency === 'excellent') {
  849. consecutiveFluent.value += 1
  850. if (consecutiveFluent.value === 3) triggerBadge('smooth_talker')
  851. } else {
  852. consecutiveFluent.value = 0
  853. }
  854. if (d.accuracy === 'excellent') {
  855. consecutiveAccurate.value += 1
  856. if (consecutiveAccurate.value === 5) triggerBadge('pronunciation_pro')
  857. } else {
  858. consecutiveAccurate.value = 0
  859. }
  860. if (d.accuracy === 'excellent' && d.fluency === 'excellent' && d.completeness === 'excellent' && d.rhythm === 'excellent') {
  861. setTimeout(() => triggerBadge('perfect_round'), 400)
  862. }
  863. }
  864. // ─────────────────────────────────────────────
  865. // Watchers
  866. // ─────────────────────────────────────────────
  867. // 自动滚动到底部
  868. watch(
  869. () => engine.messages.value.map(m => m.content + m.status).join('|'),
  870. () => {
  871. nextTick(() => {
  872. if (chatContainerRef.value) {
  873. chatContainerRef.value.scrollTop = chatContainerRef.value.scrollHeight
  874. }
  875. })
  876. },
  877. )
  878. // 自动播放:AI 消息流式 done 后,合成并播一次。
  879. // 用 Set 去重防止 watcher 因为不相关重渲染重复触发。
  880. const autoPlayedIds = new Set<string>()
  881. const seededHistoricalMessageIds = new Set<string>()
  882. watch(
  883. () => engine.messages.value.map(m => `${m.id}:${m.status}`).join('|'),
  884. () => {
  885. for (const m of engine.messages.value) {
  886. if (
  887. m.role === 'ai' &&
  888. m.status === 'done' &&
  889. m.content &&
  890. !seededHistoricalMessageIds.has(m.id) &&
  891. !autoPlayedIds.has(m.id)
  892. ) {
  893. autoPlayedIds.add(m.id)
  894. player.play(m.id, { kind: 'tts', text: m.content })
  895. }
  896. }
  897. },
  898. )
  899. // AI 消息 done 后,延迟 600ms 显示 "在等你的回答..."
  900. watch(
  901. () => {
  902. const msgs = engine.messages.value
  903. const last = msgs[msgs.length - 1]
  904. return last?.role === 'ai' && last.status === 'done' ? last.id : null
  905. },
  906. (val) => {
  907. if (idleHintTimer) clearTimeout(idleHintTimer)
  908. if (val) {
  909. showIdleHint.value = false
  910. idleHintTimer = setTimeout(() => { showIdleHint.value = true }, 600)
  911. } else {
  912. showIdleHint.value = false
  913. }
  914. },
  915. )
  916. // 学生消息产生 evaluation 时,检查徽章 + 清理沉默提示
  917. watch(
  918. () => engine.messages.value.filter(m => m.role === 'student' && m.evaluation).length,
  919. () => {
  920. const done = engine.messages.value.filter(m => m.role === 'student' && m.evaluation)
  921. const last = done[done.length - 1]
  922. if (last?.evaluation) checkBadges(last.evaluation)
  923. },
  924. )
  925. // 对话完成 → 通知父组件
  926. watch(
  927. () => engine.isComplete.value,
  928. async (complete) => {
  929. if (complete) emit('complete', await fetchReportSafe())
  930. },
  931. )
  932. // 沉默检测 → 随机提示
  933. watch(
  934. () => recorder.silenceDetected.value,
  935. (silent) => {
  936. if (silent && recorder.isRecording.value) {
  937. silenceHintText.value = SILENCE_HINTS[Math.floor(Math.random() * SILENCE_HINTS.length)]
  938. } else {
  939. silenceHintText.value = ''
  940. }
  941. },
  942. )
  943. // 录音时长达到上限,自动完成
  944. watch(
  945. () => recorder.recordingDuration.value,
  946. (v) => {
  947. if (v >= MAX_RECORDING_SECONDS && recorder.isRecording.value) {
  948. handleFinishRecording()
  949. }
  950. },
  951. )
  952. // ─────────────────────────────────────────────
  953. // Lifecycle
  954. // ─────────────────────────────────────────────
  955. onMounted(() => {
  956. if (props.sessionInfo) {
  957. const hasHistory = !!props.sessionInfo.messages?.length
  958. seededHistoricalMessageIds.clear()
  959. for (const message of props.sessionInfo.messages ?? []) {
  960. seededHistoricalMessageIds.add(message.id)
  961. }
  962. engine.attachSession({
  963. sessionId: props.sessionInfo.sessionId,
  964. expiresAt: props.sessionInfo.expiresAt,
  965. totalRounds: props.totalRounds,
  966. currentRound: props.sessionInfo.currentRound,
  967. messages: props.sessionInfo.messages,
  968. })
  969. if (!hasHistory) engine.generateGreeting()
  970. } else {
  971. console.warn('[DialogueChatView] mounted without sessionInfo; chat is inert. Parent must createSession before mounting.')
  972. }
  973. // 无 sessionInfo 时聊天区保持空(父组件应当先创建 session 再挂载本组件)
  974. })
  975. onUnmounted(() => {
  976. if (idleHintTimer) clearTimeout(idleHintTimer)
  977. if (badgeTimer) clearTimeout(badgeTimer)
  978. })
  979. </script>
  980. <style lang="scss" scoped>
  981. // ─────────────────────────────────────────────
  982. // Root
  983. // ─────────────────────────────────────────────
  984. .dialogue-chat-view {
  985. width: 100%;
  986. height: 100%;
  987. display: flex;
  988. flex-direction: column;
  989. position: relative;
  990. user-select: none;
  991. background: #fff;
  992. font-size: 12px;
  993. }
  994. // ─────────────────────────────────────────────
  995. // Header
  996. // ─────────────────────────────────────────────
  997. .chat-header {
  998. display: flex;
  999. align-items: center;
  1000. justify-content: space-between;
  1001. padding: 8px 12px;
  1002. border-bottom: 1px solid #f3f4f6;
  1003. background: #fff;
  1004. flex-shrink: 0;
  1005. }
  1006. .header-left {
  1007. display: flex;
  1008. align-items: center;
  1009. gap: 8px;
  1010. min-width: 0;
  1011. }
  1012. .ai-avatar {
  1013. width: 24px; height: 24px;
  1014. border-radius: 50%;
  1015. background: #fff7ed;
  1016. border: 1px solid #fed7aa;
  1017. display: flex; align-items: center; justify-content: center;
  1018. font-size: 12px;
  1019. flex-shrink: 0;
  1020. &.breathing { animation: breathing 2.4s ease-in-out infinite; }
  1021. }
  1022. .ai-name { font-size: 12px; font-weight: 600; color: #1f2937; }
  1023. .idle-hint { font-size: 11px; color: #9ca3af; }
  1024. .online-dot {
  1025. width: 6px; height: 6px;
  1026. background: #10b981;
  1027. border-radius: 50%;
  1028. }
  1029. .header-right {
  1030. display: flex;
  1031. align-items: center;
  1032. gap: 12px;
  1033. }
  1034. .round-indicator { font-size: 11px; font-weight: 500; color: #f97316; }
  1035. .total-time { font-size: 11px; font-weight: 500; color: #6b7280; font-variant-numeric: tabular-nums; }
  1036. .icon-btn {
  1037. padding: 6px;
  1038. border: none; background: transparent;
  1039. color: #9ca3af;
  1040. border-radius: 6px;
  1041. display: flex; align-items: center; justify-content: center;
  1042. cursor: pointer;
  1043. transition: background 0.15s, color 0.15s;
  1044. &:hover { background: #f3f4f6; color: #4b5563; }
  1045. }
  1046. // ─────────────────────────────────────────────
  1047. // Permission banner
  1048. // ─────────────────────────────────────────────
  1049. .permission-banner {
  1050. display: flex;
  1051. align-items: center;
  1052. gap: 8px;
  1053. padding: 8px 12px;
  1054. background: #fef3c7;
  1055. border-bottom: 1px solid #fde68a;
  1056. font-size: 11px;
  1057. color: #92400e;
  1058. flex-shrink: 0;
  1059. }
  1060. .permission-icon { font-size: 14px; }
  1061. // ─────────────────────────────────────────────
  1062. // Chat area
  1063. // ─────────────────────────────────────────────
  1064. .chat-area {
  1065. flex: 1;
  1066. overflow-y: auto;
  1067. padding: 12px;
  1068. display: flex;
  1069. flex-direction: column;
  1070. gap: 12px;
  1071. background: #f7f8fa;
  1072. min-height: 0;
  1073. }
  1074. .msg-row {
  1075. display: flex;
  1076. align-items: flex-end;
  1077. gap: 8px;
  1078. }
  1079. .msg-ai { justify-content: flex-start; }
  1080. .msg-student {
  1081. flex-direction: column;
  1082. align-items: flex-end;
  1083. gap: 4px;
  1084. }
  1085. .msg-col {
  1086. max-width: 78%;
  1087. display: flex;
  1088. flex-direction: column;
  1089. gap: 4px;
  1090. }
  1091. .avatar-sm {
  1092. width: 28px; height: 28px;
  1093. border-radius: 50%;
  1094. background: #fff7ed;
  1095. border: 1px solid #fed7aa;
  1096. display: flex; align-items: center; justify-content: center;
  1097. font-size: 14px;
  1098. flex-shrink: 0;
  1099. margin-bottom: 2px;
  1100. }
  1101. // 语音条
  1102. .voice-bar {
  1103. display: flex;
  1104. align-items: center;
  1105. gap: 8px;
  1106. padding: 8px 12px;
  1107. width: clamp(140px, 44%, 210px);
  1108. }
  1109. .voice-ai {
  1110. background: #fff;
  1111. border: 1px solid #f3f4f6;
  1112. border-radius: 16px;
  1113. border-top-left-radius: 4px;
  1114. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1115. }
  1116. .voice-student {
  1117. background: #f97316;
  1118. border-radius: 16px;
  1119. border-top-right-radius: 4px;
  1120. }
  1121. .play-btn {
  1122. width: 24px; height: 24px;
  1123. border-radius: 50%;
  1124. border: none;
  1125. display: flex; align-items: center; justify-content: center;
  1126. flex-shrink: 0;
  1127. cursor: pointer;
  1128. transition: background 0.2s;
  1129. }
  1130. .play-ai {
  1131. background: rgba(249,115,22,0.1);
  1132. color: #f97316;
  1133. &:hover { background: rgba(249,115,22,0.2); }
  1134. }
  1135. .play-student {
  1136. background: rgba(255,255,255,0.2);
  1137. color: #fff;
  1138. &:hover { background: rgba(255,255,255,0.3); }
  1139. }
  1140. .play-btn-error {
  1141. background: #fef2f2 !important;
  1142. color: #dc2626 !important;
  1143. border: 1px solid #fecaca;
  1144. &:hover { background: #fee2e2 !important; }
  1145. }
  1146. .play-spinner {
  1147. animation: spin 1s linear infinite;
  1148. }
  1149. .play-error-hint {
  1150. font-size: 10px;
  1151. color: #dc2626;
  1152. font-weight: 500;
  1153. flex-shrink: 0;
  1154. white-space: nowrap;
  1155. }
  1156. .play-error-hint-student {
  1157. color: #fff;
  1158. }
  1159. .wave-bar-group {
  1160. flex: 1;
  1161. display: flex;
  1162. align-items: center;
  1163. gap: 1px;
  1164. }
  1165. .wave-bar {
  1166. width: 2px;
  1167. border-radius: 999px;
  1168. flex-shrink: 0;
  1169. }
  1170. .wave-ai { background: rgba(249,115,22,0.4); }
  1171. .wave-student { background: rgba(255,255,255,0.5); }
  1172. .voice-duration { font-size: 10px; flex-shrink: 0; }
  1173. .voice-duration-ai { color: #9ca3af; }
  1174. .voice-duration-student { color: rgba(255,255,255,0.7); }
  1175. // 气泡
  1176. .bubble {
  1177. padding: 8px 12px;
  1178. border-radius: 12px;
  1179. font-size: 12px;
  1180. line-height: 1.55;
  1181. max-width: 100%;
  1182. }
  1183. .bubble-ai {
  1184. background: #fff;
  1185. border: 1px solid #f3f4f6;
  1186. border-top-left-radius: 4px;
  1187. color: #374151;
  1188. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1189. }
  1190. .bubble-student {
  1191. background: #fff7ed;
  1192. border: 1px solid #fed7aa;
  1193. border-top-right-radius: 4px;
  1194. color: #374151;
  1195. max-width: 78%;
  1196. padding: 6px 12px;
  1197. }
  1198. .improvable-word {
  1199. color: #d97706;
  1200. text-decoration: underline wavy #fbbf24;
  1201. cursor: pointer;
  1202. padding: 0 2px;
  1203. border-radius: 2px;
  1204. transition: background 0.2s;
  1205. &:hover { background: #fef3c7; }
  1206. }
  1207. // typing 指示器
  1208. .typing-bubble {
  1209. display: inline-flex;
  1210. align-items: center;
  1211. gap: 4px;
  1212. padding: 10px 14px;
  1213. background: #fff;
  1214. border: 1px solid #f3f4f6;
  1215. border-radius: 16px;
  1216. border-top-left-radius: 4px;
  1217. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1218. }
  1219. .typing-bubble-student {
  1220. border-top-left-radius: 16px;
  1221. border-top-right-radius: 4px;
  1222. }
  1223. .typing-dot {
  1224. width: 6px; height: 6px;
  1225. background: rgba(249,115,22,0.7);
  1226. border-radius: 50%;
  1227. animation: typing-bounce 1s ease-in-out infinite;
  1228. }
  1229. @keyframes typing-bounce {
  1230. 0%, 100% { transform: translateY(0); opacity: 0.5; }
  1231. 50% { transform: translateY(-3px); opacity: 1; }
  1232. }
  1233. // 错误卡
  1234. .error-card {
  1235. margin-top: 4px;
  1236. padding: 6px 10px;
  1237. background: #fef2f2;
  1238. border: 1px solid #fecaca;
  1239. border-radius: 10px;
  1240. display: inline-flex;
  1241. align-items: center;
  1242. gap: 8px;
  1243. }
  1244. .error-text { font-size: 11px; color: #dc2626; }
  1245. .retry-btn {
  1246. padding: 3px 10px;
  1247. background: #fff;
  1248. border: 1px solid #fecaca;
  1249. border-radius: 999px;
  1250. font-size: 11px;
  1251. color: #dc2626;
  1252. cursor: pointer;
  1253. &:hover { background: #fef2f2; border-color: #f87171; }
  1254. }
  1255. .rerecord-btn {
  1256. padding: 3px 10px;
  1257. background: transparent;
  1258. border: 1px solid #d1d5db;
  1259. border-radius: 999px;
  1260. font-size: 11px;
  1261. color: #6b7280;
  1262. cursor: pointer;
  1263. margin-left: 4px;
  1264. &:hover { background: #f9fafb; border-color: #9ca3af; color: #374151; }
  1265. }
  1266. // 评分卡
  1267. .eval-card {
  1268. background: #fff;
  1269. border: 1px solid #f3f4f6;
  1270. border-radius: 12px;
  1271. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1272. overflow: hidden;
  1273. width: clamp(260px, 88%, 420px);
  1274. text-align: left;
  1275. margin-top: 2px;
  1276. }
  1277. .eval-l1 { padding: 8px 12px; }
  1278. .dim-row {
  1279. display: flex;
  1280. align-items: center;
  1281. gap: 6px;
  1282. font-size: 10px;
  1283. color: #6b7280;
  1284. flex-wrap: wrap;
  1285. }
  1286. .dim-label { color: #6b7280; }
  1287. .dim-sep { color: #e5e7eb; margin: 0 2px; }
  1288. .dim-badge {
  1289. font-size: 10px;
  1290. font-weight: 600;
  1291. padding: 1px 4px;
  1292. border-radius: 3px;
  1293. }
  1294. .dim-excellent { color: #059669; background: #ecfdf5; }
  1295. .dim-good { color: #10b981; background: #ecfdf5; }
  1296. .dim-improve { color: #f59e0b; background: #fffbeb; }
  1297. .sugg-row {
  1298. display: flex;
  1299. align-items: center;
  1300. justify-content: space-between;
  1301. gap: 8px;
  1302. margin-top: 6px;
  1303. }
  1304. .sugg-text {
  1305. flex: 1;
  1306. min-width: 0;
  1307. font-size: 10px;
  1308. color: #6b7280;
  1309. display: flex;
  1310. align-items: center;
  1311. gap: 4px;
  1312. margin: 0;
  1313. }
  1314. .sugg-icon { color: #f59e0b; flex-shrink: 0; }
  1315. .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  1316. .detail-toggle {
  1317. font-size: 10px;
  1318. color: #f97316;
  1319. background: transparent;
  1320. border: none;
  1321. cursor: pointer;
  1322. display: flex;
  1323. align-items: center;
  1324. gap: 2px;
  1325. flex-shrink: 0;
  1326. &:hover { color: #ea580c; }
  1327. svg { transition: transform 0.2s; }
  1328. .chev-up { transform: rotate(180deg); }
  1329. }
  1330. .eval-l2 {
  1331. padding: 10px 12px;
  1332. border-top: 1px solid #f9fafb;
  1333. background: #fafbfc;
  1334. display: flex;
  1335. flex-direction: column;
  1336. gap: 10px;
  1337. }
  1338. .detail-label {
  1339. font-size: 10px;
  1340. color: #9ca3af;
  1341. margin: 0 0 4px;
  1342. display: flex;
  1343. align-items: center;
  1344. gap: 4px;
  1345. }
  1346. .detail-content {
  1347. font-size: 12px;
  1348. color: #374151;
  1349. background: #fff;
  1350. padding: 6px 10px;
  1351. border: 1px solid #f3f4f6;
  1352. border-radius: 8px;
  1353. margin: 0;
  1354. line-height: 1.5;
  1355. }
  1356. .word-tags { display: flex; flex-wrap: wrap; gap: 4px; }
  1357. .word-tag {
  1358. padding: 2px 8px;
  1359. background: #fff7ed;
  1360. color: #ea580c;
  1361. font-size: 10px;
  1362. border-radius: 999px;
  1363. border: 1px solid #fed7aa;
  1364. }
  1365. // ─────────────────────────────────────────────
  1366. // Silence hint
  1367. // ─────────────────────────────────────────────
  1368. .silence-hint-wrap {
  1369. position: absolute;
  1370. bottom: 76px;
  1371. left: 0; right: 0;
  1372. display: flex;
  1373. justify-content: center;
  1374. z-index: 10;
  1375. padding: 0 16px;
  1376. pointer-events: none;
  1377. }
  1378. .silence-hint {
  1379. background: rgba(255,255,255,0.95);
  1380. backdrop-filter: blur(6px);
  1381. border: 1px solid #fed7aa;
  1382. border-radius: 14px;
  1383. box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  1384. padding: 10px 14px;
  1385. display: flex;
  1386. align-items: flex-start;
  1387. gap: 10px;
  1388. max-width: 320px;
  1389. width: 100%;
  1390. pointer-events: auto;
  1391. }
  1392. .silence-icon { color: #fb923c; font-size: 14px; flex-shrink: 0; margin-top: 2px; }
  1393. .silence-text { font-size: 12px; color: #4b5563; margin: 0; line-height: 1.5; flex: 1; }
  1394. .silence-close {
  1395. background: transparent; border: none;
  1396. color: #d1d5db;
  1397. cursor: pointer;
  1398. padding: 2px;
  1399. flex-shrink: 0;
  1400. &:hover { color: #6b7280; }
  1401. }
  1402. // ─────────────────────────────────────────────
  1403. // Control zone
  1404. // ─────────────────────────────────────────────
  1405. .control-zone {
  1406. flex-shrink: 0;
  1407. border-top: 1px solid #f3f4f6;
  1408. background: #fff;
  1409. padding: 10px 16px 12px;
  1410. }
  1411. .progress-wrap {
  1412. max-width: 384px;
  1413. margin: 0 auto 8px;
  1414. }
  1415. .progress-track {
  1416. height: 1px;
  1417. border-radius: 999px;
  1418. overflow: hidden;
  1419. }
  1420. .progress-fill {
  1421. height: 100%;
  1422. background: #fb923c;
  1423. transition: width 1s linear, background-color 0.4s ease, opacity 0.2s ease;
  1424. &.near-limit { background: #f87171; }
  1425. }
  1426. .state-stack {
  1427. position: relative;
  1428. height: 36px;
  1429. max-width: 384px;
  1430. margin: 0 auto;
  1431. }
  1432. .state-layer {
  1433. position: absolute;
  1434. inset: 0;
  1435. display: flex;
  1436. align-items: center;
  1437. }
  1438. .state-idle {
  1439. justify-content: center;
  1440. gap: 12px;
  1441. }
  1442. .state-center { justify-content: center; gap: 8px; }
  1443. .state-error {
  1444. justify-content: space-between;
  1445. gap: 12px;
  1446. }
  1447. // idle buttons
  1448. .hint-btn {
  1449. display: inline-flex;
  1450. align-items: center;
  1451. gap: 5px;
  1452. padding: 5px 14px;
  1453. border-radius: 999px;
  1454. background: #f9fafb;
  1455. border: 1px solid #e5e7eb;
  1456. color: #6b7280;
  1457. font-size: 11px;
  1458. font-weight: 500;
  1459. cursor: pointer;
  1460. transition: background 0.2s, border-color 0.2s, color 0.2s;
  1461. &:hover {
  1462. background: #fff7ed;
  1463. border-color: #fed7aa;
  1464. color: #f97316;
  1465. }
  1466. }
  1467. .mic-btn {
  1468. display: inline-flex;
  1469. align-items: center;
  1470. gap: 8px;
  1471. padding: 7px 24px;
  1472. border-radius: 999px;
  1473. background: #f97316;
  1474. border: none;
  1475. color: #fff;
  1476. font-size: 13px;
  1477. font-weight: 500;
  1478. cursor: pointer;
  1479. box-shadow: 0 4px 10px rgba(249,115,22,0.25);
  1480. transition: background 0.2s, transform 0.15s;
  1481. &:hover { background: #ea580c; }
  1482. &:active { transform: scale(0.96); }
  1483. &:disabled { opacity: 0.5; cursor: not-allowed; background: #d1d5db; box-shadow: none; }
  1484. }
  1485. // recording capsule
  1486. .record-capsule {
  1487. width: 100%;
  1488. display: flex;
  1489. align-items: center;
  1490. gap: 8px;
  1491. padding: 5px 10px;
  1492. border-radius: 999px;
  1493. background: #f9fafb;
  1494. border: 1px solid #f3f4f6;
  1495. }
  1496. .cancel-btn, .finish-btn {
  1497. display: inline-flex;
  1498. align-items: center;
  1499. gap: 4px;
  1500. padding: 4px 10px;
  1501. border-radius: 999px;
  1502. font-size: 11px;
  1503. font-weight: 500;
  1504. cursor: pointer;
  1505. flex-shrink: 0;
  1506. transition: background 0.2s, border-color 0.2s, color 0.2s;
  1507. }
  1508. .cancel-btn {
  1509. background: #fff;
  1510. border: 1px solid #e5e7eb;
  1511. color: #6b7280;
  1512. &:hover { background: #fef2f2; border-color: #fecaca; color: #ef4444; }
  1513. }
  1514. .finish-btn {
  1515. background: #f97316;
  1516. border: none;
  1517. color: #fff;
  1518. &:hover:not(:disabled) { background: #ea580c; }
  1519. &:disabled {
  1520. background: #d1d5db;
  1521. color: #9ca3af;
  1522. cursor: not-allowed;
  1523. }
  1524. }
  1525. .record-meter {
  1526. flex: 1;
  1527. display: flex;
  1528. align-items: center;
  1529. justify-content: center;
  1530. gap: 6px;
  1531. }
  1532. .animated-wave { display: flex; align-items: center; gap: 1px; }
  1533. .aw-bar {
  1534. width: 2px;
  1535. border-radius: 999px;
  1536. background: #f97316;
  1537. animation: aw-pulse 1.2s ease-in-out infinite;
  1538. &.near-limit { background: #ef4444; }
  1539. }
  1540. @keyframes aw-pulse {
  1541. 0%, 100% { opacity: 0.55; }
  1542. 50% { opacity: 1; }
  1543. }
  1544. .record-time {
  1545. font-size: 12px;
  1546. font-family: monospace;
  1547. font-weight: 600;
  1548. color: #1f2937;
  1549. font-variant-numeric: tabular-nums;
  1550. &.near-limit { color: #ef4444; }
  1551. }
  1552. .record-time-max { font-size: 10px; color: #d1d5db; }
  1553. // stt / thinking
  1554. .spinner {
  1555. color: #fb923c;
  1556. animation: spin 1s linear infinite;
  1557. }
  1558. @keyframes spin {
  1559. to { transform: rotate(360deg); }
  1560. }
  1561. .mini-avatar {
  1562. width: 16px; height: 16px;
  1563. border-radius: 50%;
  1564. background: #fff7ed;
  1565. display: flex; align-items: center; justify-content: center;
  1566. font-size: 10px;
  1567. }
  1568. .center-text { font-size: 12px; color: #9ca3af; }
  1569. // error
  1570. .error-info { display: flex; align-items: center; gap: 6px; }
  1571. .warn-icon { color: #f59e0b; font-size: 12px; }
  1572. .warn-text { font-size: 12px; color: #4b5563; }
  1573. .retry-pill {
  1574. padding: 5px 14px;
  1575. border-radius: 999px;
  1576. background: #f97316;
  1577. color: #fff;
  1578. border: none;
  1579. font-size: 12px;
  1580. font-weight: 500;
  1581. cursor: pointer;
  1582. &:hover { background: #ea580c; }
  1583. }
  1584. // ─────────────────────────────────────────────
  1585. // Modals
  1586. // ─────────────────────────────────────────────
  1587. .modal-mask {
  1588. position: fixed;
  1589. inset: 0;
  1590. background: rgba(0,0,0,0.3);
  1591. backdrop-filter: blur(2px);
  1592. display: flex;
  1593. align-items: center;
  1594. justify-content: center;
  1595. z-index: 50;
  1596. padding: 16px;
  1597. }
  1598. .modal {
  1599. background: #fff;
  1600. border-radius: 16px;
  1601. width: 100%;
  1602. max-height: 80vh;
  1603. overflow-y: auto;
  1604. box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  1605. }
  1606. .phoneme-modal { max-width: 320px; }
  1607. .exit-modal { max-width: 320px; padding: 20px; }
  1608. .modal-head {
  1609. display: flex;
  1610. align-items: center;
  1611. justify-content: space-between;
  1612. margin-bottom: 12px;
  1613. }
  1614. .modal-title {
  1615. font-size: 14px;
  1616. font-weight: 600;
  1617. color: #111827;
  1618. display: flex;
  1619. align-items: center;
  1620. gap: 6px;
  1621. margin: 0;
  1622. }
  1623. .close-btn {
  1624. width: 26px; height: 26px;
  1625. background: #f3f4f6;
  1626. border: none;
  1627. border-radius: 8px;
  1628. color: #6b7280;
  1629. cursor: pointer;
  1630. display: flex; align-items: center; justify-content: center;
  1631. &:hover { background: #e5e7eb; }
  1632. }
  1633. // 音素
  1634. .phoneme-word { text-align: left; font-size: 16px; font-weight: 700; color: #111827; margin: 0; }
  1635. .phoneme-sub { font-size: 11px; color: #9ca3af; margin: 2px 0 0; }
  1636. .phoneme-body {
  1637. padding: 0 20px 20px;
  1638. display: flex;
  1639. flex-direction: column;
  1640. gap: 10px;
  1641. }
  1642. .modal-head + .phoneme-body { padding-top: 0; }
  1643. .phoneme-modal .modal-head { padding: 20px 20px 12px; margin-bottom: 0; }
  1644. .pho-card {
  1645. border-radius: 12px;
  1646. padding: 12px;
  1647. display: flex;
  1648. align-items: center;
  1649. justify-content: space-between;
  1650. gap: 12px;
  1651. }
  1652. .pho-user { background: #fffbeb; border: 1px solid #fde68a; }
  1653. .pho-standard { background: #ecfdf5; border: 1px solid #bbf7d0; }
  1654. .pho-tip { background: #eff6ff; border: 1px solid #bfdbfe; display: block; }
  1655. .pho-label { font-size: 10px; font-weight: 500; margin: 0 0 2px; }
  1656. .pho-user .pho-label { color: #d97706; }
  1657. .pho-standard .pho-label { color: #059669; }
  1658. .pho-tip .pho-label { color: #2563eb; }
  1659. .pho-value { font-size: 14px; font-family: monospace; color: #b45309; margin: 0; }
  1660. .pho-value-green { color: #15803d; }
  1661. .pho-tip-text { font-size: 12px; color: #1d4ed8; margin: 0; line-height: 1.5; }
  1662. .pho-play {
  1663. width: 30px; height: 30px;
  1664. border-radius: 8px;
  1665. border: 1px solid;
  1666. display: flex; align-items: center; justify-content: center;
  1667. cursor: pointer;
  1668. }
  1669. .pho-play-user { background: #fef3c7; border-color: #fde68a; color: #d97706; &:hover { background: #fde68a; } }
  1670. .pho-play-standard { background: #d1fae5; border-color: #bbf7d0; color: #059669; &:hover { background: #bbf7d0; } }
  1671. .pho-practice-btn {
  1672. width: 100%;
  1673. padding: 9px;
  1674. border-radius: 12px;
  1675. background: #f97316;
  1676. color: #fff;
  1677. border: none;
  1678. font-size: 12px;
  1679. font-weight: 500;
  1680. cursor: pointer;
  1681. &:hover { background: #ea580c; }
  1682. }
  1683. // 退出弹窗
  1684. .exit-hint { font-size: 11px; color: #9ca3af; margin: 0 0 14px; }
  1685. .exit-actions { display: flex; flex-direction: column; gap: 10px; }
  1686. .exit-secondary {
  1687. padding: 9px 0;
  1688. border-radius: 12px;
  1689. background: transparent;
  1690. border: 1px solid #e5e7eb;
  1691. color: #4b5563;
  1692. font-size: 12px;
  1693. font-weight: 500;
  1694. cursor: pointer;
  1695. &:hover { background: #f9fafb; }
  1696. }
  1697. .exit-primary {
  1698. padding: 9px 0;
  1699. border-radius: 12px;
  1700. background: #f97316;
  1701. border: none;
  1702. color: #fff;
  1703. font-size: 12px;
  1704. font-weight: 500;
  1705. cursor: pointer;
  1706. &:hover { background: #ea580c; }
  1707. }
  1708. // 徽章
  1709. .badge-popup {
  1710. position: fixed;
  1711. top: 64px;
  1712. right: 16px;
  1713. z-index: 60;
  1714. }
  1715. .badge-card {
  1716. display: flex;
  1717. align-items: center;
  1718. gap: 12px;
  1719. padding: 10px 16px;
  1720. background: linear-gradient(to right, #f97316, #f59e0b);
  1721. border-radius: 16px;
  1722. box-shadow: 0 8px 24px rgba(249,115,22,0.3);
  1723. }
  1724. .badge-icon { font-size: 24px; }
  1725. .badge-name { font-size: 12px; font-weight: 600; color: #fff; margin: 0; }
  1726. .badge-desc { font-size: 10px; color: rgba(255,255,255,0.8); margin: 2px 0 0; }
  1727. // ─────────────────────────────────────────────
  1728. // Animations
  1729. // ─────────────────────────────────────────────
  1730. @keyframes breathing {
  1731. 0%, 100% { transform: scale(1); }
  1732. 50% { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }
  1733. }
  1734. @keyframes fade-in-frames {
  1735. from { opacity: 0; transform: translateY(4px); }
  1736. to { opacity: 1; transform: translateY(0); }
  1737. }
  1738. .fade-in { animation: fade-in-frames 0.22s ease-out; }
  1739. @keyframes scale-in-frames {
  1740. from { opacity: 0; transform: scale(0.96); }
  1741. to { opacity: 1; transform: scale(1); }
  1742. }
  1743. .scale-in { animation: scale-in-frames 0.22s ease-out; }
  1744. </style>