aiGengrate.vue 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397
  1. <template>
  2. <Dialog
  3. :title="'AI生成课程'"
  4. v-model="dialogVisible"
  5. width="90%"
  6. :fullscreen="true"
  7. @update:fullscreen="(value) => (fullscreen = value)"
  8. >
  9. <div class="course-script-editor">
  10. <!-- 全屏遮挡层 -->
  11. <div v-if="isGenerating" class="loading-overlay">
  12. <div class="loading-content">
  13. <div class="loading-spinner"></div>
  14. <div class="loading-text">生成中...</div>
  15. </div>
  16. </div>
  17. <div class="main-container">
  18. <!-- 左侧步骤指示器 -->
  19. <div class="steps-sidebar">
  20. <div class="steps-container">
  21. <template v-for="(step, index) in steps" :key="step.id">
  22. <div
  23. :class="[
  24. 'step-item',
  25. {
  26. process: currentStep === step.id,
  27. finish: step.id < currentStep,
  28. wait: step.id > currentStep
  29. }
  30. ]"
  31. >
  32. <div class="step-circle">{{ step.id }}</div>
  33. <div class="step-title">{{ step.label }}</div>
  34. </div>
  35. <div
  36. v-if="index < steps.length - 1"
  37. class="step-line"
  38. :class="{ active: currentStep > step.id }"
  39. ></div>
  40. </template>
  41. </div>
  42. </div>
  43. <!-- 右侧内容区域 -->
  44. <div class="content-area">
  45. <!-- 步骤1:AI一句话生成 -->
  46. <div v-if="currentStep === 1" class="step-content">
  47. <div class="ai-input-container">
  48. <div class="ai-input-wrapper">
  49. <div class="ai-icon">🤖</div>
  50. <textarea
  51. v-model="scriptPrompt"
  52. placeholder="AI一句话生成课程脚本,例如:生成一节关于牛顿万有引力的小学科学课脚本..."
  53. class="ai-textarea"
  54. ></textarea>
  55. </div>
  56. <div class="selection-group">
  57. <div class="selection-item">
  58. <label>主讲老师</label>
  59. <el-select
  60. v-model="selectedMainTeacher"
  61. filterable
  62. size="large"
  63. placeholder="请选择主讲老师"
  64. style="width: 300px"
  65. clearable
  66. >
  67. <el-option
  68. v-for="teacher in digitalHumans"
  69. :key="teacher.name"
  70. :label="teacher.name"
  71. :value="teacher.name"
  72. />
  73. </el-select>
  74. </div>
  75. <div class="selection-item">
  76. <label>助讲老师</label>
  77. <el-select
  78. v-model="selectedAssistants"
  79. filterable
  80. size="large"
  81. placeholder="请选择助讲老师"
  82. style="width: 300px"
  83. clearable
  84. multiple
  85. >
  86. <el-option
  87. v-for="teacher in digitalHumans"
  88. :key="teacher.name"
  89. :label="teacher.name"
  90. :value="teacher.name"
  91. />
  92. </el-select>
  93. </div>
  94. <div class="selection-item">
  95. <label>主题类型</label>
  96. <el-select
  97. v-model="selectedThemeType"
  98. size="large"
  99. placeholder="请选择主题类型"
  100. style="width: 300px"
  101. >
  102. <el-option label="课程通用" value="13" />
  103. <el-option label="诗词课" value="256" />
  104. <el-option label="诗词课(英才小学生)" value="262" />
  105. </el-select>
  106. </div>
  107. <div v-if="selectedThemeType === '262'" class="selection-item">
  108. <label>课程小节</label>
  109. <el-select
  110. v-model="selectedLessonSection"
  111. size="large"
  112. placeholder="请选择课程小节"
  113. style="width: 300px"
  114. >
  115. <el-option
  116. v-for="section in poetryLessonSections"
  117. :key="section.value"
  118. :label="section.label"
  119. :value="section.value"
  120. >
  121. <span>({{ section.value }}){{ section.label }}</span>
  122. </el-option>
  123. </el-select>
  124. </div>
  125. </div>
  126. <div class="button-group">
  127. <button
  128. class="generate-btn primary"
  129. :disabled="
  130. !scriptPrompt || !selectedMainTeacher || !selectedThemeType || isGenerating
  131. "
  132. @click="generateScript"
  133. >
  134. {{ isGenerating ? '生成中...' : '生成课程脚本' }}
  135. </button>
  136. <button
  137. v-if="hasDraftCache"
  138. class="generate-btn secondary"
  139. @click="loadDraftAndGotoStep2"
  140. >
  141. 查看草稿
  142. </button>
  143. </div>
  144. </div>
  145. </div>
  146. <!-- 步骤2:脚本编辑(含背景图/音生成) -->
  147. <div v-else-if="currentStep === 2" class="step-content">
  148. <!-- 固定顶部的一键操作栏 -->
  149. <div class="editor-toolbar sticky-top">
  150. <button
  151. class="toolbar-btn"
  152. @click="generateAllImages"
  153. :disabled="isGeneratingImages || isAnyImageGenerating"
  154. >
  155. {{ isGeneratingImages ? '生成中...' : '一键生成所有背景图' }}
  156. </button>
  157. <button
  158. class="toolbar-btn"
  159. @click="generateAllVideos"
  160. :disabled="isGeneratingVideos || isAnyVideoGenerating"
  161. >
  162. {{ isGeneratingVideos ? '生成中...' : '一键生成所有视频' }}
  163. </button>
  164. <button
  165. class="toolbar-btn"
  166. @click="generateAllVoiceovers"
  167. :disabled="isGeneratingVoiceovers || isAnyVoiceoverGenerating"
  168. >
  169. {{ isGeneratingVoiceovers ? '生成中...' : '一键配音' }}
  170. </button>
  171. </div>
  172. <!-- 可滚动的内容区域 -->
  173. <div class="script-editor">
  174. <div
  175. v-for="(section, sectionIndex) in scriptData.sections"
  176. :key="sectionIndex"
  177. class="script-section"
  178. >
  179. <div class="section-header">
  180. <div class="section-name-container">
  181. <label class="section-name-label">环节 {{ sectionIndex + 1 }}</label>
  182. <input
  183. v-model="section.name"
  184. class="section-title"
  185. placeholder="如:环节一(引入)"
  186. />
  187. </div>
  188. <button class="remove-section-btn" @click="removeSection(sectionIndex)">×</button>
  189. </div>
  190. <div class="media-controls">
  191. <!-- 背景类型切换 -->
  192. <el-radio-group v-model="section.backgroundType" class="background-type-switch">
  193. <el-radio-button label="imageAudio">图音背景</el-radio-button>
  194. <el-radio-button label="video">视频背景</el-radio-button>
  195. </el-radio-group>
  196. <!-- 图音背景 -->
  197. <template v-if="section.backgroundType === 'imageAudio'">
  198. <div class="media-item">
  199. <div class="media-input-group">
  200. <span class="media-label">背景图</span>
  201. <el-input
  202. v-model="section.backgroundImage.prompt"
  203. type="textarea"
  204. :autosize="{ minRows: 2, maxRows: 4 }"
  205. placeholder="描述词"
  206. class="media-prompt"
  207. />
  208. <el-button
  209. type="primary"
  210. size="small"
  211. :loading="section.backgroundImage.generating"
  212. :disabled="
  213. !section.backgroundImage.prompt || section.backgroundImage.generating
  214. "
  215. @click="generateMedia(sectionIndex)"
  216. class="generate-btn"
  217. >
  218. {{
  219. section.backgroundImage.generating
  220. ? '生成中...'
  221. : section.backgroundImage.url
  222. ? '重新生成'
  223. : '生成'
  224. }}
  225. </el-button>
  226. </div>
  227. <div class="upload-container">
  228. <UploadImg v-model="section.backgroundImage.url" />
  229. </div>
  230. </div>
  231. <div class="media-item">
  232. <div class="media-input-group">
  233. <span class="media-label">背景音</span>
  234. <el-select
  235. v-model="section.backgroundAudio.type"
  236. placeholder="选择背景音"
  237. :style="{ width: fullscreen ? '240px' : '130px' }"
  238. clearable
  239. size="large"
  240. @change="(value) => handleBackgroundAudioChange(value, section)"
  241. >
  242. <el-option
  243. v-for="musicType in backgroundMusicTypes"
  244. :key="musicType.id"
  245. :label="musicType.name"
  246. :value="musicType.id"
  247. />
  248. </el-select>
  249. <button
  250. v-if="section.backgroundAudio.type"
  251. class="play-btn small"
  252. @click="playBackgroundAudio(section.backgroundAudio.type)"
  253. >
  254. <span class="play-icon">{{
  255. audioState.isPlaying &&
  256. audioState.currentType === 'background' &&
  257. audioState.currentUrl === section.backgroundAudio.url
  258. ? '⏸'
  259. : '▶'
  260. }}</span>
  261. </button>
  262. </div>
  263. </div>
  264. </template>
  265. <!-- 视频背景 -->
  266. <template v-else-if="section.backgroundType === 'video'">
  267. <div class="media-item">
  268. <div class="media-input-group">
  269. <span class="media-label">视频提示词</span>
  270. <el-input
  271. v-model="section.backgroundVideo.prompt"
  272. type="textarea"
  273. :autosize="{ minRows: 2, maxRows: 4 }"
  274. placeholder="描述词"
  275. class="media-prompt-video"
  276. />
  277. <el-button
  278. type="primary"
  279. size="small"
  280. :loading="section.backgroundVideo.generating"
  281. :disabled="
  282. !section.backgroundVideo.prompt || section.backgroundVideo.generating
  283. "
  284. @click="generateVideo(sectionIndex)"
  285. class="generate-btn"
  286. >
  287. {{
  288. section.backgroundVideo.generating
  289. ? '生成中...'
  290. : section.backgroundVideo.url
  291. ? '重新生成'
  292. : '生成'
  293. }}
  294. </el-button>
  295. </div>
  296. <div class="upload-container">
  297. <UploadVideo2 v-model="section.backgroundVideo.url" />
  298. </div>
  299. </div>
  300. </template>
  301. </div>
  302. <div class="dialogues-container">
  303. <div
  304. v-for="(dialogue, dialogueIndex) in section.dialogues"
  305. :key="dialogueIndex"
  306. class="dialogue-item"
  307. :class="[dialogue.type, { hidden: dialogue.type === 'user' }]"
  308. >
  309. <div class="dialogue-header">
  310. <div class="dialogue-type-tag" :class="dialogue.type">
  311. {{
  312. dialogue.type === 'digital'
  313. ? '数字人'
  314. : dialogue.type === 'user'
  315. ? '用户'
  316. : dialogue.type === 'quest'
  317. ? '提问'
  318. : dialogue.type === 'poem'
  319. ? '诗词'
  320. : dialogue.type === 'poem_reading'
  321. ? '朗诵评价'
  322. : dialogue.type === 'write_reading'
  323. ? '写诗评价'
  324. : dialogue.type === 'recite_reading'
  325. ? '背诵诗词评价'
  326. : '视频'
  327. }}
  328. </div>
  329. </div>
  330. <div class="dialogue-row">
  331. <!-- 数字人对话 -->
  332. <template v-if="dialogue.type === 'digital'">
  333. <div class="dialogue-role-select">
  334. <el-select
  335. v-model="dialogue.roleName"
  336. placeholder="选择角色"
  337. style="width: 140px"
  338. clearable
  339. >
  340. <el-option
  341. v-for="role in digitalHumans"
  342. :key="role.id"
  343. :label="role.name"
  344. :value="role.name"
  345. />
  346. </el-select>
  347. </div>
  348. <div class="dialogue-content-container">
  349. <el-input
  350. v-model="dialogue.content"
  351. type="textarea"
  352. class="dialogue-content"
  353. placeholder="对话内容..."
  354. :autosize="{ minRows: 2, maxRows: 4 }"
  355. />
  356. </div>
  357. <div class="action-buttons">
  358. <div class="action-buttons-row">
  359. <button
  360. v-if="dialogue.voiceoverUrl"
  361. class="play-btn"
  362. @click="playVoiceover(dialogue.voiceoverUrl)"
  363. >
  364. <span class="play-icon">{{
  365. audioState.isPlaying &&
  366. audioState.currentType === 'voice' &&
  367. audioState.currentUrl === dialogue.voiceoverUrl
  368. ? '⏸'
  369. : '▶'
  370. }}</span>
  371. </button>
  372. <button
  373. class="remove-btn"
  374. @click="removeDialogue(sectionIndex, dialogueIndex)"
  375. >×</button
  376. >
  377. </div>
  378. <div class="action-buttons-row">
  379. <button
  380. v-if="!dialogue.voiceoverUrl"
  381. class="generate-btn small"
  382. :disabled="
  383. !dialogue.content ||
  384. !dialogue.roleName ||
  385. dialogue.generatingVoiceover
  386. "
  387. @click="generateVoiceover(sectionIndex, dialogueIndex)"
  388. >
  389. <span class="voice-icon">{{
  390. dialogue.generatingVoiceover ? '生成中...' : '生成语音'
  391. }}</span>
  392. </button>
  393. <button
  394. v-if="dialogue.voiceoverUrl"
  395. class="generate-btn small"
  396. :disabled="
  397. !dialogue.content ||
  398. !dialogue.roleName ||
  399. dialogue.generatingVoiceover
  400. "
  401. @click="generateVoiceover(sectionIndex, dialogueIndex)"
  402. >
  403. <span class="voice-icon">{{
  404. dialogue.generatingVoiceover ? '生成中...' : '重新生成'
  405. }}</span>
  406. </button>
  407. </div>
  408. </div>
  409. </template>
  410. <!-- 用户 -->
  411. <template v-else-if="dialogue.type === 'user'">
  412. <div class="dialogue-content-container full-width">
  413. <el-input
  414. v-model="dialogue.content"
  415. type="textarea"
  416. class="dialogue-content"
  417. placeholder="用户回复内容参考语..."
  418. :autosize="{ minRows: 2, maxRows: 4 }"
  419. />
  420. </div>
  421. <div class="dialogue-reply-select">
  422. <el-select
  423. v-model="dialogue.roleName"
  424. placeholder="选择数字人回复"
  425. style="width: 140px"
  426. clearable
  427. >
  428. <el-option
  429. v-for="role in digitalHumans"
  430. :key="role.id"
  431. :label="role.name"
  432. :value="role.name"
  433. />
  434. </el-select>
  435. </div>
  436. <div class="action-buttons">
  437. <div class="action-buttons-row">
  438. <button
  439. class="remove-btn"
  440. @click="removeDialogue(sectionIndex, dialogueIndex)"
  441. >×</button
  442. >
  443. </div>
  444. </div>
  445. </template>
  446. <!-- 提问 -->
  447. <template v-else-if="dialogue.type === 'quest'">
  448. <div class="dialogue-role-select">
  449. <el-select
  450. v-model="dialogue.roleName"
  451. placeholder="选择角色"
  452. style="width: 140px"
  453. clearable
  454. >
  455. <el-option
  456. v-for="role in digitalHumans"
  457. :key="role.id"
  458. :label="role.name"
  459. :value="role.name"
  460. />
  461. </el-select>
  462. </div>
  463. <div class="dialogue-content-container">
  464. <div class="question-type-select">
  465. <span class="question-type-label">提问类型:</span>
  466. <el-select
  467. v-model="dialogue.questionType"
  468. placeholder="请选择提问类型"
  469. style="width: 140px"
  470. >
  471. <el-option label="AI问答" value="AI Q&A" />
  472. <el-option label="单选题" value="singleChoice" />
  473. </el-select>
  474. </div>
  475. <el-input
  476. v-model="dialogue.content"
  477. type="textarea"
  478. class="dialogue-content"
  479. placeholder="提问内容..."
  480. :autosize="{ minRows: 2, maxRows: 4 }"
  481. />
  482. <!-- 单选题选项 -->
  483. <div v-if="dialogue.questionType === 'singleChoice'" class="single-choice-options">
  484. <div class="options-header">
  485. <span class="options-label">选项列表:</span>
  486. <button class="add-option-btn" @click="addOption(sectionIndex, dialogueIndex)">+ 添加选项</button>
  487. </div>
  488. <div
  489. v-for="(option, optionIndex) in (dialogue.options || [])"
  490. :key="optionIndex"
  491. class="option-item"
  492. >
  493. <span class="option-label">{{ String.fromCharCode(65 + optionIndex) }}.</span>
  494. <el-input
  495. v-model="option.content"
  496. placeholder="选项内容"
  497. style="flex: 1; margin-right: 10px;"
  498. />
  499. <div class="answer-radio-wrapper">
  500. <el-radio
  501. v-model="dialogue.answer"
  502. :label="String.fromCharCode(65 + optionIndex)"
  503. />
  504. <span v-if="dialogue.answer === String.fromCharCode(65 + optionIndex)" class="correct-mark">✓</span>
  505. </div>
  506. <button
  507. v-if="(dialogue.options || []).length > 2"
  508. class="remove-option-btn"
  509. @click="removeOption(sectionIndex, dialogueIndex, optionIndex)"
  510. >×</button>
  511. </div>
  512. </div>
  513. </div>
  514. <div class="action-buttons">
  515. <div class="action-buttons-row">
  516. <button
  517. v-if="dialogue.voiceoverUrl"
  518. class="play-btn"
  519. @click="playVoiceover(dialogue.voiceoverUrl)"
  520. >
  521. <span class="play-icon">{{
  522. audioState.isPlaying &&
  523. audioState.currentType === 'voice' &&
  524. audioState.currentUrl === dialogue.voiceoverUrl
  525. ? '⏸'
  526. : '▶'
  527. }}</span>
  528. </button>
  529. <button
  530. class="remove-btn"
  531. @click="removeDialogue(sectionIndex, dialogueIndex)"
  532. >×</button
  533. >
  534. </div>
  535. <div class="action-buttons-row">
  536. <button
  537. v-if="!dialogue.voiceoverUrl"
  538. class="generate-btn small"
  539. :disabled="
  540. !dialogue.content ||
  541. !dialogue.roleName ||
  542. dialogue.generatingVoiceover
  543. "
  544. @click="generateVoiceover(sectionIndex, dialogueIndex)"
  545. >
  546. <span class="voice-icon">{{
  547. dialogue.generatingVoiceover ? '生成中...' : '生成语音'
  548. }}</span>
  549. </button>
  550. <button
  551. v-if="dialogue.voiceoverUrl"
  552. class="generate-btn small"
  553. :disabled="
  554. !dialogue.content ||
  555. !dialogue.roleName ||
  556. dialogue.generatingVoiceover
  557. "
  558. @click="generateVoiceover(sectionIndex, dialogueIndex)"
  559. >
  560. <span class="voice-icon">{{
  561. dialogue.generatingVoiceover ? '生成中...' : '重新生成'
  562. }}</span>
  563. </button>
  564. </div>
  565. </div>
  566. </template>
  567. <!-- 诗词 -->
  568. <template v-else-if="dialogue.type === 'poem'">
  569. <div class="dialogue-role-select">
  570. <el-select
  571. v-model="dialogue.roleName"
  572. placeholder="选择角色"
  573. style="width: 140px"
  574. clearable
  575. >
  576. <el-option
  577. v-for="role in digitalHumans"
  578. :key="role.id"
  579. :label="role.name"
  580. :value="role.name"
  581. />
  582. </el-select>
  583. </div>
  584. <div class="dialogue-content-container">
  585. <el-input
  586. v-model="dialogue.content"
  587. type="textarea"
  588. class="dialogue-content"
  589. placeholder="诗词内容..."
  590. :autosize="{ minRows: 2, maxRows: 4 }"
  591. />
  592. </div>
  593. <div class="action-buttons">
  594. <div class="action-buttons-row">
  595. <button
  596. v-if="dialogue.voiceoverUrl"
  597. class="play-btn"
  598. @click="playVoiceover(dialogue.voiceoverUrl)"
  599. >
  600. <span class="play-icon">{{
  601. audioState.isPlaying &&
  602. audioState.currentType === 'voice' &&
  603. audioState.currentUrl === dialogue.voiceoverUrl
  604. ? '⏸'
  605. : '▶'
  606. }}</span>
  607. </button>
  608. <button
  609. class="remove-btn"
  610. @click="removeDialogue(sectionIndex, dialogueIndex)"
  611. >×</button
  612. >
  613. </div>
  614. <div class="action-buttons-row">
  615. <button
  616. v-if="!dialogue.voiceoverUrl"
  617. class="generate-btn small"
  618. :disabled="
  619. !dialogue.content ||
  620. !dialogue.roleName ||
  621. dialogue.generatingVoiceover
  622. "
  623. @click="generateVoiceover(sectionIndex, dialogueIndex)"
  624. >
  625. <span class="voice-icon">{{
  626. dialogue.generatingVoiceover ? '生成中...' : '生成语音'
  627. }}</span>
  628. </button>
  629. <button
  630. v-if="dialogue.voiceoverUrl"
  631. class="generate-btn small"
  632. :disabled="
  633. !dialogue.content ||
  634. !dialogue.roleName ||
  635. dialogue.generatingVoiceover
  636. "
  637. @click="generateVoiceover(sectionIndex, dialogueIndex)"
  638. >
  639. <span class="voice-icon">{{
  640. dialogue.generatingVoiceover ? '生成中...' : '重新生成'
  641. }}</span>
  642. </button>
  643. </div>
  644. </div>
  645. </template>
  646. <!-- 视频 -->
  647. <template v-else-if="dialogue.type === 'video'">
  648. <div class="media-input-group" style="display: flex; align-items: center; justify-content: center;">
  649. <span class="media-label" style="margin-right: 10px;">视频提示词</span>
  650. <el-input
  651. v-model="dialogue.videoPrompt"
  652. type="textarea"
  653. :autosize="{ minRows: 2, maxRows: 4 }"
  654. placeholder="描述词"
  655. class="media-prompt-video"
  656. style="flex: 1; margin-right: 10px;"
  657. />
  658. <el-button
  659. type="primary"
  660. size="small"
  661. :loading="dialogue.generatingVideo"
  662. :disabled="
  663. !dialogue.videoPrompt || dialogue.generatingVideo
  664. "
  665. @click="generateDialogueVideo(sectionIndex, dialogueIndex)"
  666. class="generate-btn"
  667. style="margin-right: 10px;"
  668. >
  669. {{
  670. dialogue.generatingVideo
  671. ? '生成中...'
  672. : dialogue.videoUrl
  673. ? '重新生成'
  674. : '生成'
  675. }}
  676. </el-button>
  677. <div class="upload-container" style="margin: 0 10px;">
  678. <UploadVideo2 v-model="dialogue.videoUrl" />
  679. </div>
  680. <button
  681. class="remove-btn"
  682. @click="removeDialogue(sectionIndex, dialogueIndex)"
  683. >×</button>
  684. </div>
  685. </template>
  686. <!-- 朗诵评价 -->
  687. <template v-else-if="dialogue.type === 'poem_reading'">
  688. <div class="dialogue-role-select">
  689. <el-select
  690. v-model="dialogue.roleName"
  691. placeholder="选择角色"
  692. style="width: 140px"
  693. clearable
  694. >
  695. <el-option
  696. v-for="role in digitalHumans"
  697. :key="role.id"
  698. :label="role.name"
  699. :value="role.name"
  700. />
  701. </el-select>
  702. </div>
  703. <div class="dialogue-content-container">
  704. <el-input
  705. v-model="dialogue.content"
  706. type="textarea"
  707. class="dialogue-content"
  708. placeholder="朗诵评价内容..."
  709. :autosize="{ minRows: 2, maxRows: 4 }"
  710. />
  711. </div>
  712. <div class="action-buttons">
  713. <div class="action-buttons-row">
  714. <button
  715. class="remove-btn"
  716. @click="removeDialogue(sectionIndex, dialogueIndex)"
  717. >×</button
  718. >
  719. </div>
  720. </div>
  721. </template>
  722. <!-- 写诗评价 -->
  723. <template v-else-if="dialogue.type === 'write_reading'">
  724. <div class="dialogue-role-select">
  725. <el-select
  726. v-model="dialogue.roleName"
  727. placeholder="选择角色"
  728. style="width: 140px"
  729. clearable
  730. >
  731. <el-option
  732. v-for="role in digitalHumans"
  733. :key="role.id"
  734. :label="role.name"
  735. :value="role.name"
  736. />
  737. </el-select>
  738. </div>
  739. <div class="dialogue-content-container">
  740. <el-input
  741. v-model="dialogue.content"
  742. type="textarea"
  743. class="dialogue-content"
  744. placeholder="写诗评价内容..."
  745. :autosize="{ minRows: 2, maxRows: 4 }"
  746. />
  747. </div>
  748. <div class="action-buttons">
  749. <div class="action-buttons-row">
  750. <button
  751. class="remove-btn"
  752. @click="removeDialogue(sectionIndex, dialogueIndex)"
  753. >×</button
  754. >
  755. </div>
  756. </div>
  757. </template>
  758. <!-- 背诵诗词评价 -->
  759. <template v-else-if="dialogue.type === 'recite_reading'">
  760. <div class="dialogue-role-select">
  761. <el-select
  762. v-model="dialogue.roleName"
  763. placeholder="选择角色"
  764. style="width: 140px"
  765. clearable
  766. >
  767. <el-option
  768. v-for="role in digitalHumans"
  769. :key="role.id"
  770. :label="role.name"
  771. :value="role.name"
  772. />
  773. </el-select>
  774. </div>
  775. <div class="dialogue-content-container">
  776. <el-input
  777. v-model="dialogue.content"
  778. type="textarea"
  779. class="dialogue-content"
  780. placeholder="背诵诗词评价内容..."
  781. :autosize="{ minRows: 2, maxRows: 4 }"
  782. />
  783. </div>
  784. <div class="action-buttons">
  785. <div class="action-buttons-row">
  786. <button
  787. class="remove-btn"
  788. @click="removeDialogue(sectionIndex, dialogueIndex)"
  789. >×</button
  790. >
  791. </div>
  792. </div>
  793. </template>
  794. </div>
  795. </div>
  796. <div class="add-dialogue-buttons">
  797. <button class="add-dialogue-btn digital" @click="addDialogue(sectionIndex)"
  798. >+ 添加对话</button
  799. >
  800. <button
  801. class="add-dialogue-btn quest-user"
  802. @click="addQuestWithUserReply(sectionIndex)"
  803. >+ 添加提问与回复</button
  804. >
  805. <button class="add-dialogue-btn video" @click="addVideoDialogue(sectionIndex)"
  806. >+ 添加视频</button
  807. >
  808. <div class="more-dropdown-wrapper">
  809. <button
  810. class="add-dialogue-btn more-btn"
  811. @click.stop="toggleMoreMenu(sectionIndex)"
  812. >+ 更多 ▾</button>
  813. <div
  814. v-if="activeMoreMenu === sectionIndex"
  815. class="more-dropdown-menu"
  816. @click.stop
  817. >
  818. <button class="more-item-btn poem" @click="addPoemDialogue(sectionIndex); activeMoreMenu = null"
  819. >+ 添加诗词</button
  820. >
  821. <button class="more-item-btn poem_reading" @click="addPoemReadingDialogue(sectionIndex); activeMoreMenu = null"
  822. >+ 添加朗诵评价</button
  823. >
  824. <button class="more-item-btn write_reading" @click="addWriteReadingDialogue(sectionIndex); activeMoreMenu = null"
  825. >+ 添加写诗评价</button
  826. >
  827. <button class="more-item-btn recite_reading" @click="addReciteReadingDialogue(sectionIndex); activeMoreMenu = null"
  828. >+ 添加背诵诗词评价</button
  829. >
  830. </div>
  831. </div>
  832. </div>
  833. </div>
  834. </div>
  835. <button class="add-section-btn" @click="addSection">+ 添加环节</button>
  836. </div>
  837. <div class="preview-actions">
  838. <button v-if="currentStep > 1" class="secondary-btn" @click="currentStep--">
  839. 重新生成
  840. </button>
  841. <button class="primary-btn" @click="nextStep"> 预览完整脚本 </button>
  842. </div>
  843. </div>
  844. <!-- 步骤3:预览与保存 -->
  845. <div v-else-if="currentStep === 3" class="step-content">
  846. <div class="preview-container">
  847. <h3>课程脚本预览</h3>
  848. <div class="scrollable-content">
  849. <br />
  850. <div v-if="isValidationPassed" class="validation-result valid">
  851. {{ validationMessage }}
  852. </div>
  853. <div v-else>
  854. <div
  855. v-for="(error, index) in errorMessages"
  856. :key="index"
  857. class="validation-result invalid"
  858. >
  859. {{ error }}
  860. </div>
  861. </div>
  862. <div class="preview-content">
  863. <div
  864. v-for="(section, sectionIndex) in scriptData.sections"
  865. :key="sectionIndex"
  866. class="preview-section"
  867. :style="{
  868. backgroundImage: section.backgroundType === 'imageAudio' && section.backgroundImage.url
  869. ? `url(${section.backgroundImage.url})`
  870. : 'none',
  871. backgroundSize: 'cover',
  872. backgroundPosition: 'center',
  873. backgroundRepeat: 'no-repeat'
  874. }"
  875. >
  876. <div v-if="section.backgroundType === 'video' && section.backgroundVideo.url" class="preview-video">
  877. <video :src="section.backgroundVideo.url" alt="视频背景" autoplay loop muted ></video>
  878. </div>
  879. <div class="preview-section-content">
  880. <div class="preview-media">
  881. <div class="preview-media-left">
  882. <label class="section-name-label">环节 {{ sectionIndex + 1 }}</label>
  883. <strong>{{ section.name }}</strong>
  884. </div>
  885. <div class="preview-media-right">
  886. <span v-if="section.backgroundType === 'imageAudio' && section.backgroundAudio.type" class="preview-audio">
  887. 背景音:{{ section.backgroundAudio.type }}
  888. <button
  889. class="play-btn small"
  890. @click="playBackgroundAudio(section.backgroundAudio.type)"
  891. >
  892. <span class="play-icon">{{
  893. audioState.isPlaying &&
  894. audioState.currentType === 'background' &&
  895. audioState.currentUrl === section.backgroundAudio.url
  896. ? '⏸'
  897. : '▶'
  898. }}</span>
  899. </button>
  900. </span>
  901. </div>
  902. </div>
  903. <div class="preview-dialogues">
  904. <div
  905. v-for="(dialogue, dialogueIndex) in section.dialogues.filter(
  906. (d) => d.type !== 'user'
  907. )"
  908. :key="dialogueIndex"
  909. class="preview-dialogue"
  910. :class="dialogue.type"
  911. >
  912. <div class="dialogue-header">
  913. <div class="dialogue-header-left">
  914. <div class="dialogue-type-tag" :class="dialogue.type">
  915. {{
  916. dialogue.type === 'digital'
  917. ? '数字人'
  918. : dialogue.type === 'user'
  919. ? '用户'
  920. : dialogue.type === 'quest'
  921. ? '提问'
  922. : dialogue.type === 'poem'
  923. ? '诗词'
  924. : dialogue.type === 'poem_reading'
  925. ? '朗诵评价'
  926. : dialogue.type === 'write_reading'
  927. ? '写诗评价'
  928. : dialogue.type === 'recite_reading'
  929. ? '背诵诗词评价'
  930. : '视频'
  931. }}
  932. </div>
  933. <div class="dialogue-role">
  934. {{
  935. dialogue.type !== 'user' && dialogue.type !== 'video'
  936. ? getRoleName(dialogue.roleName)
  937. : dialogue.type === 'video' ? '视频' : '用户'
  938. }}:
  939. </div>
  940. </div>
  941. <button
  942. v-if="dialogue.voiceoverUrl"
  943. class="play-btn small"
  944. @click="playVoiceover(dialogue.voiceoverUrl)"
  945. >
  946. <span class="play-icon">{{
  947. audioState.isPlaying &&
  948. audioState.currentType === 'voice' &&
  949. audioState.currentUrl === dialogue.voiceoverUrl
  950. ? '⏸'
  951. : '▶'
  952. }}</span>
  953. </button>
  954. </div>
  955. <template v-if="dialogue.type === 'video'">
  956. <div class="dialogue-text">{{ dialogue.videoPrompt }}</div>
  957. <div v-if="dialogue.videoUrl" class="media-preview">
  958. <video :src="dialogue.videoUrl" alt="视频预览" controls></video>
  959. </div>
  960. </template>
  961. <template v-else>
  962. <div class="dialogue-text" v-html="parseMarkdown(dialogue.content)"></div>
  963. </template>
  964. <div
  965. v-if="dialogue.type === 'user' && dialogue.roleName"
  966. class="reply-info"
  967. >
  968. 回复角色:{{ getRoleName(dialogue.roleName) }}
  969. </div>
  970. </div>
  971. </div>
  972. </div>
  973. </div>
  974. </div>
  975. </div>
  976. <div class="preview-actions">
  977. <button class="secondary-btn" @click="currentStep = 2">返回修改</button>
  978. <!-- <button
  979. class="primary-btn"
  980. :disabled="!isValidationPassed"
  981. @click="showVideoPreview"
  982. >
  983. 预览视频
  984. </button>-->
  985. <button class="primary-btn" :disabled="!isValidationPassed" @click="saveScript">
  986. 保存课程脚本
  987. </button>
  988. </div>
  989. </div>
  990. </div>
  991. </div>
  992. </div>
  993. <!-- 视频预览模态框 -->
  994. <VideoPreview
  995. :visible="showVideoPreviewModal"
  996. :script-data="scriptData"
  997. :script-roles="digitalHumans"
  998. @close="closeVideoPreview"
  999. />
  1000. </div>
  1001. </Dialog>
  1002. </template>
  1003. <script setup>
  1004. import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
  1005. import { Dialog } from '@/components/Dialog'
  1006. import { ElMessage } from 'element-plus'
  1007. import UploadImg from '@/components/UploadFile/src/UploadImg.vue'
  1008. import UploadVideo2 from '@/components/UploadFile/src/UploadVideo2.vue'
  1009. import { ChatMessageApi } from '@/api/ai/chat/message'
  1010. import { ChatConversationApi } from '@/api/ai/chat/conversation'
  1011. import { ChatRoleApi } from '@/api/ai/model/chatRole'
  1012. import { ImageApi } from '@/api/ai/image'
  1013. import { TtsApi } from '@/api/ai/tts'
  1014. import { VideoApi} from '@/api/ai/video'
  1015. import VideoPreview from '@/views/bjdx/course/aiGenerate/VideoPreview.vue'
  1016. import { AiImageStatusEnum, AiPlatformEnum, AiVideoStatusEnum } from '@/views/ai/utils/constants'
  1017. import { marked } from 'marked'
  1018. import { useUserStore } from '@/store/modules/user'
  1019. // 步骤配置
  1020. const steps = [
  1021. { id: 1, label: 'AI生成脚本' },
  1022. { id: 2, label: '编辑脚本与媒体' },
  1023. { id: 3, label: '预览与保存' }
  1024. ]
  1025. // 当前步骤
  1026. const currentStep = ref(1)
  1027. // 步骤1数据
  1028. const scriptPrompt = ref('')
  1029. const selectedMainTeacher = ref('')
  1030. const selectedAssistants = ref([])
  1031. const selectedThemeType = ref()
  1032. const isGenerating = ref(false)
  1033. // 对话框可见性
  1034. const props = defineProps({
  1035. visible: {
  1036. type: Boolean,
  1037. default: false
  1038. },
  1039. initialStep: {
  1040. type: Number,
  1041. default: 1
  1042. },
  1043. initialScriptData: {
  1044. type: String,
  1045. default: ''
  1046. }
  1047. })
  1048. const dialogVisible = computed({
  1049. get: () => props.visible,
  1050. set: (value) => emit('update:visible', value)
  1051. })
  1052. // 获取用户信息
  1053. const userStore = useUserStore()
  1054. const userId = computed(() => userStore.getUser.id)
  1055. // 检查是否存在草稿缓存
  1056. const hasDraftCache = ref(false)
  1057. // 步骤2生成状态
  1058. const isGeneratingImages = ref(false)
  1059. const isGeneratingVoiceovers = ref(false)
  1060. const isGeneratingVideos = ref(false)
  1061. // 数字人列表
  1062. const digitalHumans = ref([])
  1063. // 背景音类型
  1064. const backgroundMusicTypes = ref([
  1065. {
  1066. id: '轻松欢快',
  1067. name: '轻松欢快',
  1068. url: 'https://learn-ai.com.cn/admin-api/infra/file/29/get/20260310/AI_1773106630966.MP3'
  1069. }
  1070. ])
  1071. // 诗词课(英才小学生)课程小节选项
  1072. const poetryLessonSections = ref([
  1073. {
  1074. value: '1',
  1075. label: '读·共读辨情,初识诗境',
  1076. constraint: ['digital', 'poem_reading', 'poem'],
  1077. description: '引导学生朗读诗词,通过共读辨情,本节课只需要带着学生一起朗读,不需要其他对话类型。(对话类型参考:digital对话引导,poem诗句,poem_reading学生朗读,digital对话引导...)'
  1078. },
  1079. {
  1080. value: '2',
  1081. label: '悟·深究共情,解码精神',
  1082. constraint: ['digital', 'video', 'quest', 'user'],
  1083. description: '保证第一个环节的第一个对话类型是(video)AIGC视频类型,填充视频生成提示词(根据诗词情感生成提示词),' +
  1084. '后续再以作者和学生对话的方式进行沉浸式课堂教学,先逐句拆解每一首诗的含义,讲解重点字词。' +
  1085. '然后展开讲解诗人的生平背景,' +
  1086. '最后讲解整句诗的思想,中间穿插互动提问(问题方向为:抓住诗词特色画面,理解环境描写如何烘托人物心境,情感这几点来提问)'
  1087. },
  1088. {
  1089. value: '3',
  1090. label: '用·印证文脉,联结现实',
  1091. constraint: ['digital', 'poem', 'recite_reading'],
  1092. description: '本节小课是先跟着诗词跟读,都读完后给出引导进行背诵,注意:逐句背诵,每一句诗词引导背诵和用户背诵都要单独一个环节,方便环节背景图应景(背景图上不要出现诗词语句)' +
  1093. '注意对话流程:digital对话引导跟读,poem诗句,digital对话背诵引导(不要出现诗词语句),recite_reading学生背诵...'
  1094. },
  1095. {
  1096. value: '4',
  1097. label: '创·汲智明志,创意表达',
  1098. constraint: ['digital', 'quest', 'user', 'write_reading'],
  1099. description: '将诗词内容,结合新的时代进行思考,给同学们进行提问,引出创作动机,并引导学生根据其中经典诗句进行仿写,可以先给出例子,然后引导学生进行仿写。' +
  1100. '注意每条仿写对话前面都要有引导对话和示例,引导学生根据示例进行仿写。' +
  1101. '仿写结束后以作者和学生对话的方式进行沉浸式课堂教学,中间穿插互动提问'
  1102. },
  1103. {
  1104. value: '5',
  1105. label: '评价',
  1106. constraint: ['digital', 'poem', 'poem_reading', 'write_reading'],
  1107. description: '本节课需要先进行诗词朗读,引导学生根据诗词内容进行评价(注意对话流程:digital对话引导,poem诗句,poem_reading学生朗读...)' +
  1108. '然后引导学生仿写诗词进行评价。(后续对话流程:digital对话引导先给出示例,write_reading学生仿写)'
  1109. }
  1110. ])
  1111. // 当前选中的课程小节
  1112. const selectedLessonSection = ref('')
  1113. // 从localStorage加载脚本数据
  1114. const loadScriptDataFromCache = () => {
  1115. try {
  1116. const key = `courseScriptData_${userId.value}`
  1117. const cachedData = localStorage.getItem(key)
  1118. if (cachedData) {
  1119. try {
  1120. return JSON.parse(cachedData)
  1121. } catch (error) {
  1122. console.error('解析缓存数据失败:', error)
  1123. }
  1124. }
  1125. } catch (error) {
  1126. console.error('获取用户信息失败:', error)
  1127. }
  1128. return null
  1129. }
  1130. // 是否为编辑模式
  1131. const isEditMode = ref(false)
  1132. // 脚本数据结构
  1133. const scriptData = reactive(
  1134. loadScriptDataFromCache() || {
  1135. title: '',
  1136. sections: [
  1137. {
  1138. name: '环节一',
  1139. backgroundType: 'imageAudio', // imageAudio: 图音背景, video: 视频背景
  1140. backgroundImage: {
  1141. prompt: '',
  1142. url: '',
  1143. generating: false
  1144. },
  1145. backgroundAudio: {
  1146. type: '',
  1147. url: ''
  1148. },
  1149. backgroundVideo: {
  1150. prompt: '',
  1151. url: '',
  1152. generating: false
  1153. },
  1154. dialogues: [
  1155. {
  1156. type: 'digital',
  1157. roleName: '',
  1158. content: '',
  1159. voiceoverUrl: '',
  1160. generatingVoiceover: false
  1161. },
  1162. {
  1163. type: 'user',
  1164. roleName: '',
  1165. content: ''
  1166. }
  1167. ]
  1168. }
  1169. ]
  1170. }
  1171. )
  1172. // 兼容旧数据,为旧数据添加背景类型字段和提问类型字段
  1173. if (scriptData.sections) {
  1174. scriptData.sections.forEach(section => {
  1175. if (!section.backgroundType) {
  1176. section.backgroundType = 'imageAudio';
  1177. }
  1178. if (!section.backgroundVideo) {
  1179. section.backgroundVideo = {
  1180. prompt: '',
  1181. url: '',
  1182. generating: false
  1183. };
  1184. }
  1185. // 为旧数据的提问类型对话添加默认的questionType
  1186. if (section.dialogues) {
  1187. section.dialogues.forEach(dialogue => {
  1188. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1189. dialogue.questionType = 'AI Q&A';
  1190. dialogue.options = [{ content: '' }, { content: '' }];
  1191. dialogue.answer = '';
  1192. }
  1193. });
  1194. }
  1195. });
  1196. }
  1197. // 保存脚本数据到localStorage
  1198. const saveScriptDataToCache = () => {
  1199. try {
  1200. const key = `courseScriptData_${userId.value}`
  1201. localStorage.setItem(key, JSON.stringify(scriptData))
  1202. hasDraftCache.value = true
  1203. console.log('保存脚本数据到缓存', key)
  1204. } catch (error) {
  1205. console.error('保存缓存数据失败:', error)
  1206. }
  1207. }
  1208. // 清空脚本数据缓存
  1209. const clearScriptDataCache = () => {
  1210. const key = `courseScriptData_${userId.value}`
  1211. localStorage.removeItem(key)
  1212. hasDraftCache.value = false
  1213. console.log('清除脚本数据缓存', key)
  1214. }
  1215. // 加载草稿并跳转到步骤2
  1216. const loadDraftAndGotoStep2 = () => {
  1217. const cachedData = loadScriptDataFromCache()
  1218. if (cachedData) {
  1219. Object.assign(scriptData, cachedData)
  1220. // 为加载的草稿数据添加背景类型和视频背景字段
  1221. if (scriptData.sections) {
  1222. scriptData.sections.forEach(section => {
  1223. if (!section.backgroundType) {
  1224. section.backgroundType = 'imageAudio';
  1225. }
  1226. if (!section.backgroundVideo) {
  1227. section.backgroundVideo = {
  1228. prompt: '',
  1229. url: '',
  1230. generating: false
  1231. };
  1232. }
  1233. // 为旧数据的提问类型对话添加默认的questionType
  1234. if (section.dialogues) {
  1235. section.dialogues.forEach(dialogue => {
  1236. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1237. dialogue.questionType = 'AI Q&A';
  1238. dialogue.options = [{ content: '' }, { content: '' }];
  1239. dialogue.answer = '';
  1240. }
  1241. });
  1242. }
  1243. });
  1244. }
  1245. currentStep.value = 2
  1246. }
  1247. }
  1248. // 监听脚本数据变化,自动保存到缓存
  1249. watch(
  1250. () => scriptData,
  1251. () => {
  1252. saveScriptDataToCache()
  1253. },
  1254. { deep: true }
  1255. )
  1256. // 监听对话框可见性变化
  1257. watch(
  1258. () => props.visible,
  1259. (newVisible, oldVisible) => {
  1260. if (newVisible) {
  1261. // 对话框打开时,设置初始步骤
  1262. currentStep.value = props.initialStep
  1263. // 清空被替换的URL集合
  1264. replacedUrls.value.clear()
  1265. // 处理脚本数据
  1266. if (props.initialScriptData) {
  1267. // 标记为编辑模式
  1268. isEditMode.value = true
  1269. try {
  1270. const parsedData = JSON.parse(props.initialScriptData)
  1271. Object.assign(scriptData, parsedData)
  1272. // 为加载的脚本数据添加背景类型和视频背景字段
  1273. if (scriptData.sections) {
  1274. scriptData.sections.forEach(section => {
  1275. if (!section.backgroundType) {
  1276. section.backgroundType = 'imageAudio';
  1277. }
  1278. if (!section.backgroundVideo) {
  1279. section.backgroundVideo = {
  1280. prompt: '',
  1281. url: '',
  1282. generating: false
  1283. };
  1284. }
  1285. // 为旧数据的提问类型对话添加默认的questionType
  1286. if (section.dialogues) {
  1287. section.dialogues.forEach(dialogue => {
  1288. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1289. dialogue.questionType = 'AI Q&A';
  1290. dialogue.options = [{ content: '' }, { content: '' }];
  1291. dialogue.answer = '';
  1292. }
  1293. });
  1294. }
  1295. });
  1296. }
  1297. } catch (error) {
  1298. console.error('解析脚本数据失败:', error)
  1299. // 解析失败,尝试加载草稿
  1300. const cachedData = loadScriptDataFromCache()
  1301. if (cachedData) {
  1302. Object.assign(scriptData, cachedData)
  1303. // 为加载的草稿数据添加背景类型和视频背景字段
  1304. if (scriptData.sections) {
  1305. scriptData.sections.forEach(section => {
  1306. if (!section.backgroundType) {
  1307. section.backgroundType = 'imageAudio';
  1308. }
  1309. if (!section.backgroundVideo) {
  1310. section.backgroundVideo = {
  1311. prompt: '',
  1312. url: '',
  1313. generating: false
  1314. };
  1315. }
  1316. // 为旧数据的提问类型对话添加默认的questionType
  1317. if (section.dialogues) {
  1318. section.dialogues.forEach(dialogue => {
  1319. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1320. dialogue.questionType = 'AI Q&A';
  1321. dialogue.options = [{ content: '' }, { content: '' }];
  1322. dialogue.answer = '';
  1323. }
  1324. });
  1325. }
  1326. });
  1327. }
  1328. }
  1329. }
  1330. } else {
  1331. // 标记为新建模式
  1332. isEditMode.value = false
  1333. // 没有脚本数据,尝试加载草稿
  1334. const cachedData = loadScriptDataFromCache()
  1335. if (cachedData) {
  1336. Object.assign(scriptData, cachedData)
  1337. // 为加载的草稿数据添加背景类型和视频背景字段
  1338. if (scriptData.sections) {
  1339. scriptData.sections.forEach(section => {
  1340. if (!section.backgroundType) {
  1341. section.backgroundType = 'imageAudio';
  1342. }
  1343. if (!section.backgroundVideo) {
  1344. section.backgroundVideo = {
  1345. prompt: '',
  1346. url: '',
  1347. generating: false
  1348. };
  1349. }
  1350. // 为旧数据的提问类型对话添加默认的questionType
  1351. if (section.dialogues) {
  1352. section.dialogues.forEach(dialogue => {
  1353. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1354. dialogue.questionType = 'AI Q&A';
  1355. dialogue.options = [{ content: '' }, { content: '' }];
  1356. dialogue.answer = '';
  1357. }
  1358. });
  1359. }
  1360. });
  1361. }
  1362. }
  1363. }
  1364. } else if (oldVisible) {
  1365. // 对话框关闭时
  1366. if (props.initialScriptData) {
  1367. // 编辑进来的,清空缓存
  1368. clearScriptDataCache()
  1369. }
  1370. // 重置编辑模式标记
  1371. isEditMode.value = false
  1372. // 新增进来的,保留缓存
  1373. }
  1374. }
  1375. )
  1376. // 音频播放状态
  1377. const audioState = reactive({
  1378. currentAudio: null,
  1379. isPlaying: false,
  1380. currentType: '',
  1381. currentUrl: ''
  1382. })
  1383. // 存储所有音频实例
  1384. const audioInstances = new Map()
  1385. // 计算属性:判断是否可以进入下一步
  1386. const canProceed = computed(() => {
  1387. switch (currentStep.value) {
  1388. case 1:
  1389. return !!scriptPrompt.value && !!selectedMainTeacher.value && !!selectedThemeType.value
  1390. case 2:
  1391. case 3:
  1392. return scriptData.sections.every(
  1393. (section) =>
  1394. section.backgroundImage.url &&
  1395. section.dialogues.every(
  1396. (dialogue) =>
  1397. (dialogue.type === 'digital' ||
  1398. dialogue.type === 'quest' ||
  1399. dialogue.type === 'poem' ||
  1400. dialogue.type === 'poem_reading' ||
  1401. dialogue.type === 'write_reading' ||
  1402. dialogue.type === 'recite_reading') &&
  1403. dialogue.roleName &&
  1404. dialogue.content.trim() &&
  1405. (dialogue.type === 'poem_reading' ||
  1406. dialogue.type === 'write_reading' ||
  1407. dialogue.type === 'recite_reading' ||
  1408. dialogue.voiceoverUrl)
  1409. )
  1410. )
  1411. default:
  1412. return false
  1413. }
  1414. })
  1415. // 计算属性:检查是否有任何背景图正在生成
  1416. const isAnyImageGenerating = computed(() => {
  1417. return scriptData.sections.some((section) => section.backgroundImage.generating)
  1418. })
  1419. // 计算属性:检查是否有任何配音正在生成
  1420. const isAnyVoiceoverGenerating = computed(() => {
  1421. return scriptData.sections.some((section) =>
  1422. section.dialogues.some((dialogue) => dialogue.generatingVoiceover)
  1423. )
  1424. })
  1425. // 计算属性:检查是否有任何视频正在生成
  1426. const isAnyVideoGenerating = computed(() => {
  1427. return scriptData.sections.some((section) => {
  1428. // 检查背景视频是否正在生成
  1429. if (section.backgroundVideo.generating) {
  1430. return true
  1431. }
  1432. // 检查对话视频是否正在生成
  1433. return section.dialogues.some((dialogue) => dialogue.generatingVideo)
  1434. })
  1435. })
  1436. // 校验结果
  1437. const isValidationPassed = ref(false)
  1438. const validationMessage = ref('')
  1439. const errorMessages = ref([])
  1440. // 视频预览状态
  1441. const showVideoPreviewModal = ref(false)
  1442. // 全屏状态
  1443. const fullscreen = ref(false)
  1444. // 存储被替换的URL链接集合
  1445. const replacedUrls = ref(new Set())
  1446. const activeConversationId = ref(null) // 选中的对话编号
  1447. const conversationInAbortController = ref() // 对话进行中 abort 控制器(控制 stream 对话)
  1448. const conversationInProgress = ref(false) // 对话是否正在进行中。目前只有【发送】消息时,会更新为 true,避免切换对话、删除对话等操作
  1449. const enableContext = ref(false) // 是否开启上下文
  1450. // 接收 Stream 消息
  1451. const receiveMessageFullText = ref('')
  1452. const scriptDataTemp = ref(null)
  1453. // 步骤1:生成脚本
  1454. const generateScript = async () => {
  1455. isGenerating.value = true
  1456. try {
  1457. clearScriptDataCache()
  1458. scriptData.title = ''
  1459. scriptData.sections = []
  1460. receiveMessageFullText.value = ''
  1461. scriptDataTemp.value = null
  1462. const role = digitalHumans.value.find((r) => r.name === selectedMainTeacher.value)
  1463. let content =
  1464. scriptPrompt.value +
  1465. '(主讲人:' +
  1466. role.name +
  1467. ',主讲人角色定位:' +
  1468. role.description +
  1469. ';助讲有:'
  1470. let zhujiang = []
  1471. selectedAssistants.value.forEach((rName) => {
  1472. const role = digitalHumans.value.find((r) => r.name === rName)
  1473. zhujiang.push(role.name + '[' + role.description + ']')
  1474. })
  1475. content += zhujiang.join(',') + ')'
  1476. // 如果选择了诗词课(英才小学生)并且选中了课程小节,将其信息追加到内容中
  1477. if (selectedThemeType.value === '262' && selectedLessonSection.value) {
  1478. const lessonSection = poetryLessonSections.value.find(
  1479. (s) => s.value === selectedLessonSection.value
  1480. )
  1481. if (lessonSection) {
  1482. content +=
  1483. '【课程小节:' +
  1484. lessonSection.label +
  1485. ';本节课只能出现下面的对话类型:' +
  1486. lessonSection.constraint.join(',') +
  1487. '禁止出现对话类型之外的对话类型;小节描述:' +
  1488. lessonSection.description +
  1489. '】'
  1490. }
  1491. }
  1492. await createAiRoleIdConversation(Number(selectedThemeType.value))
  1493. currentStep.value = 2
  1494. await doSendMessageStream(activeConversationId.value, content)
  1495. } catch (error) {
  1496. console.error('生成脚本失败:', error)
  1497. } finally {
  1498. isGenerating.value = false
  1499. }
  1500. }
  1501. /** 选择 card 角色:新建聊天对话 */
  1502. const createAiRoleIdConversation = async (roleId) => {
  1503. activeConversationId.value = await ChatConversationApi.createChatConversationMy({
  1504. roleId: roleId
  1505. })
  1506. }
  1507. /** 真正执行【发送】消息操作 */
  1508. const doSendMessageStream = async (conversationId, content) => {
  1509. conversationInAbortController.value = new AbortController()
  1510. conversationInProgress.value = true
  1511. scriptPrompt.value = ''
  1512. try {
  1513. let isFirstChunk = true
  1514. await ChatMessageApi.sendChatMessageStream(
  1515. conversationId,
  1516. content,
  1517. conversationInAbortController.value,
  1518. enableContext.value,
  1519. async (res) => {
  1520. const { code, data, msg } = JSON.parse(res.data)
  1521. if (code !== 0) {
  1522. console.error(`对话异常! ${msg}`)
  1523. return
  1524. }
  1525. if (data.eventType === 'TEXT') {
  1526. if (data.receive?.content === '') {
  1527. return
  1528. }
  1529. if (isFirstChunk) {
  1530. isFirstChunk = false
  1531. }
  1532. receiveMessageFullText.value += data.receive.content
  1533. console.log('数据加载中..')
  1534. try {
  1535. const parsedData = JSON.parse(receiveMessageFullText.value)
  1536. scriptDataTemp.value = parsedData
  1537. Object.assign(scriptData, parsedData)
  1538. // 为新生成的脚本数据添加背景类型和视频背景字段
  1539. if (scriptData.sections) {
  1540. scriptData.sections.forEach(section => {
  1541. if (!section.backgroundType) {
  1542. section.backgroundType = 'imageAudio';
  1543. }
  1544. if (!section.backgroundVideo) {
  1545. section.backgroundVideo = {
  1546. prompt: '',
  1547. url: '',
  1548. generating: false
  1549. };
  1550. }
  1551. // 为新生成的提问类型对话添加默认的questionType
  1552. if (section.dialogues) {
  1553. section.dialogues.forEach(dialogue => {
  1554. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1555. dialogue.questionType = 'AI Q&A';
  1556. dialogue.options = [{ content: '' }, { content: '' }];
  1557. dialogue.answer = '';
  1558. }
  1559. });
  1560. }
  1561. });
  1562. }
  1563. } catch (e) {
  1564. // 解析失败,说明数据还不完整,继续等待
  1565. }
  1566. }
  1567. },
  1568. (error) => {
  1569. console.error(`对话异常! ${error}`)
  1570. throw error
  1571. },
  1572. () => {
  1573. try {
  1574. if (receiveMessageFullText.value) {
  1575. console.log('最终数据:', receiveMessageFullText.value)
  1576. const parsedData = JSON.parse(receiveMessageFullText.value)
  1577. console.log('最终数据json:', parsedData)
  1578. scriptDataTemp.value = parsedData
  1579. Object.assign(scriptData, parsedData)
  1580. // 为新生成的脚本数据添加背景类型和视频背景字段
  1581. if (scriptData.sections) {
  1582. scriptData.sections.forEach(section => {
  1583. if (!section.backgroundType) {
  1584. section.backgroundType = 'imageAudio';
  1585. }
  1586. if (!section.backgroundVideo) {
  1587. section.backgroundVideo = {
  1588. prompt: '',
  1589. url: '',
  1590. generating: false
  1591. };
  1592. }
  1593. // 为新生成的提问类型对话添加默认的questionType
  1594. if (section.dialogues) {
  1595. section.dialogues.forEach(dialogue => {
  1596. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1597. dialogue.questionType = 'AI Q&A';
  1598. dialogue.options = [{ content: '' }, { content: '' }];
  1599. dialogue.answer = '';
  1600. }
  1601. });
  1602. }
  1603. });
  1604. }
  1605. }
  1606. } catch (e) {
  1607. console.error('最终数据解析失败:', e)
  1608. // 清洗规则:移除```json、```、** 等非JSON标记,只保留中间的JSON内容
  1609. try {
  1610. let cleanJsonStr = receiveMessageFullText.value
  1611. const parsedData = JSON.parse(
  1612. cleanJsonStr
  1613. .replace(/^```json\s*/, '')
  1614. .replace(/\s*```$/, '')
  1615. .replace(/\*\*/g, '')
  1616. .trim()
  1617. )
  1618. console.log('最终清洗后数据json:', parsedData)
  1619. scriptDataTemp.value = parsedData
  1620. Object.assign(scriptData, parsedData)
  1621. // 为新生成的脚本数据添加背景类型和视频背景字段
  1622. if (scriptData.sections) {
  1623. scriptData.sections.forEach(section => {
  1624. if (!section.backgroundType) {
  1625. section.backgroundType = 'imageAudio';
  1626. }
  1627. if (!section.backgroundVideo) {
  1628. section.backgroundVideo = {
  1629. prompt: '',
  1630. url: '',
  1631. generating: false
  1632. };
  1633. }
  1634. // 为新生成的提问类型对话添加默认的questionType
  1635. if (section.dialogues) {
  1636. section.dialogues.forEach(dialogue => {
  1637. if (dialogue.type === 'quest' && !dialogue.questionType) {
  1638. dialogue.questionType = 'AI Q&A';
  1639. dialogue.options = [{ content: '' }, { content: '' }];
  1640. dialogue.answer = '';
  1641. }
  1642. });
  1643. }
  1644. });
  1645. }
  1646. } catch (cleanError) {
  1647. console.error('清洗后数据解析失败:', cleanError)
  1648. }
  1649. }
  1650. }
  1651. )
  1652. } catch (error) {
  1653. console.error('发送消息流失败:', error)
  1654. } finally {
  1655. conversationInProgress.value = false
  1656. }
  1657. }
  1658. // 步骤2:添加环节
  1659. const addSection = () => {
  1660. scriptData.sections.push({
  1661. name: `环节${scriptData.sections.length + 1}`,
  1662. backgroundType: 'imageAudio', // imageAudio: 图音背景, video: 视频背景
  1663. backgroundImage: { prompt: '', url: '', generating: false },
  1664. backgroundAudio: { type: '', url: '' },
  1665. backgroundVideo: { prompt: '', url: '', generating: false },
  1666. dialogues: []
  1667. })
  1668. }
  1669. // 步骤2:添加对话(数字人)
  1670. const addDialogue = (sectionIndex) => {
  1671. scriptData.sections[sectionIndex].dialogues.push({
  1672. type: 'digital',
  1673. roleName: '',
  1674. content: '',
  1675. voiceoverUrl: '',
  1676. generatingVoiceover: false
  1677. })
  1678. }
  1679. // 步骤2:添加视频对话
  1680. const addVideoDialogue = (sectionIndex) => {
  1681. scriptData.sections[sectionIndex].dialogues.push({
  1682. type: 'video',
  1683. videoUrl: '',
  1684. videoPrompt: '',
  1685. generatingVideo: false
  1686. })
  1687. }
  1688. // 步骤2:添加用户回复
  1689. const addUserReply = (sectionIndex) => {
  1690. scriptData.sections[sectionIndex].dialogues.push({
  1691. type: 'user',
  1692. content: '',
  1693. roleName: '',
  1694. voiceoverUrl: '',
  1695. generatingVoiceover: false
  1696. })
  1697. }
  1698. // 步骤2:添加提问
  1699. const addQuestDialogue = (sectionIndex) => {
  1700. scriptData.sections[sectionIndex].dialogues.push({
  1701. type: 'quest',
  1702. content: '',
  1703. roleName: '',
  1704. voiceoverUrl: '',
  1705. generatingVoiceover: false,
  1706. questionType: 'AI Q&A',
  1707. options: [{ content: '' }, { content: '' }],
  1708. answer: ''
  1709. })
  1710. }
  1711. // 步骤2:添加诗词
  1712. const addPoemDialogue = (sectionIndex) => {
  1713. scriptData.sections[sectionIndex].dialogues.push({
  1714. type: 'poem',
  1715. content: '',
  1716. roleName: '',
  1717. voiceoverUrl: '',
  1718. generatingVoiceover: false
  1719. })
  1720. }
  1721. // 步骤2:添加朗诵评价
  1722. const addPoemReadingDialogue = (sectionIndex) => {
  1723. scriptData.sections[sectionIndex].dialogues.push({
  1724. type: 'poem_reading',
  1725. content: '',
  1726. roleName: '',
  1727. })
  1728. }
  1729. // 步骤2:添加写诗评价
  1730. const addWriteReadingDialogue = (sectionIndex) => {
  1731. scriptData.sections[sectionIndex].dialogues.push({
  1732. type: 'write_reading',
  1733. content: '',
  1734. roleName: '',
  1735. })
  1736. }
  1737. // 步骤2:添加背诵诗词评价
  1738. const addReciteReadingDialogue = (sectionIndex) => {
  1739. scriptData.sections[sectionIndex].dialogues.push({
  1740. type: 'recite_reading',
  1741. content: '',
  1742. roleName: '',
  1743. })
  1744. }
  1745. // 步骤2:切换更多按钮菜单
  1746. const activeMoreMenu = ref(null)
  1747. const toggleMoreMenu = (sectionIndex) => {
  1748. activeMoreMenu.value = activeMoreMenu.value === sectionIndex ? null : sectionIndex
  1749. }
  1750. // 点击其他区域关闭更多菜单
  1751. const closeMoreMenu = () => {
  1752. activeMoreMenu.value = null
  1753. }
  1754. // 步骤2:添加提问与用户回复
  1755. const addQuestWithUserReply = (sectionIndex) => {
  1756. // 添加提问类型对话
  1757. scriptData.sections[sectionIndex].dialogues.push({
  1758. type: 'quest',
  1759. content: '',
  1760. roleName: '',
  1761. voiceoverUrl: '',
  1762. generatingVoiceover: false,
  1763. questionType: 'AI Q&A',
  1764. options: [{ content: '' }, { content: '' }],
  1765. answer: ''
  1766. })
  1767. // 添加用户回复类型对话
  1768. scriptData.sections[sectionIndex].dialogues.push({
  1769. type: 'user',
  1770. content: '',
  1771. roleName: '',
  1772. voiceoverUrl: '',
  1773. generatingVoiceover: false
  1774. })
  1775. }
  1776. // 步骤2:添加单选题选项
  1777. const addOption = (sectionIndex, dialogueIndex) => {
  1778. const dialogue = scriptData.sections[sectionIndex].dialogues[dialogueIndex]
  1779. if (!dialogue.options) {
  1780. dialogue.options = []
  1781. }
  1782. if (dialogue.options.length < 6) {
  1783. dialogue.options.push({ content: '' })
  1784. }
  1785. }
  1786. // 步骤2:删除单选题选项
  1787. const removeOption = (sectionIndex, dialogueIndex, optionIndex) => {
  1788. const dialogue = scriptData.sections[sectionIndex].dialogues[dialogueIndex]
  1789. if (dialogue.options && dialogue.options.length > 2) {
  1790. dialogue.options.splice(optionIndex, 1)
  1791. // 如果删除的是当前选中的答案,需要重新设置答案
  1792. if (dialogue.answer && dialogue.answer.charCodeAt(0) - 65 >= dialogue.options.length) {
  1793. dialogue.answer = ''
  1794. }
  1795. }
  1796. }
  1797. // 步骤2:删除对话
  1798. const removeDialogue = (sectionIndex, dialogueIndex) => {
  1799. const dialogues = scriptData.sections[sectionIndex].dialogues
  1800. const dialogue = dialogues[dialogueIndex]
  1801. // 如果是提问类型,同时删除后面的用户回复
  1802. if (
  1803. dialogue.type === 'quest' &&
  1804. dialogueIndex < dialogues.length - 1 &&
  1805. dialogues[dialogueIndex + 1].type === 'user'
  1806. ) {
  1807. dialogues.splice(dialogueIndex, 2)
  1808. } else {
  1809. dialogues.splice(dialogueIndex, 1)
  1810. }
  1811. }
  1812. // 步骤2:删除环节
  1813. const removeSection = (sectionIndex) => {
  1814. if (scriptData.sections.length > 1) {
  1815. scriptData.sections.splice(sectionIndex, 1)
  1816. } else {
  1817. alert('至少需要保留一个环节')
  1818. }
  1819. }
  1820. // 图片生成相关状态
  1821. const inProgressImageMap = ref({}) // 监听的图片映射,key 为 image 编号,value 为 { sectionIndex, type: 'image'|'audio' }
  1822. const inProgressTimer = ref(null) // 生成中的图片定时器,轮询生成进展
  1823. // 视频生成相关状态
  1824. const inProgressVideoMap = ref({}) // 监听的视频映射,key 为 video 编号,value 为 { sectionIndex, dialogueIndex, type: 'background'|'dialogue' }
  1825. const inProgressVideoTimer = ref(null) // 生成中的视频定时器,轮询生成进展
  1826. // 步骤2:生成单个媒体(仅背景图)
  1827. const generateMedia = async (sectionIndex) => {
  1828. const section = scriptData.sections[sectionIndex]
  1829. const media = section.backgroundImage
  1830. // 记录旧的URL
  1831. let oldUrl = null
  1832. if (media.url) {
  1833. oldUrl = media.url
  1834. replacedUrls.value.add(oldUrl)
  1835. }
  1836. media.generating = true
  1837. try {
  1838. const form = {
  1839. platform: AiPlatformEnum.DOU_BAO,
  1840. modelId: 56,
  1841. prompt: media.prompt,
  1842. width: 1024,
  1843. height: 768
  1844. }
  1845. const response = await ImageApi.drawImage(form)
  1846. inProgressImageMap.value[response] = {
  1847. sectionIndex
  1848. }
  1849. } catch (error) {
  1850. console.error(`生成图片失败:`, error)
  1851. media.generating = false
  1852. // 生成失败,从replacedUrls中移除旧URL
  1853. if (oldUrl) {
  1854. replacedUrls.value.delete(oldUrl)
  1855. }
  1856. }
  1857. }
  1858. // 步骤2:生成视频背景
  1859. const generateVideo = async (sectionIndex) => {
  1860. const section = scriptData.sections[sectionIndex]
  1861. const media = section.backgroundVideo
  1862. // 记录旧的URL
  1863. let oldUrl = null
  1864. if (media.url) {
  1865. oldUrl = media.url
  1866. replacedUrls.value.add(oldUrl)
  1867. }
  1868. media.generating = true
  1869. try {
  1870. const form = {
  1871. platform: AiPlatformEnum.DOU_BAO,
  1872. modelId: 60,
  1873. prompt: media.prompt,
  1874. width: 1024,
  1875. height: 768,
  1876. resolution: '1080P',
  1877. duration: 4,
  1878. options: {}
  1879. }
  1880. const response = await VideoApi.drawVideo(form)
  1881. inProgressVideoMap.value[response] = {
  1882. sectionIndex,
  1883. type: 'background'
  1884. }
  1885. } catch (error) {
  1886. console.error(`生成视频失败:`, error)
  1887. media.generating = false
  1888. // 生成失败,从replacedUrls中移除旧URL
  1889. if (oldUrl) {
  1890. replacedUrls.value.delete(oldUrl)
  1891. }
  1892. }
  1893. }
  1894. // 步骤2:生成对话视频
  1895. const generateDialogueVideo = async (sectionIndex, dialogueIndex) => {
  1896. const dialogue = scriptData.sections[sectionIndex].dialogues[dialogueIndex]
  1897. // 记录旧的URL
  1898. let oldUrl = null
  1899. if (dialogue.videoUrl) {
  1900. oldUrl = dialogue.videoUrl
  1901. replacedUrls.value.add(oldUrl)
  1902. }
  1903. dialogue.generatingVideo = true
  1904. try {
  1905. const form = {
  1906. platform: AiPlatformEnum.DOU_BAO,
  1907. modelId: 64,
  1908. prompt: dialogue.videoPrompt,
  1909. width: 1024,
  1910. height: 768,
  1911. resolution: '1080P',
  1912. duration: 4,
  1913. options: {}
  1914. }
  1915. const response = await VideoApi.drawVideo(form)
  1916. inProgressVideoMap.value[response] = {
  1917. sectionIndex,
  1918. dialogueIndex,
  1919. type: 'dialogue'
  1920. }
  1921. } catch (error) {
  1922. console.error(`生成对话视频失败:`, error)
  1923. dialogue.generatingVideo = false
  1924. // 生成失败,从replacedUrls中移除旧URL
  1925. if (oldUrl) {
  1926. replacedUrls.value.delete(oldUrl)
  1927. }
  1928. }
  1929. }
  1930. // 步骤2:一键生成所有背景图
  1931. const generateAllImages = async () => {
  1932. isGeneratingImages.value = true
  1933. try {
  1934. for (let i = 0; i < scriptData.sections.length; i++) {
  1935. const section = scriptData.sections[i]
  1936. // 只处理没有背景图URL的环节
  1937. if (!section.backgroundImage.url) {
  1938. await generateMedia(i)
  1939. }
  1940. }
  1941. // 检查是否有图片正在生成
  1942. const checkImagesComplete = setInterval(() => {
  1943. if (Object.keys(inProgressImageMap.value).length === 0) {
  1944. isGeneratingImages.value = false
  1945. clearInterval(checkImagesComplete)
  1946. }
  1947. }, 1000)
  1948. } catch (error) {
  1949. console.error('生成所有背景图失败:', error)
  1950. isGeneratingImages.value = false
  1951. }
  1952. }
  1953. // 步骤2:一键生成所有视频
  1954. const generateAllVideos = async () => {
  1955. isGeneratingVideos.value = true
  1956. try {
  1957. for (let i = 0; i < scriptData.sections.length; i++) {
  1958. const section = scriptData.sections[i]
  1959. // 处理视频背景
  1960. if (section.backgroundType === 'video' && !section.backgroundVideo.url) {
  1961. await generateVideo(i)
  1962. }
  1963. // 处理对话视频
  1964. for (let j = 0; j < section.dialogues.length; j++) {
  1965. const dialogue = section.dialogues[j]
  1966. if (dialogue.type === 'video' && !dialogue.videoUrl) {
  1967. await generateDialogueVideo(i, j)
  1968. }
  1969. }
  1970. }
  1971. // 检查是否有视频正在生成
  1972. const checkVideosComplete = setInterval(() => {
  1973. if (Object.keys(inProgressVideoMap.value).length === 0) {
  1974. isGeneratingVideos.value = false
  1975. clearInterval(checkVideosComplete)
  1976. }
  1977. }, 1000)
  1978. } catch (error) {
  1979. console.error('生成所有视频失败:', error)
  1980. isGeneratingVideos.value = false
  1981. }
  1982. }
  1983. // 轮询生成中的图片列表
  1984. const refreshWatchImages = async () => {
  1985. const imageIds = Object.keys(inProgressImageMap.value).map(Number)
  1986. if (imageIds.length === 0) {
  1987. return
  1988. }
  1989. try {
  1990. const list = await ImageApi.getImageListMyByIds(imageIds)
  1991. const newWatchImages = {}
  1992. list.forEach((image) => {
  1993. const info = inProgressImageMap.value[image.id]
  1994. if (info) {
  1995. if (image.status === AiImageStatusEnum.IN_PROGRESS) {
  1996. newWatchImages[image.id] = info
  1997. } else if (image.status === AiImageStatusEnum.SUCCESS && image.picUrl) {
  1998. const section = scriptData.sections[info.sectionIndex]
  1999. section.backgroundImage.url = image.picUrl
  2000. section.backgroundImage.generating = false
  2001. } else if (image.status === AiImageStatusEnum.FAIL) {
  2002. const section = scriptData.sections[info.sectionIndex]
  2003. section.backgroundImage.generating = false
  2004. // 生成失败,从replacedUrls中移除旧URL
  2005. if (section.backgroundImage.url) {
  2006. replacedUrls.value.delete(section.backgroundImage.url)
  2007. }
  2008. }
  2009. }
  2010. })
  2011. inProgressImageMap.value = newWatchImages
  2012. } catch (error) {
  2013. console.error('轮询图片状态失败:', error)
  2014. }
  2015. }
  2016. // 轮询生成中的视频列表
  2017. const refreshWatchVideos = async () => {
  2018. const videoIds = Object.keys(inProgressVideoMap.value).map(Number)
  2019. if (videoIds.length === 0) {
  2020. return
  2021. }
  2022. try {
  2023. const list = await VideoApi.getVideoListMyByIds(videoIds)
  2024. const newWatchVideos = {}
  2025. list.forEach((video) => {
  2026. const info = inProgressVideoMap.value[video.id]
  2027. if (info) {
  2028. if (video.status === AiVideoStatusEnum.IN_PROGRESS) {
  2029. newWatchVideos[video.id] = info
  2030. } else if (video.status === AiVideoStatusEnum.SUCCESS && video.videoUrl) {
  2031. if (info.type === 'background') {
  2032. const section = scriptData.sections[info.sectionIndex]
  2033. section.backgroundVideo.url = video.videoUrl
  2034. section.backgroundVideo.generating = false
  2035. } else if (info.type === 'dialogue') {
  2036. const dialogue = scriptData.sections[info.sectionIndex].dialogues[info.dialogueIndex]
  2037. dialogue.videoUrl = video.videoUrl
  2038. dialogue.generatingVideo = false
  2039. }
  2040. } else if (video.status === AiVideoStatusEnum.FAIL) {
  2041. if (info.type === 'background') {
  2042. const section = scriptData.sections[info.sectionIndex]
  2043. section.backgroundVideo.generating = false
  2044. // 生成失败,从replacedUrls中移除旧URL
  2045. if (section.backgroundVideo.url) {
  2046. replacedUrls.value.delete(section.backgroundVideo.url)
  2047. }
  2048. } else if (info.type === 'dialogue') {
  2049. const dialogue = scriptData.sections[info.sectionIndex].dialogues[info.dialogueIndex]
  2050. dialogue.generatingVideo = false
  2051. // 生成失败,从replacedUrls中移除旧URL
  2052. if (dialogue.videoUrl) {
  2053. replacedUrls.value.delete(dialogue.videoUrl)
  2054. }
  2055. }
  2056. }
  2057. }
  2058. })
  2059. inProgressVideoMap.value = newWatchVideos
  2060. } catch (error) {
  2061. console.error('轮询视频状态失败:', error)
  2062. }
  2063. }
  2064. // 播放音频通用函数
  2065. const playAudio = (url, type) => {
  2066. if (audioState.currentAudio) {
  2067. audioState.currentAudio.pause()
  2068. audioState.currentAudio.currentTime = 0
  2069. }
  2070. if (audioState.isPlaying && audioState.currentUrl === url && audioState.currentType === type) {
  2071. if (audioState.currentAudio) {
  2072. audioState.currentAudio.pause()
  2073. }
  2074. audioState.isPlaying = false
  2075. return
  2076. }
  2077. let audio = audioInstances.get(`${type}_${url}`)
  2078. if (!audio) {
  2079. audio = new Audio(url)
  2080. audio.autoplay = false
  2081. audioInstances.set(`${type}_${url}`, audio)
  2082. audio.onended = () => {
  2083. audioState.isPlaying = false
  2084. audioState.currentAudio = null
  2085. audioState.currentUrl = ''
  2086. audioState.currentType = ''
  2087. }
  2088. }
  2089. audio.play().catch((error) => {
  2090. console.error('播放失败:', error)
  2091. audioState.isPlaying = false
  2092. })
  2093. audioState.currentAudio = audio
  2094. audioState.isPlaying = true
  2095. audioState.currentUrl = url
  2096. audioState.currentType = type
  2097. }
  2098. // 播放语音
  2099. const playVoiceover = (voiceoverUrl) => {
  2100. playAudio(voiceoverUrl, 'voice')
  2101. }
  2102. // 处理背景音选择变化
  2103. const handleBackgroundAudioChange = (value, section) => {
  2104. if (value) {
  2105. const selectedMusic = backgroundMusicTypes.value.find((music) => music.id === value)
  2106. if (selectedMusic) {
  2107. section.backgroundAudio.url = selectedMusic.url
  2108. }
  2109. } else {
  2110. section.backgroundAudio.url = ''
  2111. }
  2112. }
  2113. // 播放背景音
  2114. const playBackgroundAudio = (musicType) => {
  2115. const selectedMusic = backgroundMusicTypes.value.find((music) => music.id === musicType)
  2116. const audioUrl = selectedMusic ? selectedMusic.url : `https://example.com/${musicType}.mp3`
  2117. playAudio(audioUrl, 'background')
  2118. }
  2119. // 生成单个语音
  2120. const generateVoiceover = async (sectionIndex, dialogueIndex) => {
  2121. const dialogue = scriptData.sections[sectionIndex].dialogues[dialogueIndex]
  2122. // 只处理数字人、提问和诗词类型的对话
  2123. if (dialogue.type !== 'digital' && dialogue.type !== 'quest' && dialogue.type !== 'poem') {
  2124. return
  2125. }
  2126. // 记录旧的URL
  2127. let oldUrl = null
  2128. if (dialogue.voiceoverUrl) {
  2129. oldUrl = dialogue.voiceoverUrl
  2130. replacedUrls.value.add(oldUrl)
  2131. }
  2132. dialogue.generatingVoiceover = true
  2133. let role = digitalHumans.value.find((r) => r.name === dialogue.roleName)
  2134. try {
  2135. // 根据对话类型设置不同的command
  2136. const command =
  2137. dialogue.type === 'poem' ? '要有感情的朗读诗词语句,要符合诗词的节奏和韵律。' : null
  2138. // 调用后端API将文本转成语音
  2139. // 将返回的URL赋值给对话
  2140. dialogue.voiceoverUrl = await TtsApi.convert({
  2141. roleId: Number(role.id),
  2142. content: dialogue.content,
  2143. command: command
  2144. })
  2145. } catch (error) {
  2146. console.error('生成语音失败:', error)
  2147. // 生成失败,从replacedUrls中移除旧URL
  2148. if (oldUrl) {
  2149. replacedUrls.value.delete(oldUrl)
  2150. }
  2151. } finally {
  2152. dialogue.generatingVoiceover = false
  2153. }
  2154. }
  2155. // 步骤3:一键生成所有语音
  2156. const generateAllVoiceovers = async () => {
  2157. isGeneratingVoiceovers.value = true
  2158. try {
  2159. for (let i = 0; i < scriptData.sections.length; i++) {
  2160. for (let j = 0; j < scriptData.sections[i].dialogues.length; j++) {
  2161. const dialogue = scriptData.sections[i].dialogues[j]
  2162. // 只处理没有语音URL的对话
  2163. if (!dialogue.voiceoverUrl) {
  2164. await generateVoiceover(i, j)
  2165. }
  2166. }
  2167. }
  2168. } catch (error) {
  2169. console.error('生成所有语音失败:', error)
  2170. } finally {
  2171. isGeneratingVoiceovers.value = false
  2172. }
  2173. }
  2174. // 获取角色名称
  2175. const getRoleName = (roleName) => {
  2176. const role = digitalHumans.value.find((r) => r.name === roleName)
  2177. return role ? role.name : '未知角色'
  2178. }
  2179. // 解析 Markdown 文本
  2180. const parseMarkdown = (text) => {
  2181. if (!text) return ''
  2182. return marked(text)
  2183. }
  2184. // 步骤4:校验脚本
  2185. const validateScript = () => {
  2186. let isValid = true
  2187. errorMessages.value = []
  2188. // 检查环节名称、背景图或视频
  2189. scriptData.sections.forEach((section, sectionIndex) => {
  2190. if (!section.name.trim()) {
  2191. errorMessages.value.push(`环节${sectionIndex + 1}:名称未配置!`)
  2192. isValid = false
  2193. }
  2194. // 根据背景类型检查对应的媒体URL
  2195. if (section.backgroundType === 'video') {
  2196. // 视频背景需要检查视频URL
  2197. if (!section.backgroundVideo.url) {
  2198. errorMessages.value.push(`环节${sectionIndex + 1}:视频背景URL未配置!`)
  2199. isValid = false
  2200. }
  2201. } else if (section.backgroundType === 'imageAudio') {
  2202. // 图音背景需要检查背景图URL
  2203. if (!section.backgroundImage.url) {
  2204. errorMessages.value.push(`环节${sectionIndex + 1}:背景图URL未配置!`)
  2205. isValid = false
  2206. }
  2207. }
  2208. // 检查对话
  2209. section.dialogues.forEach((dialogue, dialogueIndex) => {
  2210. // 检查数字人、提问、诗词、朗诵评价、写诗评价、背诵诗词评价类型的对话
  2211. if (dialogue.type === 'digital' || dialogue.type === 'quest' || dialogue.type === 'poem' || dialogue.type === 'poem_reading' || dialogue.type === 'write_reading' || dialogue.type === 'recite_reading') {
  2212. if (
  2213. !dialogue.roleName ||
  2214. !dialogue.content.trim() ||
  2215. (dialogue.type !== 'poem' && dialogue.type !== 'poem_reading' && dialogue.type !== 'write_reading' && dialogue.type !== 'recite_reading' && !dialogue.voiceoverUrl)
  2216. ) {
  2217. errorMessages.value.push(
  2218. `环节${sectionIndex + 1}:对话${dialogueIndex + 1}:存在完成内容!`
  2219. )
  2220. isValid = false
  2221. }
  2222. } else if (dialogue.type === 'video') {
  2223. // 检查视频类型的对话
  2224. if (
  2225. !dialogue.videoUrl
  2226. ) {
  2227. errorMessages.value.push(
  2228. `环节${sectionIndex + 1}:对话${dialogueIndex + 1}:视频内容未配置完整!`
  2229. )
  2230. isValid = false
  2231. }
  2232. }
  2233. })
  2234. })
  2235. isValidationPassed.value = isValid
  2236. validationMessage.value = errorMessages.value.length > 0 ? '校验失败' : '校验通过'
  2237. }
  2238. // 图片上传前验证
  2239. const beforeImageUpload = (file) => {
  2240. const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/webp'
  2241. const isLt2M = file.size / 1024 / 1024 < 2
  2242. if (!isJPG) {
  2243. ElMessage.error('只能上传 JPG、PNG、GIF、WebP 格式的图片!')
  2244. return false
  2245. }
  2246. if (!isLt2M) {
  2247. ElMessage.error('图片大小不能超过 2MB!')
  2248. return false
  2249. }
  2250. return true
  2251. }
  2252. // 处理图片上传成功
  2253. const handleImageUpload = (response, file, sectionIndex) => {
  2254. // 这里假设上传成功后返回的response包含图片的URL
  2255. // 实际项目中需要根据后端API的返回格式进行调整
  2256. const imageUrl = response.url || URL.createObjectURL(file)
  2257. scriptData.sections[sectionIndex].backgroundImage.url = imageUrl
  2258. scriptData.sections[sectionIndex].backgroundImage.generating = false
  2259. ElMessage.success('图片上传成功!')
  2260. }
  2261. // 编辑图片
  2262. const editImage = (sectionIndex) => {
  2263. // 这里可以添加编辑图片的逻辑,比如打开图片编辑器
  2264. ElMessage.info('编辑图片功能待实现')
  2265. }
  2266. // 删除图片
  2267. const deleteImage = (sectionIndex) => {
  2268. scriptData.sections[sectionIndex].backgroundImage.url = ''
  2269. ElMessage.success('图片删除成功!')
  2270. }
  2271. // 步骤4:保存脚本
  2272. const saveScript = async () => {
  2273. validateScript()
  2274. if (!isValidationPassed.value) {
  2275. return
  2276. }
  2277. // 保存脚本后清除缓存
  2278. clearScriptDataCache()
  2279. emit('save', scriptData, [...replacedUrls.value])
  2280. emit('update:visible', false)
  2281. }
  2282. // 下一步操作
  2283. const nextStep = () => {
  2284. if (currentStep.value === 2) {
  2285. validateScript()
  2286. }
  2287. currentStep.value++
  2288. }
  2289. // 显示视频预览
  2290. const showVideoPreview = () => {
  2291. showVideoPreviewModal.value = true
  2292. }
  2293. // 关闭视频预览
  2294. const closeVideoPreview = () => {
  2295. showVideoPreviewModal.value = false
  2296. }
  2297. // 组件挂载时
  2298. onMounted(async () => {
  2299. // 设置初始步骤
  2300. currentStep.value = props.initialStep
  2301. // 监听文档点击关闭更多菜单
  2302. document.addEventListener('click', closeMoreMenu)
  2303. try {
  2304. const params = {
  2305. pageOn: 1,
  2306. pageSize: 100,
  2307. category: '小学低年级',
  2308. publicStatus: true
  2309. }
  2310. const { list } = await ChatRoleApi.getMyPage(params)
  2311. params.category += 'AI'
  2312. const { list: listAi } = await ChatRoleApi.getMyPage(params)
  2313. params.category = '全部'
  2314. const { list: listAll } = await ChatRoleApi.getMyPage(params)
  2315. params.category = '全部-Poet'
  2316. const { list: listAllPoet } = await ChatRoleApi.getMyPage(params)
  2317. listAi.push(...list)
  2318. listAi.push(...listAll)
  2319. listAi.push(...listAllPoet)
  2320. digitalHumans.value = listAi
  2321. } catch (error) {
  2322. console.error('获取角色数据失败:', error)
  2323. }
  2324. inProgressTimer.value = setInterval(async () => {
  2325. await refreshWatchImages()
  2326. }, 3000)
  2327. inProgressVideoTimer.value = setInterval(async () => {
  2328. await refreshWatchVideos()
  2329. }, 3000)
  2330. })
  2331. // 关闭事件
  2332. const emit = defineEmits(['update:visible', 'save'])
  2333. const handleClose = () => {
  2334. emit('update:visible', false)
  2335. }
  2336. // 组件卸载时
  2337. onUnmounted(() => {
  2338. if (inProgressTimer.value) {
  2339. clearInterval(inProgressTimer.value)
  2340. }
  2341. if (inProgressVideoTimer.value) {
  2342. clearInterval(inProgressVideoTimer.value)
  2343. }
  2344. document.removeEventListener('click', closeMoreMenu)
  2345. })
  2346. </script>
  2347. <style scoped>
  2348. .course-script-editor {
  2349. width: 100%;
  2350. height: 90vh;
  2351. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  2352. display: flex;
  2353. flex-direction: column;
  2354. overflow: hidden;
  2355. background-color: #f8f9fa;
  2356. }
  2357. /* 主容器样式 */
  2358. .main-container {
  2359. flex: 1;
  2360. display: flex;
  2361. overflow: hidden;
  2362. }
  2363. /* 左侧步骤指示器样式 */
  2364. .steps-sidebar {
  2365. width: 200px;
  2366. background-color: #f5f7fa;
  2367. border-right: 1px solid #ebeef5;
  2368. padding: 30px 0;
  2369. display: flex;
  2370. align-items: center;
  2371. }
  2372. /* 右侧内容区域样式 */
  2373. .content-area {
  2374. flex: 1;
  2375. display: flex;
  2376. flex-direction: column;
  2377. overflow: hidden;
  2378. }
  2379. /* 步骤内容样式 */
  2380. .step-content {
  2381. flex: 1;
  2382. padding: 20px;
  2383. overflow: hidden;
  2384. display: flex;
  2385. flex-direction: column;
  2386. background-color: white;
  2387. border-radius: 0;
  2388. box-shadow: none;
  2389. }
  2390. /* 步骤1垂直居中 */
  2391. .step-content:has(.ai-input-container) {
  2392. justify-content: center;
  2393. align-items: center;
  2394. }
  2395. /* 编辑器工具栏样式 - 固定顶部 */
  2396. .editor-toolbar.sticky-top {
  2397. position: sticky;
  2398. top: 0;
  2399. z-index: 100;
  2400. margin-top: -20px;
  2401. margin-left: -20px;
  2402. margin-right: -20px;
  2403. border-radius: 0;
  2404. border-bottom: 1px solid #ebeef5;
  2405. background: rgba(250, 250, 250, 0.95);
  2406. backdrop-filter: blur(10px);
  2407. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  2408. }
  2409. /* 脚本编辑器样式 - 可滚动 */
  2410. .script-editor {
  2411. flex: 1;
  2412. overflow-y: auto;
  2413. margin-top: 20px;
  2414. padding-right: 10px;
  2415. background-color: white;
  2416. border-radius: 8px;
  2417. padding: 20px;
  2418. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  2419. }
  2420. .script-editor::-webkit-scrollbar {
  2421. width: 6px;
  2422. }
  2423. .script-editor::-webkit-scrollbar-track {
  2424. background: #f1f1f1;
  2425. border-radius: 3px;
  2426. }
  2427. .script-editor::-webkit-scrollbar-thumb {
  2428. background: #c1c1c1;
  2429. border-radius: 3px;
  2430. }
  2431. /* 背景类型切换样式 */
  2432. .background-type-switch {
  2433. position: absolute;
  2434. top: -15px;
  2435. left: 10px;
  2436. z-index: 10;
  2437. }
  2438. /* 媒体控制区域样式调整 */
  2439. .media-controls {
  2440. position: relative;
  2441. margin-top: 30px;
  2442. padding-top: 40px; /* 为背景类型切换留出空间 */
  2443. height: 165px;
  2444. }
  2445. /* 视频预览样式 */
  2446. .media-preview video {
  2447. width: 100%;
  2448. max-height: 300px;
  2449. object-fit: cover;
  2450. border-radius: 4px;
  2451. }
  2452. /* 预览视频背景样式 */
  2453. .preview-section {
  2454. position: relative;
  2455. min-height: 400px;
  2456. margin-bottom: 20px;
  2457. border-radius: 8px;
  2458. overflow: hidden;
  2459. }
  2460. .preview-video {
  2461. position: absolute;
  2462. top: 0;
  2463. left: 0;
  2464. width: 100%;
  2465. height: 100%;
  2466. z-index: 0;
  2467. }
  2468. .preview-video video {
  2469. width: 100%;
  2470. height: 100%;
  2471. object-fit: cover;
  2472. }
  2473. .preview-section-content {
  2474. position: relative;
  2475. z-index: 1;
  2476. padding: 20px;
  2477. background: rgba(255, 255, 255, 0.8);
  2478. height: 100%;
  2479. display: flex;
  2480. flex-direction: column;
  2481. }
  2482. .script-editor::-webkit-scrollbar-thumb:hover {
  2483. background: #a1a1a1;
  2484. }
  2485. /* 步骤导航 */
  2486. .steps-container {
  2487. display: flex;
  2488. flex-direction: column;
  2489. align-items: center;
  2490. gap: 20px;
  2491. width: 100%;
  2492. .step-item {
  2493. display: flex;
  2494. flex-direction: column;
  2495. align-items: center;
  2496. width: 100%;
  2497. .step-circle {
  2498. width: 32px;
  2499. height: 32px;
  2500. border-radius: 50%;
  2501. display: flex;
  2502. align-items: center;
  2503. justify-content: center;
  2504. font-weight: bold;
  2505. margin-bottom: 8px;
  2506. }
  2507. .step-title {
  2508. font-size: 14px;
  2509. text-align: center;
  2510. padding: 0 20px;
  2511. }
  2512. &.process {
  2513. .step-circle {
  2514. background-color: #409eff;
  2515. color: white;
  2516. }
  2517. .step-title {
  2518. color: #409eff;
  2519. }
  2520. }
  2521. &.wait {
  2522. .step-circle {
  2523. background-color: #e4e7ed;
  2524. color: #c0c4cc;
  2525. }
  2526. .step-title {
  2527. color: #c0c4cc;
  2528. }
  2529. }
  2530. &.finish {
  2531. .step-circle {
  2532. background-color: #67c23a;
  2533. color: white;
  2534. }
  2535. .step-title {
  2536. color: #67c23a;
  2537. }
  2538. }
  2539. }
  2540. .step-line {
  2541. width: 2px;
  2542. height: 40px;
  2543. background-color: #e4e7ed;
  2544. &.active {
  2545. background-color: #409eff;
  2546. }
  2547. }
  2548. }
  2549. /* 步骤内容 */
  2550. .step-content {
  2551. background-color: white;
  2552. border-radius: 8px;
  2553. padding: 20px;
  2554. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  2555. }
  2556. /* 按钮组样式 */
  2557. .button-group {
  2558. display: flex;
  2559. gap: 10px;
  2560. margin-top: 20px;
  2561. justify-content: center;
  2562. }
  2563. /* 次要按钮样式 */
  2564. .generate-btn.secondary {
  2565. background-color: #606266;
  2566. color: white;
  2567. }
  2568. .generate-btn.secondary:hover {
  2569. background-color: #ffaa72;
  2570. color: white;
  2571. }
  2572. /* 对话类型标签 */
  2573. .dialogue-type-tag {
  2574. position: absolute;
  2575. top: -10px;
  2576. left: 10px;
  2577. padding: 2px 8px;
  2578. border-radius: 10px;
  2579. font-size: 12px;
  2580. font-weight: 500;
  2581. color: white;
  2582. }
  2583. /* 隐藏用户回复卡片 */
  2584. .dialogue-item.hidden {
  2585. display: none;
  2586. }
  2587. /* 错误信息项样式 */
  2588. .error-item {
  2589. margin-bottom: 8px;
  2590. line-height: 1.4;
  2591. }
  2592. .dialogue-type-tag.digital {
  2593. background-color: #409eff;
  2594. }
  2595. .dialogue-type-tag.user {
  2596. background-color: #67c23a;
  2597. }
  2598. .dialogue-type-tag.quest {
  2599. background-color: #e6a23c;
  2600. }
  2601. .dialogue-type-tag.poem {
  2602. background-color: #909399;
  2603. }
  2604. .dialogue-type-tag.poem_reading {
  2605. background-color: #7d60a4;
  2606. }
  2607. .dialogue-type-tag.write_reading {
  2608. background-color: #c23a70;
  2609. }
  2610. .dialogue-type-tag.recite_reading {
  2611. background-color: #2aa898;
  2612. }
  2613. .dialogue-type-tag.video {
  2614. background-color: #8b4513;
  2615. }
  2616. /* 对话项样式 */
  2617. .dialogue-item {
  2618. position: relative;
  2619. background-color: #f9f9f9;
  2620. border-radius: 8px;
  2621. padding: 20px;
  2622. margin-bottom: 15px;
  2623. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  2624. transition: all 0.3s ease;
  2625. }
  2626. .dialogue-item:hover {
  2627. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  2628. }
  2629. .dialogue-item.digital {
  2630. border-left: 4px solid #409eff;
  2631. }
  2632. .dialogue-item.user {
  2633. border-left: 4px solid #67c23a;
  2634. }
  2635. .dialogue-item.quest {
  2636. border-left: 4px solid #e6a23c;
  2637. }
  2638. .dialogue-item.video {
  2639. border-left: 4px solid #8b4513;
  2640. }
  2641. .dialogue-item.poem_reading {
  2642. border-left: 4px solid #7d60a4;
  2643. }
  2644. .dialogue-item.write_reading {
  2645. border-left: 4px solid #c23a70;
  2646. }
  2647. .dialogue-item.recite_reading {
  2648. border-left: 4px solid #2aa898;
  2649. }
  2650. /* 对话头部 */
  2651. .dialogue-header {
  2652. margin-bottom: 10px;
  2653. }
  2654. /* 对话行 */
  2655. .dialogue-row {
  2656. display: flex;
  2657. gap: 15px;
  2658. align-items: flex-start;
  2659. }
  2660. /* 角色选择 */
  2661. .dialogue-role-select {
  2662. flex-shrink: 0;
  2663. }
  2664. /* 回复角色选择 */
  2665. .dialogue-reply-select {
  2666. flex-shrink: 0;
  2667. }
  2668. /* 内容容器 */
  2669. .dialogue-content-container {
  2670. flex: 1;
  2671. min-width: 0;
  2672. }
  2673. /* 添加对话按钮容器 */
  2674. .add-dialogue-buttons {
  2675. display: flex;
  2676. gap: 10px;
  2677. margin-top: 15px;
  2678. }
  2679. /* 添加对话按钮 */
  2680. .add-dialogue-btn {
  2681. padding: 8px 16px;
  2682. border: none;
  2683. border-radius: 4px;
  2684. font-size: 14px;
  2685. font-weight: 500;
  2686. cursor: pointer;
  2687. transition: all 0.3s ease;
  2688. display: flex;
  2689. align-items: center;
  2690. justify-content: center;
  2691. gap: 5px;
  2692. min-width: 120px;
  2693. }
  2694. .add-dialogue-btn.digital {
  2695. background-color: #83c2ff;
  2696. color: white;
  2697. }
  2698. .add-dialogue-btn.digital:hover {
  2699. background-color: #409eff;
  2700. border-color: #4aa2fd;
  2701. color: white;
  2702. }
  2703. .add-dialogue-btn.user {
  2704. background-color: #85ce61;
  2705. color: white;
  2706. }
  2707. .add-dialogue-btn.quest {
  2708. background-color: #e6a23c;
  2709. color: white;
  2710. }
  2711. .add-dialogue-btn.poem {
  2712. background-color: #909399;
  2713. color: white;
  2714. }
  2715. .add-dialogue-btn.poem_reading {
  2716. background-color: #7d60a4;
  2717. color: white;
  2718. }
  2719. .add-dialogue-btn.write_reading {
  2720. background-color: #c23a70;
  2721. color: white;
  2722. }
  2723. .add-dialogue-btn.recite_reading {
  2724. background-color: #2aa898;
  2725. color: white;
  2726. }
  2727. .add-dialogue-btn.quest-user {
  2728. background-color: #e6a23c;
  2729. color: white;
  2730. }
  2731. .add-dialogue-btn.more-btn {
  2732. background-color: #4a5568;
  2733. color: white;
  2734. }
  2735. .add-dialogue-btn.user:hover {
  2736. background-color: #67c23a;
  2737. border-color: #67c23a;
  2738. color: white;
  2739. }
  2740. .add-dialogue-btn.quest:hover {
  2741. background-color: #cf9236;
  2742. border-color: #cf9236;
  2743. color: white;
  2744. }
  2745. .add-dialogue-btn.quest-user:hover {
  2746. background-color: #cf9236;
  2747. border-color: #cf9236;
  2748. color: white;
  2749. }
  2750. .add-dialogue-btn.poem:hover {
  2751. background-color: #73767a;
  2752. border-color: #73767a;
  2753. }
  2754. .add-dialogue-btn.poem_reading:hover {
  2755. background-color: #624a83;
  2756. border-color: #624a83;
  2757. color: white;
  2758. }
  2759. .add-dialogue-btn.write_reading:hover {
  2760. background-color: #9e2a56;
  2761. border-color: #9e2a56;
  2762. color: white;
  2763. }
  2764. .add-dialogue-btn.recite_reading:hover {
  2765. background-color: #208174;
  2766. border-color: #208174;
  2767. color: white;
  2768. }
  2769. .add-dialogue-btn.more-btn:hover {
  2770. background-color: #2d3748;
  2771. border-color: #2d3748;
  2772. color: white;
  2773. }
  2774. /* 更多下拉菜单容器 */
  2775. .more-dropdown-wrapper {
  2776. position: relative;
  2777. display: inline-block;
  2778. }
  2779. /* 更多下拉菜单 */
  2780. .more-dropdown-menu {
  2781. position: absolute;
  2782. top: 100%;
  2783. right: 0;
  2784. margin-top: 5px;
  2785. background-color: white;
  2786. border: 1px solid #d9d9d9;
  2787. border-radius: 6px;
  2788. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  2789. padding: 6px;
  2790. display: flex;
  2791. flex-direction: column;
  2792. gap: 6px;
  2793. min-width: 170px;
  2794. z-index: 100;
  2795. }
  2796. /* 下拉菜单中按钮 */
  2797. .more-item-btn {
  2798. padding: 8px 12px;
  2799. border: none;
  2800. border-radius: 4px;
  2801. font-size: 14px;
  2802. font-weight: 500;
  2803. cursor: pointer;
  2804. transition: all 0.3s ease;
  2805. display: flex;
  2806. align-items: center;
  2807. justify-content: flex-start;
  2808. gap: 5px;
  2809. text-align: left;
  2810. width: 100%;
  2811. color: white;
  2812. }
  2813. .more-item-btn.poem {
  2814. background-color: #909399;
  2815. }
  2816. .more-item-btn.poem:hover {
  2817. background-color: #73767a;
  2818. }
  2819. .more-item-btn.poem_reading {
  2820. background-color: #7d60a4;
  2821. }
  2822. .more-item-btn.poem_reading:hover {
  2823. background-color: #624a83;
  2824. }
  2825. .more-item-btn.write_reading {
  2826. background-color: #c23a70;
  2827. }
  2828. .more-item-btn.write_reading:hover {
  2829. background-color: #9e2a56;
  2830. }
  2831. .more-item-btn.recite_reading {
  2832. background-color: #2aa898;
  2833. }
  2834. .more-item-btn.recite_reading:hover {
  2835. background-color: #208174;
  2836. }
  2837. /* 上传相关样式 */
  2838. .upload-container {
  2839. margin-top: 10px;
  2840. display: inline-block;
  2841. }
  2842. .media-upload-placeholder {
  2843. display: flex;
  2844. flex-direction: column;
  2845. align-items: center;
  2846. justify-content: center;
  2847. padding: 40px 20px;
  2848. border: 2px dashed #d9d9d9;
  2849. border-radius: 8px;
  2850. margin-top: 10px;
  2851. background-color: #fafafa;
  2852. }
  2853. .upload-icon {
  2854. font-size: 48px;
  2855. margin-bottom: 16px;
  2856. }
  2857. .upload-text {
  2858. margin-bottom: 16px;
  2859. color: #999;
  2860. }
  2861. .upload-btn {
  2862. margin-left: 10px;
  2863. }
  2864. .upload-btn-full {
  2865. width: 100%;
  2866. }
  2867. .media-preview {
  2868. position: relative;
  2869. margin-top: 10px;
  2870. border-radius: 8px;
  2871. overflow: hidden;
  2872. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  2873. }
  2874. .media-preview img,
  2875. .media-preview video {
  2876. width: 100%;
  2877. max-height: 300px;
  2878. object-fit: cover;
  2879. }
  2880. .media-preview .preview-actions {
  2881. position: absolute;
  2882. bottom: 0;
  2883. left: 0;
  2884. right: 0;
  2885. background: rgba(0, 0, 0, 0.6);
  2886. padding: 10px;
  2887. display: flex;
  2888. justify-content: flex-end;
  2889. margin-top: 0;
  2890. }
  2891. .media-preview .preview-actions button {
  2892. color: white;
  2893. margin-left: 10px;
  2894. }
  2895. .media-preview .preview-actions button:hover {
  2896. color: #409eff;
  2897. }
  2898. .add-dialogue-btn.video {
  2899. background-color: #8b4513;
  2900. color: white;
  2901. }
  2902. .add-dialogue-btn.video:hover {
  2903. background-color: #a0522d;
  2904. border-color: #a0522d;
  2905. color: white;
  2906. }
  2907. /* 预览对话样式 */
  2908. .preview-dialogue {
  2909. position: relative;
  2910. margin-bottom: 20px;
  2911. padding: 15px;
  2912. border-radius: 8px;
  2913. background-color: #f9f9f9;
  2914. }
  2915. .preview-dialogue.digital {
  2916. border-left: 4px solid #409eff;
  2917. }
  2918. .preview-dialogue.user {
  2919. border-left: 4px solid #67c23a;
  2920. }
  2921. .preview-dialogue.quest {
  2922. border-left: 4px solid #e6a23c;
  2923. }
  2924. .preview-dialogue.poem {
  2925. border-left: 4px solid #909399;
  2926. }
  2927. .preview-dialogue.video {
  2928. border-left: 4px solid #8b4513;
  2929. }
  2930. .preview-dialogue .dialogue-header {
  2931. display: flex;
  2932. align-items: center;
  2933. justify-content: space-between;
  2934. gap: 0;
  2935. margin-bottom: 10px;
  2936. }
  2937. .preview-dialogue .dialogue-header-left {
  2938. display: flex;
  2939. align-items: center;
  2940. gap: 2px;
  2941. }
  2942. .preview-dialogue .dialogue-type-tag {
  2943. position: static;
  2944. margin-right: 2px;
  2945. }
  2946. /* 回复信息 */
  2947. .reply-info {
  2948. margin-top: 10px;
  2949. padding-top: 10px;
  2950. border-top: 1px solid #e8e8e8;
  2951. font-size: 14px;
  2952. color: #666;
  2953. font-style: italic;
  2954. }
  2955. /* AI输入容器 */
  2956. .ai-input-container {
  2957. max-width: 800px;
  2958. margin: 0 auto;
  2959. padding: 30px;
  2960. background: white;
  2961. border-radius: 16px;
  2962. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  2963. display: flex;
  2964. flex-direction: column;
  2965. min-height: 500px;
  2966. }
  2967. .selection-group {
  2968. margin-bottom: 30px;
  2969. }
  2970. .ai-input-wrapper {
  2971. margin-bottom: 30px;
  2972. }
  2973. .ai-input-container .button-group {
  2974. display: flex;
  2975. gap: 10px;
  2976. margin-top: 30px;
  2977. justify-content: center;
  2978. }
  2979. .ai-input-container .button-group button {
  2980. flex: 1;
  2981. min-width: 200px;
  2982. text-align: center;
  2983. }
  2984. .ai-input-wrapper {
  2985. position: relative;
  2986. margin-bottom: 30px;
  2987. }
  2988. .ai-icon {
  2989. position: absolute;
  2990. top: 20px;
  2991. left: 20px;
  2992. font-size: 28px;
  2993. color: #409eff;
  2994. background: rgba(64, 158, 255, 0.1);
  2995. width: 48px;
  2996. height: 48px;
  2997. border-radius: 12px;
  2998. display: flex;
  2999. align-items: center;
  3000. justify-content: center;
  3001. animation: pulse 2s infinite;
  3002. }
  3003. @keyframes pulse {
  3004. 0% {
  3005. box-shadow: 0 0 0 0 rgba(64, 158, 255, 0.4);
  3006. }
  3007. 70% {
  3008. box-shadow: 0 0 0 10px rgba(64, 158, 255, 0);
  3009. }
  3010. 100% {
  3011. box-shadow: 0 0 0 0 rgba(64, 158, 255, 0);
  3012. }
  3013. }
  3014. .ai-textarea {
  3015. width: 100%;
  3016. min-height: 140px;
  3017. padding: 24px 24px 24px 84px;
  3018. border: 2px solid #e8e8e8;
  3019. border-radius: 16px;
  3020. font-size: 16px;
  3021. resize: vertical;
  3022. transition: all 0.3s ease;
  3023. background: #fafafa;
  3024. line-height: 1.6;
  3025. }
  3026. .ai-textarea:focus {
  3027. outline: none;
  3028. border-color: #409eff;
  3029. background: white;
  3030. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3031. }
  3032. .selection-group {
  3033. display: grid;
  3034. grid-template-columns: 1fr 1fr;
  3035. gap: 24px;
  3036. margin-bottom: 30px;
  3037. }
  3038. .selection-item {
  3039. display: flex;
  3040. flex-direction: column;
  3041. gap: 10px;
  3042. }
  3043. .selection-item label {
  3044. font-weight: 600;
  3045. color: #333;
  3046. font-size: 14px;
  3047. text-transform: uppercase;
  3048. letter-spacing: 0.5px;
  3049. color: #666;
  3050. }
  3051. .selection-item select {
  3052. padding: 14px 16px;
  3053. border: 2px solid #e8e8e8;
  3054. border-radius: 10px;
  3055. font-size: 14px;
  3056. transition: all 0.3s ease;
  3057. background: white;
  3058. }
  3059. .selection-item select:focus {
  3060. outline: none;
  3061. border-color: #409eff;
  3062. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3063. }
  3064. .multi-select {
  3065. display: flex;
  3066. flex-wrap: wrap;
  3067. gap: 10px;
  3068. padding: 12px;
  3069. border: 2px solid #e8e8e8;
  3070. border-radius: 10px;
  3071. background: white;
  3072. transition: all 0.3s ease;
  3073. }
  3074. .multi-select:focus-within {
  3075. border-color: #409eff;
  3076. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3077. }
  3078. .select-option {
  3079. padding: 8px 16px;
  3080. background: #f5f5f5;
  3081. border-radius: 20px;
  3082. cursor: pointer;
  3083. transition: all 0.2s ease;
  3084. font-size: 14px;
  3085. font-weight: 500;
  3086. border: 1px solid transparent;
  3087. }
  3088. .select-option:hover {
  3089. background: #e6f7ff;
  3090. border-color: #91d5ff;
  3091. }
  3092. .select-option.selected {
  3093. background: #409eff;
  3094. color: white;
  3095. border-color: #409eff;
  3096. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
  3097. }
  3098. /* 加载遮挡层样式 */
  3099. .loading-overlay {
  3100. position: fixed;
  3101. top: 0;
  3102. left: 0;
  3103. width: 100%;
  3104. height: 100%;
  3105. background-color: rgba(0, 0, 0, 0.1);
  3106. display: flex;
  3107. align-items: center;
  3108. justify-content: center;
  3109. z-index: 9999;
  3110. pointer-events: auto;
  3111. }
  3112. .loading-content {
  3113. display: flex;
  3114. flex-direction: column;
  3115. align-items: center;
  3116. gap: 16px;
  3117. background: white;
  3118. padding: 32px;
  3119. border-radius: 12px;
  3120. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  3121. pointer-events: auto;
  3122. }
  3123. .loading-spinner {
  3124. width: 48px;
  3125. height: 48px;
  3126. border: 4px solid #f3f3f3;
  3127. border-top: 4px solid #409eff;
  3128. border-radius: 50%;
  3129. animation: spin 1s linear infinite;
  3130. }
  3131. @keyframes spin {
  3132. 0% {
  3133. transform: rotate(0deg);
  3134. }
  3135. 100% {
  3136. transform: rotate(360deg);
  3137. }
  3138. }
  3139. .loading-text {
  3140. font-size: 16px;
  3141. font-weight: 500;
  3142. color: #333;
  3143. }
  3144. /* 按钮样式 */
  3145. .generate-btn {
  3146. padding: 14px 8px;
  3147. border: none;
  3148. border-radius: 8px;
  3149. font-size: 14px;
  3150. font-weight: 400;
  3151. cursor: pointer;
  3152. transition: all 0.3s ease;
  3153. position: relative;
  3154. overflow: hidden;
  3155. }
  3156. .generate-btn.primary {
  3157. background: linear-gradient(135deg, #409eff, #1890ff);
  3158. color: white;
  3159. box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
  3160. }
  3161. .generate-btn.primary:hover {
  3162. transform: translateY(-2px);
  3163. box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
  3164. }
  3165. .generate-btn.primary:disabled {
  3166. background: #91c5f7;
  3167. cursor: not-allowed;
  3168. transform: none;
  3169. box-shadow: none;
  3170. }
  3171. .generate-btn.small {
  3172. padding: 8px 16px;
  3173. font-size: 14px;
  3174. border-radius: 8px;
  3175. }
  3176. .generate-btn.small:hover {
  3177. transform: translateY(-1px);
  3178. box-shadow: 0 3px 8px rgba(64, 158, 255, 0.3);
  3179. }
  3180. .generate-btn.small:disabled {
  3181. background: #91c5f7;
  3182. color: white;
  3183. cursor: not-allowed;
  3184. transform: none;
  3185. box-shadow: none;
  3186. }
  3187. .toolbar-btn:disabled {
  3188. background: #f0f0f0;
  3189. color: #c0c0c0;
  3190. border-color: #e0e0e0;
  3191. cursor: not-allowed;
  3192. transform: none;
  3193. box-shadow: none;
  3194. }
  3195. .toolbar-btn:disabled:hover {
  3196. background: #f0f0f0;
  3197. color: #c0c0c0;
  3198. border-color: #e0e0e0;
  3199. transform: none;
  3200. box-shadow: none;
  3201. }
  3202. /* 编辑器工具栏 */
  3203. .editor-toolbar {
  3204. position: sticky;
  3205. top: 20px;
  3206. z-index: 100;
  3207. margin-bottom: 30px;
  3208. padding: 16px 20px;
  3209. background: rgba(250, 250, 250, 0.95);
  3210. backdrop-filter: blur(10px);
  3211. border-radius: 12px;
  3212. border: 1px solid #e8e8e8;
  3213. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  3214. overflow-x: auto;
  3215. overflow-y: hidden;
  3216. white-space: nowrap;
  3217. }
  3218. .editor-toolbar::-webkit-scrollbar {
  3219. height: 4px;
  3220. }
  3221. .editor-toolbar::-webkit-scrollbar-track {
  3222. background: #f1f1f1;
  3223. border-radius: 2px;
  3224. }
  3225. .editor-toolbar::-webkit-scrollbar-thumb {
  3226. background: #c1c1c1;
  3227. border-radius: 2px;
  3228. }
  3229. .editor-toolbar::-webkit-scrollbar-thumb:hover {
  3230. background: #a1a1a1;
  3231. }
  3232. .toolbar-btn {
  3233. padding: 12px 24px;
  3234. margin: 0 12px;
  3235. background: white;
  3236. border: 2px solid #e8e8e8;
  3237. border-radius: 10px;
  3238. cursor: pointer;
  3239. transition: all 0.3s ease;
  3240. font-weight: 500;
  3241. color: #333;
  3242. }
  3243. .toolbar-btn:hover {
  3244. background: #409eff;
  3245. color: white;
  3246. border-color: #409eff;
  3247. transform: translateY(-1px);
  3248. box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
  3249. }
  3250. /* 脚本编辑器 */
  3251. .script-section {
  3252. margin-top: 40px;
  3253. margin-bottom: 40px;
  3254. padding: 5px 24px 24px;
  3255. background: white;
  3256. border-radius: 16px;
  3257. position: relative;
  3258. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  3259. border: 1px solid #f0f0f0;
  3260. }
  3261. .section-header {
  3262. margin-bottom: 24px;
  3263. display: flex;
  3264. align-items: center;
  3265. gap: 16px;
  3266. }
  3267. .section-name-container {
  3268. display: flex;
  3269. align-items: center;
  3270. flex: 1;
  3271. gap: 12px;
  3272. margin-top: 16px;
  3273. }
  3274. .remove-section-btn {
  3275. background: #ff4d4f;
  3276. border: none;
  3277. color: white;
  3278. font-size: 16px;
  3279. cursor: pointer;
  3280. padding: 0;
  3281. width: 28px;
  3282. height: 28px;
  3283. display: flex;
  3284. align-items: center;
  3285. justify-content: center;
  3286. border-radius: 6px;
  3287. transition: all 0.3s ease;
  3288. flex-shrink: 0;
  3289. }
  3290. .remove-section-btn:hover {
  3291. background: #ff7875;
  3292. transform: scale(1.1);
  3293. box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
  3294. }
  3295. .section-name-label {
  3296. padding: 2px 15px;
  3297. border-radius: 10px;
  3298. font-size: 18px;
  3299. font-weight: 500;
  3300. color: white;
  3301. background-color: #c18484;
  3302. white-space: nowrap;
  3303. display: flex;
  3304. align-items: center;
  3305. height: 44px;
  3306. box-sizing: border-box;
  3307. }
  3308. .section-title {
  3309. flex: 1;
  3310. padding: 14px 16px;
  3311. border: 2px solid #e8e8e8;
  3312. border-radius: 10px;
  3313. font-size: 16px;
  3314. font-weight: 500;
  3315. transition: all 0.3s ease;
  3316. }
  3317. .section-title:focus {
  3318. outline: none;
  3319. border-color: #409eff;
  3320. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3321. }
  3322. .media-controls {
  3323. display: flex;
  3324. background: linear-gradient(135deg, #f8f9fa, #ffffff);
  3325. padding: 16px 20px;
  3326. border-radius: 10px;
  3327. border: 1px solid #e8e8e8;
  3328. align-items: center;
  3329. justify-content: space-between;
  3330. }
  3331. .media-item {
  3332. display: flex;
  3333. align-items: center;
  3334. gap: 10px;
  3335. min-height: 50px;
  3336. }
  3337. .media-input-group {
  3338. display: flex;
  3339. align-items: center;
  3340. gap: 10px;
  3341. }
  3342. .media-label {
  3343. font-size: 14px;
  3344. font-weight: 600;
  3345. white-space: nowrap;
  3346. color: #666;
  3347. }
  3348. .media-prompt {
  3349. font-size: 14px;
  3350. transition: all 0.3s ease;
  3351. width: 300px;
  3352. }
  3353. .media-prompt-video{
  3354. font-size: 14px;
  3355. transition: all 0.3s ease;
  3356. width: 500px;
  3357. }
  3358. /* 视频对话样式 */
  3359. .dialogue-item.video .dialogue-row {
  3360. justify-content: center;
  3361. }
  3362. .dialogue-item.video .media-item {
  3363. display: flex;
  3364. flex-direction: column;
  3365. align-items: center;
  3366. width: 100%;
  3367. max-width: 900px;
  3368. }
  3369. .dialogue-item.video .media-input-group {
  3370. display: flex;
  3371. align-items: center;
  3372. justify-content: center;
  3373. width: 100%;
  3374. gap: 15px;
  3375. }
  3376. .dialogue-item.video .media-label {
  3377. white-space: nowrap;
  3378. margin-bottom: 0;
  3379. }
  3380. .dialogue-item.video .media-prompt-video {
  3381. flex: 1;
  3382. min-width: 300px;
  3383. max-width: 600px;
  3384. }
  3385. .dialogue-item.video .media-prompt-video .el-textarea {
  3386. min-height: 40px;
  3387. }
  3388. .dialogue-item.video .media-prompt-video .el-textarea__inner {
  3389. min-height: 40px;
  3390. padding: 6px 12px;
  3391. }
  3392. .dialogue-item.video .media-preview {
  3393. flex: 0 0 200px;
  3394. margin: 5px 0;
  3395. }
  3396. .dialogue-item.video .media-preview video {
  3397. width: 100%;
  3398. max-height: 120px;
  3399. object-fit: cover;
  3400. border-radius: 4px;
  3401. }
  3402. .dialogue-item.video .generate-btn {
  3403. min-width: 80px;
  3404. white-space: nowrap;
  3405. }
  3406. .dialogue-item.video .remove-btn {
  3407. margin-left: 10px;
  3408. }
  3409. .media-prompt .el-textarea {
  3410. width: 100%;
  3411. min-height: 60px;
  3412. }
  3413. .media-prompt .el-textarea__inner {
  3414. padding: 8px 12px;
  3415. border: 2px solid #e8e8e8;
  3416. border-radius: 8px;
  3417. font-size: 14px;
  3418. transition: all 0.3s ease;
  3419. min-height: 60px;
  3420. resize: none;
  3421. }
  3422. .media-prompt .el-textarea__inner:focus {
  3423. outline: none;
  3424. border-color: #409eff;
  3425. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3426. }
  3427. .media-preview {
  3428. margin-left: 20px;
  3429. }
  3430. .media-preview img {
  3431. max-width: 180px;
  3432. border-radius: 8px;
  3433. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  3434. transition: transform 0.3s ease;
  3435. }
  3436. .media-preview img:hover {
  3437. transform: scale(1.05);
  3438. }
  3439. .dialogues-container {
  3440. margin-top: 48px;
  3441. }
  3442. .dialogue-item {
  3443. margin-bottom: 20px;
  3444. padding: 20px;
  3445. background: #fafafa;
  3446. border-radius: 12px;
  3447. border: 1px solid #e8e8e8;
  3448. transition: all 0.3s ease;
  3449. }
  3450. .dialogue-item:hover {
  3451. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  3452. transform: translateY(-2px);
  3453. }
  3454. .dialogue-row {
  3455. display: flex;
  3456. align-items: flex-start;
  3457. gap: 16px;
  3458. }
  3459. .dialogue-role-select {
  3460. min-width: 140px;
  3461. }
  3462. .dialogue-role-select select {
  3463. width: 100%;
  3464. padding: 10px 12px;
  3465. border: 2px solid #e8e8e8;
  3466. border-radius: 8px;
  3467. font-size: 14px;
  3468. transition: all 0.3s ease;
  3469. }
  3470. .dialogue-role-select select:focus {
  3471. outline: none;
  3472. border-color: #409eff;
  3473. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3474. }
  3475. .dialogue-content-container {
  3476. flex: 1;
  3477. }
  3478. .dialogue-content:focus {
  3479. outline: none;
  3480. border-color: #409eff;
  3481. box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  3482. }
  3483. /* 提问类型选择 */
  3484. .question-type-select {
  3485. display: flex;
  3486. align-items: center;
  3487. gap: 10px;
  3488. margin-bottom: 12px;
  3489. }
  3490. .question-type-label {
  3491. font-size: 14px;
  3492. font-weight: 600;
  3493. color: #666;
  3494. }
  3495. /* 单选题选项 */
  3496. .single-choice-options {
  3497. margin-top: 16px;
  3498. padding: 16px;
  3499. background: #f8f9fa;
  3500. border-radius: 8px;
  3501. border: 1px solid #e8e8e8;
  3502. }
  3503. .options-header {
  3504. display: flex;
  3505. align-items: center;
  3506. justify-content: space-between;
  3507. margin-bottom: 12px;
  3508. }
  3509. .options-label {
  3510. font-size: 14px;
  3511. font-weight: 600;
  3512. color: #666;
  3513. }
  3514. .add-option-btn {
  3515. padding: 6px 12px;
  3516. background: #409eff;
  3517. color: white;
  3518. border: none;
  3519. border-radius: 4px;
  3520. font-size: 12px;
  3521. cursor: pointer;
  3522. transition: all 0.2s ease;
  3523. }
  3524. .add-option-btn:hover {
  3525. background: #66b1ff;
  3526. }
  3527. .option-item {
  3528. display: flex;
  3529. align-items: center;
  3530. gap: 10px;
  3531. margin-bottom: 10px;
  3532. }
  3533. .option-item:last-child {
  3534. margin-bottom: 0;
  3535. }
  3536. .option-label {
  3537. font-weight: 600;
  3538. color: #409eff;
  3539. width: 20px;
  3540. text-align: center;
  3541. flex-shrink: 0;
  3542. }
  3543. .answer-radio-wrapper {
  3544. width: 60px;
  3545. flex-shrink: 0;
  3546. display: flex;
  3547. align-items: center;
  3548. gap: 4px;
  3549. }
  3550. .remove-option-btn {
  3551. flex-shrink: 0;
  3552. background: #ff4d4f;
  3553. border: none;
  3554. color: white;
  3555. font-size: 14px;
  3556. cursor: pointer;
  3557. padding: 0;
  3558. width: 24px;
  3559. height: 24px;
  3560. display: flex;
  3561. align-items: center;
  3562. justify-content: center;
  3563. border-radius: 4px;
  3564. transition: all 0.2s ease;
  3565. }
  3566. .remove-option-btn:hover {
  3567. background: #ff7875;
  3568. }
  3569. /* 答案单选框包装器 */
  3570. .answer-radio-wrapper {
  3571. display: flex;
  3572. align-items: center;
  3573. gap: 4px;
  3574. }
  3575. /* 正确答案标记 */
  3576. .correct-mark {
  3577. color: #52c41a;
  3578. font-size: 18px;
  3579. font-weight: bold;
  3580. animation: fadeIn 0.2s ease;
  3581. }
  3582. /* 调整单选框右外边距 */
  3583. :deep(.el-radio) {
  3584. margin-right: 10px;
  3585. }
  3586. @keyframes fadeIn {
  3587. from {
  3588. opacity: 0;
  3589. transform: scale(0.5);
  3590. }
  3591. to {
  3592. opacity: 1;
  3593. transform: scale(1);
  3594. }
  3595. }
  3596. .remove-btn {
  3597. background: #ff4d4f;
  3598. border: none;
  3599. color: white;
  3600. font-size: 16px;
  3601. cursor: pointer;
  3602. padding: 0;
  3603. width: 28px;
  3604. height: 28px;
  3605. display: flex;
  3606. align-items: center;
  3607. justify-content: center;
  3608. border-radius: 6px;
  3609. transition: all 0.3s ease;
  3610. flex-shrink: 0;
  3611. }
  3612. .remove-btn:hover {
  3613. background: #ff7875;
  3614. transform: scale(1.1);
  3615. box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
  3616. }
  3617. .dialogue-header {
  3618. display: flex;
  3619. justify-content: space-between;
  3620. align-items: center;
  3621. margin-bottom: 8px;
  3622. }
  3623. .dialogue-text {
  3624. flex: 1;
  3625. width: 100%;
  3626. font-size: 16px;
  3627. line-height: 1.6;
  3628. }
  3629. .generate-btn.small {
  3630. padding: 8px;
  3631. background: linear-gradient(135deg, #409eff, #1890ff);
  3632. color: white;
  3633. border: none;
  3634. border-radius: 6px;
  3635. cursor: pointer;
  3636. transition: all 0.3s ease;
  3637. display: flex;
  3638. align-items: center;
  3639. justify-content: center;
  3640. height: 28px;
  3641. font-size: 14px;
  3642. }
  3643. .generate-btn.small:hover {
  3644. transform: scale(1.1);
  3645. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
  3646. }
  3647. .play-btn {
  3648. padding: 8px;
  3649. background: #52c41a;
  3650. color: white;
  3651. border: none;
  3652. border-radius: 6px;
  3653. cursor: pointer;
  3654. transition: all 0.3s ease;
  3655. display: flex;
  3656. align-items: center;
  3657. justify-content: center;
  3658. width: 28px;
  3659. height: 28px;
  3660. font-size: 14px;
  3661. }
  3662. .play-btn:hover {
  3663. background: #73d13d;
  3664. transform: scale(1.1);
  3665. box-shadow: 0 2px 8px rgba(82, 196, 26, 0.3);
  3666. }
  3667. .play-btn.small {
  3668. padding: 8px;
  3669. width: 28px;
  3670. height: 28px;
  3671. font-size: 14px;
  3672. }
  3673. .voice-icon {
  3674. font-size: 14px;
  3675. line-height: 1;
  3676. }
  3677. .play-icon {
  3678. font-size: 14px;
  3679. line-height: 1;
  3680. }
  3681. .action-buttons {
  3682. display: flex;
  3683. flex-direction: column;
  3684. gap: 8px;
  3685. margin-left: 8px;
  3686. }
  3687. .action-buttons-row {
  3688. display: flex;
  3689. gap: 8px;
  3690. align-items: center;
  3691. justify-content: flex-end;
  3692. }
  3693. .add-dialogue-btn,
  3694. .add-section-btn {
  3695. padding: 12px 24px;
  3696. background: white;
  3697. border: 2px dashed #d9d9d9;
  3698. border-radius: 10px;
  3699. cursor: pointer;
  3700. transition: all 0.3s ease;
  3701. font-weight: 500;
  3702. color: #666;
  3703. margin-top: 16px;
  3704. width: 100%;
  3705. text-align: center;
  3706. }
  3707. .add-dialogue-btn:hover,
  3708. .add-section-btn:hover {
  3709. border-color: #c18484;
  3710. color: white;
  3711. background: rgba(193, 132, 132, 0.6);
  3712. transform: translateY(-1px);
  3713. box-shadow: 0 4px 12px rgba(64, 158, 255, 0.15);
  3714. }
  3715. /* 预览页面 */
  3716. .preview-container {
  3717. width: 100%;
  3718. height: 100%;
  3719. background: white;
  3720. border-radius: 16px;
  3721. padding: 30px;
  3722. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  3723. display: flex;
  3724. flex-direction: column;
  3725. }
  3726. .scrollable-content {
  3727. flex: 1;
  3728. overflow-y: auto;
  3729. margin-bottom: 20px;
  3730. padding-right: 10px;
  3731. }
  3732. .scrollable-content::-webkit-scrollbar {
  3733. width: 6px;
  3734. }
  3735. .scrollable-content::-webkit-scrollbar-track {
  3736. background: #f1f1f1;
  3737. border-radius: 3px;
  3738. }
  3739. .scrollable-content::-webkit-scrollbar-thumb {
  3740. background: #c1c1c1;
  3741. border-radius: 3px;
  3742. }
  3743. .scrollable-content::-webkit-scrollbar-thumb:hover {
  3744. background: #a1a1a1;
  3745. }
  3746. .preview-content {
  3747. margin-top: 20px;
  3748. margin-bottom: 30px;
  3749. }
  3750. .preview-actions {
  3751. margin-top: auto;
  3752. display: flex;
  3753. justify-content: flex-end;
  3754. gap: 12px;
  3755. }
  3756. .validation-result {
  3757. padding: 16px 20px;
  3758. border-radius: 10px;
  3759. font-weight: 500;
  3760. font-size: 14px;
  3761. }
  3762. .validation-result.valid {
  3763. background: #f6ffed;
  3764. border: 2px solid #b7eb8f;
  3765. color: #52c41a;
  3766. box-shadow: 0 2px 8px rgba(82, 196, 26, 0.1);
  3767. }
  3768. .validation-result.invalid {
  3769. background: #fff2f0;
  3770. border: 2px solid #ffccc7;
  3771. color: #ff4d4f;
  3772. box-shadow: 0 2px 8px rgba(255, 77, 79, 0.1);
  3773. }
  3774. .preview-section {
  3775. margin-bottom: 40px;
  3776. padding: 40px;
  3777. border-radius: 12px;
  3778. border: 1px solid #e8e8e8;
  3779. min-height: 300px;
  3780. display: flex;
  3781. align-items: center;
  3782. justify-content: center;
  3783. }
  3784. .preview-section h4 {
  3785. margin-top: 0;
  3786. color: #333;
  3787. font-size: 18px;
  3788. font-weight: 600;
  3789. margin-bottom: 20px;
  3790. }
  3791. .preview-section-content {
  3792. background: rgba(255, 255, 255, 0.2);
  3793. padding: 20px;
  3794. border-radius: 12px;
  3795. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  3796. backdrop-filter: blur(5px);
  3797. width: 80%;
  3798. }
  3799. .preview-media {
  3800. margin: 20px 0;
  3801. padding: 16px;
  3802. background: rgba(255, 255, 255, 0.8);
  3803. border-radius: 10px;
  3804. border: 1px solid #e8e8e8;
  3805. display: flex;
  3806. align-items: center;
  3807. justify-content: space-between;
  3808. flex-wrap: wrap;
  3809. }
  3810. .preview-media-left {
  3811. display: flex;
  3812. align-items: center;
  3813. gap: 12px;
  3814. }
  3815. .preview-media-right {
  3816. display: flex;
  3817. align-items: center;
  3818. gap: 12px;
  3819. }
  3820. .preview-image img {
  3821. max-width: 250px;
  3822. border-radius: 8px;
  3823. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  3824. transition: transform 0.3s ease;
  3825. }
  3826. .preview-image img:hover {
  3827. transform: scale(1.05);
  3828. }
  3829. .preview-audio {
  3830. float: right;
  3831. margin-right: 20px;
  3832. display: flex;
  3833. align-items: center;
  3834. gap: 8px;
  3835. }
  3836. .preview-dialogue {
  3837. margin-bottom: 20px;
  3838. padding: 16px;
  3839. background: white;
  3840. border-radius: 10px;
  3841. border: 1px solid #e8e8e8;
  3842. transition: all 0.3s ease;
  3843. }
  3844. .dialogue-header {
  3845. display: flex;
  3846. justify-content: space-between;
  3847. align-items: center;
  3848. margin-bottom: 8px;
  3849. }
  3850. .preview-dialogue:hover {
  3851. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  3852. }
  3853. .dialogue-role {
  3854. font-weight: 600;
  3855. color: #409eff;
  3856. font-size: 14px;
  3857. }
  3858. .dialogue-text {
  3859. line-height: 1.6;
  3860. font-size: 14px;
  3861. color: #333;
  3862. }
  3863. /* Markdown 样式 */
  3864. .dialogue-text h1,
  3865. .dialogue-text h2,
  3866. .dialogue-text h3,
  3867. .dialogue-text h4,
  3868. .dialogue-text h5,
  3869. .dialogue-text h6 {
  3870. margin: 16px 0 8px 0;
  3871. font-weight: 600;
  3872. line-height: 1.2;
  3873. }
  3874. .dialogue-text h1 {
  3875. font-size: 24px;
  3876. }
  3877. .dialogue-text h2 {
  3878. font-size: 20px;
  3879. }
  3880. .dialogue-text h3 {
  3881. font-size: 18px;
  3882. }
  3883. .dialogue-text h4 {
  3884. font-size: 16px;
  3885. }
  3886. .dialogue-text h5 {
  3887. font-size: 14px;
  3888. }
  3889. .dialogue-text h6 {
  3890. font-size: 12px;
  3891. }
  3892. .dialogue-text p {
  3893. margin: 8px 0;
  3894. }
  3895. .dialogue-text ul,
  3896. .dialogue-text ol {
  3897. margin: 8px 0;
  3898. padding-left: 24px;
  3899. }
  3900. .dialogue-text li {
  3901. margin: 4px 0;
  3902. }
  3903. .dialogue-text strong {
  3904. font-weight: 600;
  3905. }
  3906. .dialogue-text em {
  3907. font-style: italic;
  3908. }
  3909. .dialogue-text a {
  3910. color: #409eff;
  3911. text-decoration: none;
  3912. }
  3913. .dialogue-text a:hover {
  3914. text-decoration: underline;
  3915. }
  3916. .dialogue-text code {
  3917. background: #f5f5f5;
  3918. padding: 2px 4px;
  3919. border-radius: 4px;
  3920. font-family: 'Courier New', Courier, monospace;
  3921. font-size: 14px;
  3922. }
  3923. .dialogue-text pre {
  3924. background: #f5f5f5;
  3925. padding: 12px;
  3926. border-radius: 8px;
  3927. overflow-x: auto;
  3928. margin: 12px 0;
  3929. }
  3930. .dialogue-text pre code {
  3931. background: none;
  3932. padding: 0;
  3933. }
  3934. .voiceover-preview {
  3935. margin-top: 12px;
  3936. padding-top: 12px;
  3937. border-top: 1px solid #f0f0f0;
  3938. }
  3939. .preview-actions {
  3940. display: flex;
  3941. justify-content: center;
  3942. gap: 20px;
  3943. padding-top: 24px;
  3944. border-top: 1px solid #e8e8e8;
  3945. }
  3946. .primary-btn,
  3947. .secondary-btn {
  3948. padding: 14px 32px;
  3949. border: none;
  3950. border-radius: 12px;
  3951. font-size: 16px;
  3952. font-weight: 600;
  3953. cursor: pointer;
  3954. transition: all 0.3s ease;
  3955. position: relative;
  3956. overflow: hidden;
  3957. }
  3958. .primary-btn {
  3959. background: linear-gradient(135deg, #409eff, #1890ff);
  3960. color: white;
  3961. box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
  3962. }
  3963. .primary-btn:hover {
  3964. transform: translateY(-2px);
  3965. box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
  3966. }
  3967. .primary-btn:disabled {
  3968. background: #91c5f7;
  3969. cursor: not-allowed;
  3970. transform: none;
  3971. box-shadow: none;
  3972. }
  3973. .secondary-btn {
  3974. background: white;
  3975. color: #333;
  3976. border: 2px solid #e8e8e8;
  3977. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  3978. }
  3979. .secondary-btn:hover {
  3980. background: #fafafa;
  3981. border-color: #409eff;
  3982. color: #409eff;
  3983. transform: translateY(-2px);
  3984. box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
  3985. }
  3986. </style>