aiGengrate.vue 130 KB

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