| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985 |
- <template>
- <Dialog
- :title="'AI生成课程'"
- v-model="dialogVisible"
- width="90%"
- :fullscreen="true"
- @update:fullscreen="(value) => (fullscreen = value)"
- >
- <div class="course-script-editor">
- <!-- 全屏遮挡层 -->
- <div v-if="isGenerating" class="loading-overlay">
- <div class="loading-content">
- <div class="loading-spinner"></div>
- <div class="loading-text">生成中...</div>
- </div>
- </div>
- <div class="main-container">
- <!-- 左侧步骤指示器 -->
- <div class="steps-sidebar">
- <div class="steps-container">
- <template v-for="(step, index) in steps" :key="step.id">
- <div
- :class="[
- 'step-item',
- {
- process: currentStep === step.id,
- finish: step.id < currentStep,
- wait: step.id > currentStep
- }
- ]"
- >
- <div class="step-circle">{{ step.id }}</div>
- <div class="step-title">{{ step.label }}</div>
- </div>
- <div
- v-if="index < steps.length - 1"
- class="step-line"
- :class="{ active: currentStep > step.id }"
- ></div>
- </template>
- </div>
- </div>
- <!-- 右侧内容区域 -->
- <div class="content-area">
- <!-- 步骤1:AI一句话生成 -->
- <div v-if="currentStep === 1" class="step-content">
- <div class="ai-input-container">
- <div class="ai-input-wrapper">
- <div class="ai-icon">🤖</div>
- <textarea
- v-model="scriptPrompt"
- placeholder="AI一句话生成课程脚本,例如:生成一节关于牛顿万有引力的小学科学课脚本..."
- class="ai-textarea"
- ></textarea>
- </div>
- <div class="selection-group">
- <div class="selection-item">
- <label>主讲老师</label>
- <el-select
- v-model="selectedMainTeacher"
- filterable
- size="large"
- placeholder="请选择主讲老师"
- style="width: 300px"
- clearable
- >
- <el-option
- v-for="teacher in digitalHumans"
- :key="teacher.name"
- :label="teacher.name"
- :value="teacher.name"
- />
- </el-select>
- </div>
- <div class="selection-item">
- <label>助讲老师</label>
- <el-select
- v-model="selectedAssistants"
- filterable
- size="large"
- placeholder="请选择助讲老师"
- style="width: 300px"
- clearable
- multiple
- >
- <el-option
- v-for="teacher in digitalHumans"
- :key="teacher.name"
- :label="teacher.name"
- :value="teacher.name"
- />
- </el-select>
- </div>
- <div class="selection-item">
- <label>主题类型</label>
- <el-select
- v-model="selectedThemeType"
- size="large"
- placeholder="请选择主题类型"
- style="width: 300px"
- >
- <el-option label="课程通用" value="13" />
- <el-option label="诗词课" value="256" />
- </el-select>
- </div>
- </div>
- <div class="button-group">
- <button
- class="generate-btn primary"
- :disabled="
- !scriptPrompt || !selectedMainTeacher || !selectedThemeType || isGenerating
- "
- @click="generateScript"
- >
- {{ isGenerating ? '生成中...' : '生成课程脚本' }}
- </button>
- <button
- v-if="hasDraftCache"
- class="generate-btn secondary"
- @click="loadDraftAndGotoStep2"
- >
- 查看草稿
- </button>
- </div>
- </div>
- </div>
- <!-- 步骤2:脚本编辑(含背景图/音生成) -->
- <div v-else-if="currentStep === 2" class="step-content">
- <!-- 固定顶部的一键操作栏 -->
- <div class="editor-toolbar sticky-top">
- <button
- class="toolbar-btn"
- @click="generateAllImages"
- :disabled="isGeneratingImages || isAnyImageGenerating"
- >
- {{ isGeneratingImages ? '生成中...' : '一键生成所有背景图' }}
- </button>
- <button
- class="toolbar-btn"
- @click="generateAllVoiceovers"
- :disabled="isGeneratingVoiceovers || isAnyVoiceoverGenerating"
- >
- {{ isGeneratingVoiceovers ? '生成中...' : '一键配音' }}
- </button>
- </div>
- <!-- 可滚动的内容区域 -->
- <div class="script-editor">
- <div
- v-for="(section, sectionIndex) in scriptData.sections"
- :key="sectionIndex"
- class="script-section"
- >
- <div class="section-header">
- <div class="section-name-container">
- <label class="section-name-label">环节 {{ sectionIndex + 1 }}</label>
- <input
- v-model="section.name"
- class="section-title"
- placeholder="如:环节一(引入)"
- />
- </div>
- <button class="remove-section-btn" @click="removeSection(sectionIndex)">×</button>
- </div>
- <div class="media-controls">
- <div class="media-item">
- <div class="media-input-group">
- <span class="media-label">背景图</span>
- <el-input
- v-model="section.backgroundImage.prompt"
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 4 }"
- placeholder="描述词"
- class="media-prompt"
- />
- <el-button
- type="primary"
- size="small"
- :loading="section.backgroundImage.generating"
- :disabled="
- !section.backgroundImage.prompt || section.backgroundImage.generating
- "
- @click="generateMedia(sectionIndex)"
- class="generate-btn"
- >
- {{
- section.backgroundImage.generating
- ? '生成中...'
- : section.backgroundImage.url
- ? '重新生成'
- : '生成'
- }}
- </el-button>
- </div>
- <div v-if="section.backgroundImage.url" class="media-preview">
- <img :src="section.backgroundImage.url" alt="背景图预览" />
- </div>
- </div>
- <div class="media-item">
- <div class="media-input-group">
- <span class="media-label">背景音</span>
- <el-select
- v-model="section.backgroundAudio.type"
- placeholder="选择背景音"
- :style="{ width: fullscreen ? '240px' : '130px' }"
- clearable
- size="large"
- @change="(value) => handleBackgroundAudioChange(value, section)"
- >
- <el-option
- v-for="musicType in backgroundMusicTypes"
- :key="musicType.id"
- :label="musicType.name"
- :value="musicType.id"
- />
- </el-select>
- <button
- v-if="section.backgroundAudio.type"
- class="play-btn small"
- @click="playBackgroundAudio(section.backgroundAudio.type)"
- >
- <span class="play-icon">{{
- audioState.isPlaying &&
- audioState.currentType === 'background' &&
- audioState.currentUrl === section.backgroundAudio.url
- ? '⏸'
- : '▶'
- }}</span>
- </button>
- </div>
- </div>
- </div>
- <div class="dialogues-container">
- <div
- v-for="(dialogue, dialogueIndex) in section.dialogues"
- :key="dialogueIndex"
- class="dialogue-item"
- :class="[dialogue.type, { hidden: dialogue.type === 'user' }]"
- >
- <div class="dialogue-header">
- <div class="dialogue-type-tag" :class="dialogue.type">
- {{
- dialogue.type === 'digital'
- ? '数字人'
- : dialogue.type === 'user'
- ? '用户'
- : dialogue.type === 'quest'
- ? '提问'
- : '诗词'
- }}
- </div>
- </div>
- <div class="dialogue-row">
- <!-- 数字人对话 -->
- <template v-if="dialogue.type === 'digital'">
- <div class="dialogue-role-select">
- <el-select
- v-model="dialogue.roleName"
- placeholder="选择角色"
- style="width: 140px"
- clearable
- >
- <el-option
- v-for="role in digitalHumans"
- :key="role.id"
- :label="role.name"
- :value="role.name"
- />
- </el-select>
- </div>
- <div class="dialogue-content-container">
- <el-input
- v-model="dialogue.content"
- type="textarea"
- class="dialogue-content"
- placeholder="对话内容..."
- :autosize="{ minRows: 2, maxRows: 4 }"
- />
- </div>
- <div class="action-buttons">
- <div class="action-buttons-row">
- <button
- v-if="dialogue.voiceoverUrl"
- class="play-btn"
- @click="playVoiceover(dialogue.voiceoverUrl)"
- >
- <span class="play-icon">{{
- audioState.isPlaying &&
- audioState.currentType === 'voice' &&
- audioState.currentUrl === dialogue.voiceoverUrl
- ? '⏸'
- : '▶'
- }}</span>
- </button>
- <button
- class="remove-btn"
- @click="removeDialogue(sectionIndex, dialogueIndex)"
- >×</button
- >
- </div>
- <div class="action-buttons-row">
- <button
- v-if="!dialogue.voiceoverUrl"
- class="generate-btn small"
- :disabled="
- !dialogue.content ||
- !dialogue.roleName ||
- dialogue.generatingVoiceover
- "
- @click="generateVoiceover(sectionIndex, dialogueIndex)"
- >
- <span class="voice-icon">{{
- dialogue.generatingVoiceover ? '生成中...' : '生成语音'
- }}</span>
- </button>
- <button
- v-if="dialogue.voiceoverUrl"
- class="generate-btn small"
- :disabled="
- !dialogue.content ||
- !dialogue.roleName ||
- dialogue.generatingVoiceover
- "
- @click="generateVoiceover(sectionIndex, dialogueIndex)"
- >
- <span class="voice-icon">{{
- dialogue.generatingVoiceover ? '生成中...' : '重新生成'
- }}</span>
- </button>
- </div>
- </div>
- </template>
- <!-- 用户 -->
- <template v-else-if="dialogue.type === 'user'">
- <div class="dialogue-content-container full-width">
- <el-input
- v-model="dialogue.content"
- type="textarea"
- class="dialogue-content"
- placeholder="用户回复内容参考语..."
- :autosize="{ minRows: 2, maxRows: 4 }"
- />
- </div>
- <div class="dialogue-reply-select">
- <el-select
- v-model="dialogue.roleName"
- placeholder="选择数字人回复"
- style="width: 140px"
- clearable
- >
- <el-option
- v-for="role in digitalHumans"
- :key="role.id"
- :label="role.name"
- :value="role.name"
- />
- </el-select>
- </div>
- <div class="action-buttons">
- <div class="action-buttons-row">
- <button
- class="remove-btn"
- @click="removeDialogue(sectionIndex, dialogueIndex)"
- >×</button
- >
- </div>
- </div>
- </template>
- <!-- 提问 -->
- <template v-else-if="dialogue.type === 'quest'">
- <div class="dialogue-role-select">
- <el-select
- v-model="dialogue.roleName"
- placeholder="选择角色"
- style="width: 140px"
- clearable
- >
- <el-option
- v-for="role in digitalHumans"
- :key="role.id"
- :label="role.name"
- :value="role.name"
- />
- </el-select>
- </div>
- <div class="dialogue-content-container">
- <el-input
- v-model="dialogue.content"
- type="textarea"
- class="dialogue-content"
- placeholder="提问内容..."
- :autosize="{ minRows: 2, maxRows: 4 }"
- />
- </div>
- <div class="action-buttons">
- <div class="action-buttons-row">
- <button
- v-if="dialogue.voiceoverUrl"
- class="play-btn"
- @click="playVoiceover(dialogue.voiceoverUrl)"
- >
- <span class="play-icon">{{
- audioState.isPlaying &&
- audioState.currentType === 'voice' &&
- audioState.currentUrl === dialogue.voiceoverUrl
- ? '⏸'
- : '▶'
- }}</span>
- </button>
- <button
- class="remove-btn"
- @click="removeDialogue(sectionIndex, dialogueIndex)"
- >×</button
- >
- </div>
- <div class="action-buttons-row">
- <button
- v-if="!dialogue.voiceoverUrl"
- class="generate-btn small"
- :disabled="
- !dialogue.content ||
- !dialogue.roleName ||
- dialogue.generatingVoiceover
- "
- @click="generateVoiceover(sectionIndex, dialogueIndex)"
- >
- <span class="voice-icon">{{
- dialogue.generatingVoiceover ? '生成中...' : '生成语音'
- }}</span>
- </button>
- <button
- v-if="dialogue.voiceoverUrl"
- class="generate-btn small"
- :disabled="
- !dialogue.content ||
- !dialogue.roleName ||
- dialogue.generatingVoiceover
- "
- @click="generateVoiceover(sectionIndex, dialogueIndex)"
- >
- <span class="voice-icon">{{
- dialogue.generatingVoiceover ? '生成中...' : '重新生成'
- }}</span>
- </button>
- </div>
- </div>
- </template>
- <!-- 诗词 -->
- <template v-else-if="dialogue.type === 'poem'">
- <div class="dialogue-role-select">
- <el-select
- v-model="dialogue.roleName"
- placeholder="选择角色"
- style="width: 140px"
- clearable
- >
- <el-option
- v-for="role in digitalHumans"
- :key="role.id"
- :label="role.name"
- :value="role.name"
- />
- </el-select>
- </div>
- <div class="dialogue-content-container">
- <el-input
- v-model="dialogue.content"
- type="textarea"
- class="dialogue-content"
- placeholder="诗词内容..."
- :autosize="{ minRows: 2, maxRows: 4 }"
- />
- </div>
- <div class="action-buttons">
- <div class="action-buttons-row">
- <button
- v-if="dialogue.voiceoverUrl"
- class="play-btn"
- @click="playVoiceover(dialogue.voiceoverUrl)"
- >
- <span class="play-icon">{{
- audioState.isPlaying &&
- audioState.currentType === 'voice' &&
- audioState.currentUrl === dialogue.voiceoverUrl
- ? '⏸'
- : '▶'
- }}</span>
- </button>
- <button
- class="remove-btn"
- @click="removeDialogue(sectionIndex, dialogueIndex)"
- >×</button
- >
- </div>
- <div class="action-buttons-row">
- <button
- v-if="!dialogue.voiceoverUrl"
- class="generate-btn small"
- :disabled="
- !dialogue.content ||
- !dialogue.roleName ||
- dialogue.generatingVoiceover
- "
- @click="generateVoiceover(sectionIndex, dialogueIndex)"
- >
- <span class="voice-icon">{{
- dialogue.generatingVoiceover ? '生成中...' : '生成语音'
- }}</span>
- </button>
- <button
- v-if="dialogue.voiceoverUrl"
- class="generate-btn small"
- :disabled="
- !dialogue.content ||
- !dialogue.roleName ||
- dialogue.generatingVoiceover
- "
- @click="generateVoiceover(sectionIndex, dialogueIndex)"
- >
- <span class="voice-icon">{{
- dialogue.generatingVoiceover ? '生成中...' : '重新生成'
- }}</span>
- </button>
- </div>
- </div>
- </template>
- </div>
- </div>
- <div class="add-dialogue-buttons">
- <button class="add-dialogue-btn digital" @click="addDialogue(sectionIndex)"
- >+ 添加对话</button
- >
- <button
- class="add-dialogue-btn quest-user"
- @click="addQuestWithUserReply(sectionIndex)"
- >+ 添加提问与回复</button
- >
- <button class="add-dialogue-btn poem" @click="addPoemDialogue(sectionIndex)"
- >+ 添加诗词</button
- >
- </div>
- </div>
- </div>
- <button class="add-section-btn" @click="addSection">+ 添加环节</button>
- </div>
- <div class="preview-actions">
- <button v-if="currentStep > 1" class="secondary-btn" @click="currentStep--">
- 重新生成
- </button>
- <button class="primary-btn" @click="nextStep"> 预览完整脚本 </button>
- </div>
- </div>
- <!-- 步骤3:预览与保存 -->
- <div v-else-if="currentStep === 3" class="step-content">
- <div class="preview-container">
- <h3>课程脚本预览</h3>
- <div class="scrollable-content">
- <br />
- <div v-if="isValidationPassed" class="validation-result valid">
- {{ validationMessage }}
- </div>
- <div v-else>
- <div
- v-for="(error, index) in errorMessages"
- :key="index"
- class="validation-result invalid"
- >
- {{ error }}
- </div>
- </div>
- <div class="preview-content">
- <div
- v-for="(section, sectionIndex) in scriptData.sections"
- :key="sectionIndex"
- class="preview-section"
- :style="{
- backgroundImage: section.backgroundImage.url
- ? `url(${section.backgroundImage.url})`
- : 'none',
- backgroundSize: 'cover',
- backgroundPosition: 'center',
- backgroundRepeat: 'no-repeat'
- }"
- >
- <div class="preview-section-content">
- <div class="preview-media">
- <div class="preview-media-left">
- <label class="section-name-label">环节 {{ sectionIndex + 1 }}</label>
- <strong>{{ section.name }}</strong>
- </div>
- <div class="preview-media-right">
- <span v-if="section.backgroundAudio.type" class="preview-audio">
- 背景音:{{ section.backgroundAudio.type }}
- <button
- class="play-btn small"
- @click="playBackgroundAudio(section.backgroundAudio.type)"
- >
- <span class="play-icon">{{
- audioState.isPlaying &&
- audioState.currentType === 'background' &&
- audioState.currentUrl === section.backgroundAudio.url
- ? '⏸'
- : '▶'
- }}</span>
- </button>
- </span>
- </div>
- </div>
- <div class="preview-dialogues">
- <div
- v-for="(dialogue, dialogueIndex) in section.dialogues.filter(
- (d) => d.type !== 'user'
- )"
- :key="dialogueIndex"
- class="preview-dialogue"
- :class="dialogue.type"
- >
- <div class="dialogue-header">
- <div class="dialogue-header-left">
- <div class="dialogue-type-tag" :class="dialogue.type">
- {{
- dialogue.type === 'digital'
- ? '数字人'
- : dialogue.type === 'user'
- ? '用户'
- : dialogue.type === 'quest'
- ? '提问'
- : '诗词'
- }}
- </div>
- <div class="dialogue-role">
- {{
- dialogue.type !== 'user'
- ? getRoleName(dialogue.roleName)
- : '用户'
- }}:
- </div>
- </div>
- <button
- v-if="dialogue.voiceoverUrl"
- class="play-btn small"
- @click="playVoiceover(dialogue.voiceoverUrl)"
- >
- <span class="play-icon">{{
- audioState.isPlaying &&
- audioState.currentType === 'voice' &&
- audioState.currentUrl === dialogue.voiceoverUrl
- ? '⏸'
- : '▶'
- }}</span>
- </button>
- </div>
- <div class="dialogue-text" v-html="parseMarkdown(dialogue.content)"></div>
- <div
- v-if="dialogue.type === 'user' && dialogue.roleName"
- class="reply-info"
- >
- 回复角色:{{ getRoleName(dialogue.roleName) }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="preview-actions">
- <button class="secondary-btn" @click="currentStep = 2">返回修改</button>
- <!-- <button
- class="primary-btn"
- :disabled="!isValidationPassed"
- @click="showVideoPreview"
- >
- 预览视频
- </button>-->
- <button class="primary-btn" :disabled="!isValidationPassed" @click="saveScript">
- 保存课程脚本
- </button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 视频预览模态框 -->
- <VideoPreview
- :visible="showVideoPreviewModal"
- :script-data="scriptData"
- :script-roles="digitalHumans"
- @close="closeVideoPreview"
- />
- </div>
- </Dialog>
- </template>
- <script setup>
- import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
- import { Dialog } from '@/components/Dialog'
- import { ChatMessageApi } from '@/api/ai/chat/message'
- import { ChatConversationApi } from '@/api/ai/chat/conversation'
- import { ChatRoleApi } from '@/api/ai/model/chatRole'
- import { ImageApi } from '@/api/ai/image'
- import { TtsApi } from '@/api/ai/tts'
- import VideoPreview from '@/views/bjdx/course/aiGenerate/VideoPreview.vue'
- import { AiImageStatusEnum, AiPlatformEnum } from '@/views/ai/utils/constants'
- import { marked } from 'marked'
- import { useUserStore } from '@/store/modules/user'
- // 步骤配置
- const steps = [
- { id: 1, label: 'AI生成脚本' },
- { id: 2, label: '编辑脚本与媒体' },
- { id: 3, label: '预览与保存' }
- ]
- // 当前步骤
- const currentStep = ref(1)
- // 步骤1数据
- const scriptPrompt = ref('')
- const selectedMainTeacher = ref('')
- const selectedAssistants = ref([])
- const selectedThemeType = ref()
- const isGenerating = ref(false)
- // 对话框可见性
- const props = defineProps({
- visible: {
- type: Boolean,
- default: false
- },
- initialStep: {
- type: Number,
- default: 1
- },
- initialScriptData: {
- type: String,
- default: ''
- }
- })
- const dialogVisible = computed({
- get: () => props.visible,
- set: (value) => emit('update:visible', value)
- })
- // 获取用户信息
- const userStore = useUserStore()
- const userId = computed(() => userStore.getUser.id)
- // 检查是否存在草稿缓存
- const hasDraftCache = ref(false)
- // 步骤2生成状态
- const isGeneratingImages = ref(false)
- const isGeneratingVoiceovers = ref(false)
- // 数字人列表
- const digitalHumans = ref([])
- // 背景音类型
- const backgroundMusicTypes = ref([
- {
- id: '轻松欢快',
- name: '轻松欢快',
- url: 'https://learn-aliyun-oss.oss-cn-beijing.aliyuncs.com/20260310/AI_1773106630966.MP3'
- }
- ])
- // 从localStorage加载脚本数据
- const loadScriptDataFromCache = () => {
- try {
- const key = `courseScriptData_${userId.value}`
- const cachedData = localStorage.getItem(key)
- if (cachedData) {
- try {
- return JSON.parse(cachedData)
- } catch (error) {
- console.error('解析缓存数据失败:', error)
- }
- }
- } catch (error) {
- console.error('获取用户信息失败:', error)
- }
- return null
- }
- // 是否为编辑模式
- const isEditMode = ref(false)
- // 脚本数据结构
- const scriptData = reactive(
- loadScriptDataFromCache() || {
- title: '',
- sections: [
- {
- name: '环节一',
- backgroundImage: {
- prompt: '',
- url: '',
- generating: false
- },
- backgroundAudio: {
- type: '',
- url: ''
- },
- dialogues: [
- {
- type: 'digital',
- roleName: '',
- content: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- },
- {
- type: 'user',
- roleName: '',
- content: ''
- }
- ]
- }
- ]
- }
- )
- // 保存脚本数据到localStorage
- const saveScriptDataToCache = () => {
- try {
- const key = `courseScriptData_${userId.value}`
- localStorage.setItem(key, JSON.stringify(scriptData))
- hasDraftCache.value = true
- console.log('保存脚本数据到缓存', key)
- } catch (error) {
- console.error('保存缓存数据失败:', error)
- }
- }
- // 清空脚本数据缓存
- const clearScriptDataCache = () => {
- const key = `courseScriptData_${userId.value}`
- localStorage.removeItem(key)
- hasDraftCache.value = false
- console.log('清除脚本数据缓存', key)
- }
- // 加载草稿并跳转到步骤2
- const loadDraftAndGotoStep2 = () => {
- const cachedData = loadScriptDataFromCache()
- if (cachedData) {
- Object.assign(scriptData, cachedData)
- currentStep.value = 2
- }
- }
- // 监听脚本数据变化,自动保存到缓存
- watch(
- () => scriptData,
- () => {
- saveScriptDataToCache()
- },
- { deep: true }
- )
- // 监听对话框可见性变化
- watch(
- () => props.visible,
- (newVisible, oldVisible) => {
- if (newVisible) {
- // 对话框打开时,设置初始步骤
- currentStep.value = props.initialStep
- // 清空被替换的URL集合
- replacedUrls.value.clear()
- // 处理脚本数据
- if (props.initialScriptData) {
- // 标记为编辑模式
- isEditMode.value = true
- try {
- const parsedData = JSON.parse(props.initialScriptData)
- Object.assign(scriptData, parsedData)
- } catch (error) {
- console.error('解析脚本数据失败:', error)
- // 解析失败,尝试加载草稿
- const cachedData = loadScriptDataFromCache()
- if (cachedData) {
- Object.assign(scriptData, cachedData)
- }
- }
- } else {
- // 标记为新建模式
- isEditMode.value = false
- // 没有脚本数据,尝试加载草稿
- const cachedData = loadScriptDataFromCache()
- if (cachedData) {
- Object.assign(scriptData, cachedData)
- }
- }
- } else if (oldVisible) {
- // 对话框关闭时
- if (props.initialScriptData) {
- // 编辑进来的,清空缓存
- clearScriptDataCache()
- }
- // 重置编辑模式标记
- isEditMode.value = false
- // 新增进来的,保留缓存
- }
- }
- )
- // 音频播放状态
- const audioState = reactive({
- currentAudio: null,
- isPlaying: false,
- currentType: '',
- currentUrl: ''
- })
- // 存储所有音频实例
- const audioInstances = new Map()
- // 计算属性:判断是否可以进入下一步
- const canProceed = computed(() => {
- switch (currentStep.value) {
- case 1:
- return !!scriptPrompt.value && !!selectedMainTeacher.value && !!selectedThemeType.value
- case 2:
- case 3:
- return scriptData.sections.every(
- (section) =>
- section.backgroundImage.url &&
- section.dialogues.every(
- (dialogue) =>
- (dialogue.type === 'digital' ||
- dialogue.type === 'quest' ||
- dialogue.type === 'poem') &&
- dialogue.roleName &&
- dialogue.content.trim() &&
- dialogue.voiceoverUrl
- )
- )
- default:
- return false
- }
- })
- // 计算属性:检查是否有任何背景图正在生成
- const isAnyImageGenerating = computed(() => {
- return scriptData.sections.some((section) => section.backgroundImage.generating)
- })
- // 计算属性:检查是否有任何配音正在生成
- const isAnyVoiceoverGenerating = computed(() => {
- return scriptData.sections.some((section) =>
- section.dialogues.some((dialogue) => dialogue.generatingVoiceover)
- )
- })
- // 校验结果
- const isValidationPassed = ref(false)
- const validationMessage = ref('')
- const errorMessages = ref([])
- // 视频预览状态
- const showVideoPreviewModal = ref(false)
- // 全屏状态
- const fullscreen = ref(false)
- // 存储被替换的URL链接集合
- const replacedUrls = ref(new Set())
- const activeConversationId = ref(null) // 选中的对话编号
- const conversationInAbortController = ref() // 对话进行中 abort 控制器(控制 stream 对话)
- const conversationInProgress = ref(false) // 对话是否正在进行中。目前只有【发送】消息时,会更新为 true,避免切换对话、删除对话等操作
- const enableContext = ref(false) // 是否开启上下文
- // 接收 Stream 消息
- const receiveMessageFullText = ref('')
- const scriptDataTemp = ref(null)
- // 步骤1:生成脚本
- const generateScript = async () => {
- isGenerating.value = true
- try {
- clearScriptDataCache()
- scriptData.title = ''
- scriptData.sections = []
- receiveMessageFullText.value = ''
- scriptDataTemp.value = null
- const role = digitalHumans.value.find((r) => r.name === selectedMainTeacher.value)
- let content =
- scriptPrompt.value +
- '(主讲人:' +
- role.name +
- ',主讲人角色定位:' +
- role.description +
- ';助讲有:'
- let zhujiang = []
- selectedAssistants.value.forEach((rName) => {
- const role = digitalHumans.value.find((r) => r.name === rName)
- zhujiang.push(role.name + '[' + role.description + ']')
- })
- content += zhujiang.join(',') + ')'
- await createAiRoleIdConversation(Number(selectedThemeType.value))
- currentStep.value = 2
- await doSendMessageStream(activeConversationId.value, content)
- } catch (error) {
- console.error('生成脚本失败:', error)
- } finally {
- isGenerating.value = false
- }
- }
- /** 选择 card 角色:新建聊天对话 */
- const createAiRoleIdConversation = async (roleId) => {
- activeConversationId.value = await ChatConversationApi.createChatConversationMy({
- roleId: roleId
- })
- }
- /** 真正执行【发送】消息操作 */
- const doSendMessageStream = async (conversationId, content) => {
- conversationInAbortController.value = new AbortController()
- conversationInProgress.value = true
- scriptPrompt.value = ''
- try {
- let isFirstChunk = true
- await ChatMessageApi.sendChatMessageStream(
- conversationId,
- content,
- conversationInAbortController.value,
- enableContext.value,
- async (res) => {
- const { code, data, msg } = JSON.parse(res.data)
- if (code !== 0) {
- console.error(`对话异常! ${msg}`)
- return
- }
- if (data.eventType === 'TEXT') {
- if (data.receive?.content === '') {
- return
- }
- if (isFirstChunk) {
- isFirstChunk = false
- }
- receiveMessageFullText.value += data.receive.content
- console.log('数据加载中..')
- try {
- const parsedData = JSON.parse(receiveMessageFullText.value)
- scriptDataTemp.value = parsedData
- Object.assign(scriptData, parsedData)
- } catch (e) {
- // 解析失败,说明数据还不完整,继续等待
- }
- }
- },
- (error) => {
- console.error(`对话异常! ${error}`)
- throw error
- },
- () => {
- try {
- if (receiveMessageFullText.value) {
- console.log('最终数据:', receiveMessageFullText.value)
- const parsedData = JSON.parse(receiveMessageFullText.value)
- console.log('最终数据json:', parsedData)
- scriptDataTemp.value = parsedData
- Object.assign(scriptData, parsedData)
- }
- } catch (e) {
- console.error('最终数据解析失败:', e)
- // 清洗规则:移除```json、```、** 等非JSON标记,只保留中间的JSON内容
- try {
- let cleanJsonStr = receiveMessageFullText.value
- const parsedData = JSON.parse(
- cleanJsonStr
- .replace(/^```json\s*/, '')
- .replace(/\s*```$/, '')
- .replace(/\*\*/g, '')
- .trim()
- )
- console.log('最终清洗后数据json:', parsedData)
- scriptDataTemp.value = parsedData
- Object.assign(scriptData, parsedData)
- } catch (cleanError) {
- console.error('清洗后数据解析失败:', cleanError)
- }
- }
- }
- )
- } catch (error) {
- console.error('发送消息流失败:', error)
- } finally {
- conversationInProgress.value = false
- }
- }
- // 步骤2:添加环节
- const addSection = () => {
- scriptData.sections.push({
- name: `环节${scriptData.sections.length + 1}`,
- backgroundImage: { prompt: '', url: '', generating: false },
- backgroundAudio: { type: '', url: '' },
- dialogues: []
- })
- }
- // 步骤2:添加对话(数字人)
- const addDialogue = (sectionIndex) => {
- scriptData.sections[sectionIndex].dialogues.push({
- type: 'digital',
- roleName: '',
- content: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- })
- }
- // 步骤2:添加用户回复
- const addUserReply = (sectionIndex) => {
- scriptData.sections[sectionIndex].dialogues.push({
- type: 'user',
- content: '',
- roleName: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- })
- }
- // 步骤2:添加提问
- const addQuestDialogue = (sectionIndex) => {
- scriptData.sections[sectionIndex].dialogues.push({
- type: 'quest',
- content: '',
- roleName: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- })
- }
- // 步骤2:添加诗词
- const addPoemDialogue = (sectionIndex) => {
- scriptData.sections[sectionIndex].dialogues.push({
- type: 'poem',
- content: '',
- roleName: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- })
- }
- // 步骤2:添加提问与用户回复
- const addQuestWithUserReply = (sectionIndex) => {
- // 添加提问类型对话
- scriptData.sections[sectionIndex].dialogues.push({
- type: 'quest',
- content: '',
- roleName: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- })
- // 添加用户回复类型对话
- scriptData.sections[sectionIndex].dialogues.push({
- type: 'user',
- content: '',
- roleName: '',
- voiceoverUrl: '',
- generatingVoiceover: false
- })
- }
- // 步骤2:删除对话
- const removeDialogue = (sectionIndex, dialogueIndex) => {
- const dialogues = scriptData.sections[sectionIndex].dialogues
- const dialogue = dialogues[dialogueIndex]
- // 如果是提问类型,同时删除后面的用户回复
- if (
- dialogue.type === 'quest' &&
- dialogueIndex < dialogues.length - 1 &&
- dialogues[dialogueIndex + 1].type === 'user'
- ) {
- dialogues.splice(dialogueIndex, 2)
- } else {
- dialogues.splice(dialogueIndex, 1)
- }
- }
- // 步骤2:删除环节
- const removeSection = (sectionIndex) => {
- if (scriptData.sections.length > 1) {
- scriptData.sections.splice(sectionIndex, 1)
- } else {
- alert('至少需要保留一个环节')
- }
- }
- // 图片生成相关状态
- const inProgressImageMap = ref({}) // 监听的图片映射,key 为 image 编号,value 为 { sectionIndex, type: 'image'|'audio' }
- const inProgressTimer = ref(null) // 生成中的图片定时器,轮询生成进展
- // 步骤2:生成单个媒体(仅背景图)
- const generateMedia = async (sectionIndex) => {
- const section = scriptData.sections[sectionIndex]
- const media = section.backgroundImage
- // 记录旧的URL
- let oldUrl = null
- if (media.url) {
- oldUrl = media.url
- replacedUrls.value.add(oldUrl)
- }
- media.generating = true
- try {
- const form = {
- platform: AiPlatformEnum.DOU_BAO,
- modelId: 56,
- prompt: media.prompt,
- width: 1024,
- height: 768
- }
- const response = await ImageApi.drawImage(form)
- inProgressImageMap.value[response] = {
- sectionIndex
- }
- } catch (error) {
- console.error(`生成图片失败:`, error)
- media.generating = false
- // 生成失败,从replacedUrls中移除旧URL
- if (oldUrl) {
- replacedUrls.value.delete(oldUrl)
- }
- }
- }
- // 步骤2:一键生成所有背景图
- const generateAllImages = async () => {
- isGeneratingImages.value = true
- try {
- for (let i = 0; i < scriptData.sections.length; i++) {
- const section = scriptData.sections[i]
- // 只处理没有背景图URL的环节
- if (!section.backgroundImage.url) {
- await generateMedia(i)
- }
- }
- // 检查是否有图片正在生成
- const checkImagesComplete = setInterval(() => {
- if (Object.keys(inProgressImageMap.value).length === 0) {
- isGeneratingImages.value = false
- clearInterval(checkImagesComplete)
- }
- }, 1000)
- } catch (error) {
- console.error('生成所有背景图失败:', error)
- isGeneratingImages.value = false
- }
- }
- // 轮询生成中的图片列表
- const refreshWatchImages = async () => {
- const imageIds = Object.keys(inProgressImageMap.value).map(Number)
- if (imageIds.length === 0) {
- return
- }
- try {
- const list = await ImageApi.getImageListMyByIds(imageIds)
- const newWatchImages = {}
- list.forEach((image) => {
- const info = inProgressImageMap.value[image.id]
- if (info) {
- if (image.status === AiImageStatusEnum.IN_PROGRESS) {
- newWatchImages[image.id] = info
- } else if (image.status === AiImageStatusEnum.SUCCESS && image.picUrl) {
- const section = scriptData.sections[info.sectionIndex]
- section.backgroundImage.url = image.picUrl
- section.backgroundImage.generating = false
- } else if (image.status === AiImageStatusEnum.FAIL) {
- const section = scriptData.sections[info.sectionIndex]
- section.backgroundImage.generating = false
- // 生成失败,从replacedUrls中移除旧URL
- if (section.backgroundImage.url) {
- replacedUrls.value.delete(section.backgroundImage.url)
- }
- }
- }
- })
- inProgressImageMap.value = newWatchImages
- } catch (error) {
- console.error('轮询图片状态失败:', error)
- }
- }
- // 播放音频通用函数
- const playAudio = (url, type) => {
- if (audioState.currentAudio) {
- audioState.currentAudio.pause()
- audioState.currentAudio.currentTime = 0
- }
- if (audioState.isPlaying && audioState.currentUrl === url && audioState.currentType === type) {
- if (audioState.currentAudio) {
- audioState.currentAudio.pause()
- }
- audioState.isPlaying = false
- return
- }
- let audio = audioInstances.get(`${type}_${url}`)
- if (!audio) {
- audio = new Audio(url)
- audio.autoplay = false
- audioInstances.set(`${type}_${url}`, audio)
- audio.onended = () => {
- audioState.isPlaying = false
- audioState.currentAudio = null
- audioState.currentUrl = ''
- audioState.currentType = ''
- }
- }
- audio.play().catch((error) => {
- console.error('播放失败:', error)
- audioState.isPlaying = false
- })
- audioState.currentAudio = audio
- audioState.isPlaying = true
- audioState.currentUrl = url
- audioState.currentType = type
- }
- // 播放语音
- const playVoiceover = (voiceoverUrl) => {
- playAudio(voiceoverUrl, 'voice')
- }
- // 处理背景音选择变化
- const handleBackgroundAudioChange = (value, section) => {
- if (value) {
- const selectedMusic = backgroundMusicTypes.value.find((music) => music.id === value)
- if (selectedMusic) {
- section.backgroundAudio.url = selectedMusic.url
- }
- } else {
- section.backgroundAudio.url = ''
- }
- }
- // 播放背景音
- const playBackgroundAudio = (musicType) => {
- const selectedMusic = backgroundMusicTypes.value.find((music) => music.id === musicType)
- const audioUrl = selectedMusic ? selectedMusic.url : `https://example.com/${musicType}.mp3`
- playAudio(audioUrl, 'background')
- }
- // 生成单个语音
- const generateVoiceover = async (sectionIndex, dialogueIndex) => {
- const dialogue = scriptData.sections[sectionIndex].dialogues[dialogueIndex]
- // 只处理数字人、提问和诗词类型的对话
- if (dialogue.type !== 'digital' && dialogue.type !== 'quest' && dialogue.type !== 'poem') {
- return
- }
- // 记录旧的URL
- let oldUrl = null
- if (dialogue.voiceoverUrl) {
- oldUrl = dialogue.voiceoverUrl
- replacedUrls.value.add(oldUrl)
- }
- dialogue.generatingVoiceover = true
- let role = digitalHumans.value.find((r) => r.name === dialogue.roleName)
- try {
- // 根据对话类型设置不同的command
- const command =
- dialogue.type === 'poem' ? '要有感情的朗读诗词语句,要符合诗词的节奏和韵律。' : null
- // 调用后端API将文本转成语音
- // 将返回的URL赋值给对话
- dialogue.voiceoverUrl = await TtsApi.convert({
- roleId: Number(role.id),
- content: dialogue.content,
- command: command
- })
- } catch (error) {
- console.error('生成语音失败:', error)
- // 生成失败,从replacedUrls中移除旧URL
- if (oldUrl) {
- replacedUrls.value.delete(oldUrl)
- }
- } finally {
- dialogue.generatingVoiceover = false
- }
- }
- // 步骤3:一键生成所有语音
- const generateAllVoiceovers = async () => {
- isGeneratingVoiceovers.value = true
- try {
- for (let i = 0; i < scriptData.sections.length; i++) {
- for (let j = 0; j < scriptData.sections[i].dialogues.length; j++) {
- const dialogue = scriptData.sections[i].dialogues[j]
- // 只处理没有语音URL的对话
- if (!dialogue.voiceoverUrl) {
- await generateVoiceover(i, j)
- }
- }
- }
- } catch (error) {
- console.error('生成所有语音失败:', error)
- } finally {
- isGeneratingVoiceovers.value = false
- }
- }
- // 获取角色名称
- const getRoleName = (roleName) => {
- const role = digitalHumans.value.find((r) => r.name === roleName)
- return role ? role.name : '未知角色'
- }
- // 解析 Markdown 文本
- const parseMarkdown = (text) => {
- if (!text) return ''
- return marked(text)
- }
- // 步骤4:校验脚本
- const validateScript = () => {
- let isValid = true
- errorMessages.value = []
- // 检查环节名称、背景图
- scriptData.sections.forEach((section, sectionIndex) => {
- if (!section.name.trim() || !section.backgroundImage.url) {
- errorMessages.value.push(`环节${sectionIndex + 1}:名称或背景图未配置!`)
- isValid = false
- }
- // 检查对话
- section.dialogues.forEach((dialogue, dialogueIndex) => {
- // 只检查数字人、提问和诗词类型的对话
- if (dialogue.type === 'digital' || dialogue.type === 'quest' || dialogue.type === 'poem') {
- if (
- !dialogue.roleName ||
- !dialogue.content.trim() ||
- (dialogue.type !== 'poem' && !dialogue.voiceoverUrl)
- ) {
- errorMessages.value.push(
- `环节${sectionIndex + 1}:对话${dialogueIndex + 1}:存在完成内容!`
- )
- isValid = false
- }
- }
- })
- })
- isValidationPassed.value = isValid
- validationMessage.value = errorMessages.value.length > 0 ? '校验失败' : '校验通过'
- }
- // 步骤4:保存脚本
- const saveScript = async () => {
- validateScript()
- if (!isValidationPassed.value) {
- return
- }
- // 保存脚本后清除缓存
- clearScriptDataCache()
- emit('save', scriptData, [...replacedUrls.value])
- emit('update:visible', false)
- }
- // 下一步操作
- const nextStep = () => {
- if (currentStep.value === 2) {
- validateScript()
- }
- currentStep.value++
- }
- // 显示视频预览
- const showVideoPreview = () => {
- showVideoPreviewModal.value = true
- }
- // 关闭视频预览
- const closeVideoPreview = () => {
- showVideoPreviewModal.value = false
- }
- // 组件挂载时
- onMounted(async () => {
- // 设置初始步骤
- currentStep.value = props.initialStep
- try {
- const params = {
- pageOn: 1,
- pageSize: 100,
- category: '小学低年级',
- publicStatus: true
- }
- const { list } = await ChatRoleApi.getMyPage(params)
- params.category += 'AI'
- const { list: listAi } = await ChatRoleApi.getMyPage(params)
- params.category = '全部'
- const { list: listAll } = await ChatRoleApi.getMyPage(params)
- params.category = '全部-Poet'
- const { list: listAllPoet } = await ChatRoleApi.getMyPage(params)
- listAi.push(...list)
- listAi.push(...listAll)
- listAi.push(...listAllPoet)
- digitalHumans.value = listAi
- } catch (error) {
- console.error('获取角色数据失败:', error)
- }
- inProgressTimer.value = setInterval(async () => {
- await refreshWatchImages()
- }, 3000)
- })
- // 关闭事件
- const emit = defineEmits(['update:visible', 'save'])
- const handleClose = () => {
- emit('update:visible', false)
- }
- // 组件卸载时
- onUnmounted(() => {
- if (inProgressTimer.value) {
- clearInterval(inProgressTimer.value)
- }
- })
- </script>
- <style scoped>
- .course-script-editor {
- width: 100%;
- height: 90vh;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- background-color: #f8f9fa;
- }
- /* 主容器样式 */
- .main-container {
- flex: 1;
- display: flex;
- overflow: hidden;
- }
- /* 左侧步骤指示器样式 */
- .steps-sidebar {
- width: 200px;
- background-color: #f5f7fa;
- border-right: 1px solid #ebeef5;
- padding: 30px 0;
- display: flex;
- align-items: center;
- }
- /* 右侧内容区域样式 */
- .content-area {
- flex: 1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
- /* 步骤内容样式 */
- .step-content {
- flex: 1;
- padding: 20px;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- background-color: white;
- border-radius: 0;
- box-shadow: none;
- }
- /* 步骤1垂直居中 */
- .step-content:has(.ai-input-container) {
- justify-content: center;
- align-items: center;
- }
- /* 编辑器工具栏样式 - 固定顶部 */
- .editor-toolbar.sticky-top {
- position: sticky;
- top: 0;
- z-index: 100;
- margin-top: -20px;
- margin-left: -20px;
- margin-right: -20px;
- border-radius: 0;
- border-bottom: 1px solid #ebeef5;
- background: rgba(250, 250, 250, 0.95);
- backdrop-filter: blur(10px);
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
- }
- /* 脚本编辑器样式 - 可滚动 */
- .script-editor {
- flex: 1;
- overflow-y: auto;
- margin-top: 20px;
- padding-right: 10px;
- background-color: white;
- border-radius: 8px;
- padding: 20px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
- }
- .script-editor::-webkit-scrollbar {
- width: 6px;
- }
- .script-editor::-webkit-scrollbar-track {
- background: #f1f1f1;
- border-radius: 3px;
- }
- .script-editor::-webkit-scrollbar-thumb {
- background: #c1c1c1;
- border-radius: 3px;
- }
- .script-editor::-webkit-scrollbar-thumb:hover {
- background: #a1a1a1;
- }
- /* 步骤导航 */
- .steps-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 20px;
- width: 100%;
- .step-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100%;
- .step-circle {
- width: 32px;
- height: 32px;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-weight: bold;
- margin-bottom: 8px;
- }
- .step-title {
- font-size: 14px;
- text-align: center;
- padding: 0 20px;
- }
- &.process {
- .step-circle {
- background-color: #409eff;
- color: white;
- }
- .step-title {
- color: #409eff;
- }
- }
- &.wait {
- .step-circle {
- background-color: #e4e7ed;
- color: #c0c4cc;
- }
- .step-title {
- color: #c0c4cc;
- }
- }
- &.finish {
- .step-circle {
- background-color: #67c23a;
- color: white;
- }
- .step-title {
- color: #67c23a;
- }
- }
- }
- .step-line {
- width: 2px;
- height: 40px;
- background-color: #e4e7ed;
- &.active {
- background-color: #409eff;
- }
- }
- }
- /* 步骤内容 */
- .step-content {
- background-color: white;
- border-radius: 8px;
- padding: 20px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
- }
- /* 按钮组样式 */
- .button-group {
- display: flex;
- gap: 10px;
- margin-top: 20px;
- justify-content: center;
- }
- /* 次要按钮样式 */
- .generate-btn.secondary {
- background-color: #606266;
- color: white;
- }
- .generate-btn.secondary:hover {
- background-color: #ffaa72;
- color: white;
- }
- /* 对话类型标签 */
- .dialogue-type-tag {
- position: absolute;
- top: -10px;
- left: 10px;
- padding: 2px 8px;
- border-radius: 10px;
- font-size: 12px;
- font-weight: 500;
- color: white;
- }
- /* 隐藏用户回复卡片 */
- .dialogue-item.hidden {
- display: none;
- }
- /* 错误信息项样式 */
- .error-item {
- margin-bottom: 8px;
- line-height: 1.4;
- }
- .dialogue-type-tag.digital {
- background-color: #409eff;
- }
- .dialogue-type-tag.user {
- background-color: #67c23a;
- }
- .dialogue-type-tag.quest {
- background-color: #e6a23c;
- }
- .dialogue-type-tag.poem {
- background-color: #909399;
- }
- /* 对话项样式 */
- .dialogue-item {
- position: relative;
- background-color: #f9f9f9;
- border-radius: 8px;
- padding: 20px;
- margin-bottom: 15px;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
- transition: all 0.3s ease;
- }
- .dialogue-item:hover {
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
- }
- .dialogue-item.digital {
- border-left: 4px solid #409eff;
- }
- .dialogue-item.user {
- border-left: 4px solid #67c23a;
- }
- .dialogue-item.quest {
- border-left: 4px solid #e6a23c;
- }
- /* 对话头部 */
- .dialogue-header {
- margin-bottom: 10px;
- }
- /* 对话行 */
- .dialogue-row {
- display: flex;
- gap: 15px;
- align-items: flex-start;
- }
- /* 角色选择 */
- .dialogue-role-select {
- flex-shrink: 0;
- }
- /* 回复角色选择 */
- .dialogue-reply-select {
- flex-shrink: 0;
- }
- /* 内容容器 */
- .dialogue-content-container {
- flex: 1;
- min-width: 0;
- }
- /* 添加对话按钮容器 */
- .add-dialogue-buttons {
- display: flex;
- gap: 10px;
- margin-top: 15px;
- }
- /* 添加对话按钮 */
- .add-dialogue-btn {
- padding: 8px 16px;
- border: none;
- border-radius: 4px;
- font-size: 14px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.3s ease;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 5px;
- min-width: 120px;
- }
- .add-dialogue-btn.digital {
- background-color: #83c2ff;
- color: white;
- }
- .add-dialogue-btn.digital:hover {
- background-color: #409eff;
- border-color: #4aa2fd;
- color: white;
- }
- .add-dialogue-btn.user {
- background-color: #85ce61;
- color: white;
- }
- .add-dialogue-btn.quest {
- background-color: #e6a23c;
- color: white;
- }
- .add-dialogue-btn.poem {
- background-color: #909399;
- color: white;
- }
- .add-dialogue-btn.quest-user {
- background-color: #e6a23c;
- color: white;
- }
- .add-dialogue-btn.user:hover {
- background-color: #67c23a;
- border-color: #67c23a;
- color: white;
- }
- .add-dialogue-btn.quest:hover {
- background-color: #cf9236;
- border-color: #cf9236;
- color: white;
- }
- .add-dialogue-btn.quest-user:hover {
- background-color: #cf9236;
- border-color: #cf9236;
- color: white;
- }
- .add-dialogue-btn.poem:hover {
- background-color: #73767a;
- border-color: #73767a;
- color: white;
- }
- /* 预览对话样式 */
- .preview-dialogue {
- position: relative;
- margin-bottom: 20px;
- padding: 15px;
- border-radius: 8px;
- background-color: #f9f9f9;
- }
- .preview-dialogue.digital {
- border-left: 4px solid #409eff;
- }
- .preview-dialogue.user {
- border-left: 4px solid #67c23a;
- }
- .preview-dialogue.quest {
- border-left: 4px solid #e6a23c;
- }
- .preview-dialogue.poem {
- border-left: 4px solid #909399;
- }
- .preview-dialogue .dialogue-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 0;
- margin-bottom: 10px;
- }
- .preview-dialogue .dialogue-header-left {
- display: flex;
- align-items: center;
- gap: 2px;
- }
- .preview-dialogue .dialogue-type-tag {
- position: static;
- margin-right: 2px;
- }
- /* 回复信息 */
- .reply-info {
- margin-top: 10px;
- padding-top: 10px;
- border-top: 1px solid #e8e8e8;
- font-size: 14px;
- color: #666;
- font-style: italic;
- }
- /* AI输入容器 */
- .ai-input-container {
- max-width: 800px;
- margin: 0 auto;
- padding: 30px;
- background: white;
- border-radius: 16px;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
- display: flex;
- flex-direction: column;
- min-height: 500px;
- }
- .selection-group {
- margin-bottom: 30px;
- }
- .ai-input-wrapper {
- margin-bottom: 30px;
- }
- .ai-input-container .button-group {
- display: flex;
- gap: 10px;
- margin-top: 30px;
- justify-content: center;
- }
- .ai-input-container .button-group button {
- flex: 1;
- min-width: 200px;
- text-align: center;
- }
- .ai-input-wrapper {
- position: relative;
- margin-bottom: 30px;
- }
- .ai-icon {
- position: absolute;
- top: 20px;
- left: 20px;
- font-size: 28px;
- color: #409eff;
- background: rgba(64, 158, 255, 0.1);
- width: 48px;
- height: 48px;
- border-radius: 12px;
- display: flex;
- align-items: center;
- justify-content: center;
- animation: pulse 2s infinite;
- }
- @keyframes pulse {
- 0% {
- box-shadow: 0 0 0 0 rgba(64, 158, 255, 0.4);
- }
- 70% {
- box-shadow: 0 0 0 10px rgba(64, 158, 255, 0);
- }
- 100% {
- box-shadow: 0 0 0 0 rgba(64, 158, 255, 0);
- }
- }
- .ai-textarea {
- width: 100%;
- min-height: 140px;
- padding: 24px 24px 24px 84px;
- border: 2px solid #e8e8e8;
- border-radius: 16px;
- font-size: 16px;
- resize: vertical;
- transition: all 0.3s ease;
- background: #fafafa;
- line-height: 1.6;
- }
- .ai-textarea:focus {
- outline: none;
- border-color: #409eff;
- background: white;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .selection-group {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 24px;
- margin-bottom: 30px;
- }
- .selection-item {
- display: flex;
- flex-direction: column;
- gap: 10px;
- }
- .selection-item label {
- font-weight: 600;
- color: #333;
- font-size: 14px;
- text-transform: uppercase;
- letter-spacing: 0.5px;
- color: #666;
- }
- .selection-item select {
- padding: 14px 16px;
- border: 2px solid #e8e8e8;
- border-radius: 10px;
- font-size: 14px;
- transition: all 0.3s ease;
- background: white;
- }
- .selection-item select:focus {
- outline: none;
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .multi-select {
- display: flex;
- flex-wrap: wrap;
- gap: 10px;
- padding: 12px;
- border: 2px solid #e8e8e8;
- border-radius: 10px;
- background: white;
- transition: all 0.3s ease;
- }
- .multi-select:focus-within {
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .select-option {
- padding: 8px 16px;
- background: #f5f5f5;
- border-radius: 20px;
- cursor: pointer;
- transition: all 0.2s ease;
- font-size: 14px;
- font-weight: 500;
- border: 1px solid transparent;
- }
- .select-option:hover {
- background: #e6f7ff;
- border-color: #91d5ff;
- }
- .select-option.selected {
- background: #409eff;
- color: white;
- border-color: #409eff;
- box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
- }
- /* 加载遮挡层样式 */
- .loading-overlay {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.1);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 9999;
- pointer-events: auto;
- }
- .loading-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 16px;
- background: white;
- padding: 32px;
- border-radius: 12px;
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
- pointer-events: auto;
- }
- .loading-spinner {
- width: 48px;
- height: 48px;
- border: 4px solid #f3f3f3;
- border-top: 4px solid #409eff;
- border-radius: 50%;
- animation: spin 1s linear infinite;
- }
- @keyframes spin {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(360deg);
- }
- }
- .loading-text {
- font-size: 16px;
- font-weight: 500;
- color: #333;
- }
- /* 按钮样式 */
- .generate-btn {
- padding: 14px 8px;
- border: none;
- border-radius: 8px;
- font-size: 14px;
- font-weight: 400;
- cursor: pointer;
- transition: all 0.3s ease;
- position: relative;
- overflow: hidden;
- }
- .generate-btn.primary {
- background: linear-gradient(135deg, #409eff, #1890ff);
- color: white;
- box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
- }
- .generate-btn.primary:hover {
- transform: translateY(-2px);
- box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
- }
- .generate-btn.primary:disabled {
- background: #91c5f7;
- cursor: not-allowed;
- transform: none;
- box-shadow: none;
- }
- .generate-btn.small {
- padding: 8px 16px;
- font-size: 14px;
- border-radius: 8px;
- }
- .generate-btn.small:hover {
- transform: translateY(-1px);
- box-shadow: 0 3px 8px rgba(64, 158, 255, 0.3);
- }
- .generate-btn.small:disabled {
- background: #91c5f7;
- color: white;
- cursor: not-allowed;
- transform: none;
- box-shadow: none;
- }
- .toolbar-btn:disabled {
- background: #f0f0f0;
- color: #c0c0c0;
- border-color: #e0e0e0;
- cursor: not-allowed;
- transform: none;
- box-shadow: none;
- }
- .toolbar-btn:disabled:hover {
- background: #f0f0f0;
- color: #c0c0c0;
- border-color: #e0e0e0;
- transform: none;
- box-shadow: none;
- }
- /* 编辑器工具栏 */
- .editor-toolbar {
- position: sticky;
- top: 20px;
- z-index: 100;
- margin-bottom: 30px;
- padding: 16px 20px;
- background: rgba(250, 250, 250, 0.95);
- backdrop-filter: blur(10px);
- border-radius: 12px;
- border: 1px solid #e8e8e8;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
- overflow-x: auto;
- overflow-y: hidden;
- white-space: nowrap;
- }
- .editor-toolbar::-webkit-scrollbar {
- height: 4px;
- }
- .editor-toolbar::-webkit-scrollbar-track {
- background: #f1f1f1;
- border-radius: 2px;
- }
- .editor-toolbar::-webkit-scrollbar-thumb {
- background: #c1c1c1;
- border-radius: 2px;
- }
- .editor-toolbar::-webkit-scrollbar-thumb:hover {
- background: #a1a1a1;
- }
- .toolbar-btn {
- padding: 12px 24px;
- margin: 0 12px;
- background: white;
- border: 2px solid #e8e8e8;
- border-radius: 10px;
- cursor: pointer;
- transition: all 0.3s ease;
- font-weight: 500;
- color: #333;
- }
- .toolbar-btn:hover {
- background: #409eff;
- color: white;
- border-color: #409eff;
- transform: translateY(-1px);
- box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
- }
- /* 脚本编辑器 */
- .script-section {
- margin-top: 40px;
- margin-bottom: 40px;
- padding: 5px 24px 24px;
- background: white;
- border-radius: 16px;
- position: relative;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
- border: 1px solid #f0f0f0;
- }
- .section-header {
- margin-bottom: 24px;
- display: flex;
- align-items: center;
- gap: 16px;
- }
- .section-name-container {
- display: flex;
- align-items: center;
- flex: 1;
- gap: 12px;
- margin-top: 16px;
- }
- .remove-section-btn {
- background: #ff4d4f;
- border: none;
- color: white;
- font-size: 16px;
- cursor: pointer;
- padding: 0;
- width: 28px;
- height: 28px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 6px;
- transition: all 0.3s ease;
- flex-shrink: 0;
- }
- .remove-section-btn:hover {
- background: #ff7875;
- transform: scale(1.1);
- box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
- }
- .section-name-label {
- padding: 2px 15px;
- border-radius: 10px;
- font-size: 18px;
- font-weight: 500;
- color: white;
- background-color: #c18484;
- white-space: nowrap;
- display: flex;
- align-items: center;
- height: 44px;
- box-sizing: border-box;
- }
- .section-title {
- flex: 1;
- padding: 14px 16px;
- border: 2px solid #e8e8e8;
- border-radius: 10px;
- font-size: 16px;
- font-weight: 500;
- transition: all 0.3s ease;
- }
- .section-title:focus {
- outline: none;
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .media-controls {
- display: flex;
- background: linear-gradient(135deg, #f8f9fa, #ffffff);
- padding: 16px 20px;
- border-radius: 10px;
- border: 1px solid #e8e8e8;
- align-items: center;
- justify-content: space-between;
- }
- .media-item {
- display: flex;
- align-items: center;
- gap: 10px;
- margin-right: 50px;
- }
- .media-input-group {
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .media-label {
- font-size: 14px;
- font-weight: 600;
- white-space: nowrap;
- color: #666;
- }
- .media-prompt {
- font-size: 14px;
- transition: all 0.3s ease;
- width: 300px;
- }
- .media-prompt .el-textarea {
- width: 100%;
- min-height: 60px;
- }
- .media-prompt .el-textarea__inner {
- padding: 8px 12px;
- border: 2px solid #e8e8e8;
- border-radius: 8px;
- font-size: 14px;
- transition: all 0.3s ease;
- min-height: 60px;
- resize: none;
- }
- .media-prompt .el-textarea__inner:focus {
- outline: none;
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .media-preview {
- margin-top: 12px;
- margin-left: 20px;
- }
- .media-preview img {
- max-width: 180px;
- border-radius: 8px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
- transition: transform 0.3s ease;
- }
- .media-preview img:hover {
- transform: scale(1.05);
- }
- .dialogues-container {
- margin-top: 48px;
- }
- .dialogue-item {
- margin-bottom: 20px;
- padding: 20px;
- background: #fafafa;
- border-radius: 12px;
- border: 1px solid #e8e8e8;
- transition: all 0.3s ease;
- }
- .dialogue-item:hover {
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
- transform: translateY(-2px);
- }
- .dialogue-row {
- display: flex;
- align-items: flex-start;
- gap: 16px;
- }
- .dialogue-role-select {
- min-width: 140px;
- }
- .dialogue-role-select select {
- width: 100%;
- padding: 10px 12px;
- border: 2px solid #e8e8e8;
- border-radius: 8px;
- font-size: 14px;
- transition: all 0.3s ease;
- }
- .dialogue-role-select select:focus {
- outline: none;
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .dialogue-content-container {
- flex: 1;
- }
- .dialogue-content:focus {
- outline: none;
- border-color: #409eff;
- box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
- }
- .remove-btn {
- background: #ff4d4f;
- border: none;
- color: white;
- font-size: 16px;
- cursor: pointer;
- padding: 0;
- width: 28px;
- height: 28px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 6px;
- transition: all 0.3s ease;
- flex-shrink: 0;
- }
- .remove-btn:hover {
- background: #ff7875;
- transform: scale(1.1);
- box-shadow: 0 2px 8px rgba(255, 77, 79, 0.3);
- }
- .dialogue-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 8px;
- }
- .dialogue-text {
- flex: 1;
- width: 100%;
- font-size: 16px;
- line-height: 1.6;
- }
- .generate-btn.small {
- padding: 8px;
- background: linear-gradient(135deg, #409eff, #1890ff);
- color: white;
- border: none;
- border-radius: 6px;
- cursor: pointer;
- transition: all 0.3s ease;
- display: flex;
- align-items: center;
- justify-content: center;
- height: 28px;
- font-size: 14px;
- }
- .generate-btn.small:hover {
- transform: scale(1.1);
- box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
- }
- .play-btn {
- padding: 8px;
- background: #52c41a;
- color: white;
- border: none;
- border-radius: 6px;
- cursor: pointer;
- transition: all 0.3s ease;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 28px;
- height: 28px;
- font-size: 14px;
- }
- .play-btn:hover {
- background: #73d13d;
- transform: scale(1.1);
- box-shadow: 0 2px 8px rgba(82, 196, 26, 0.3);
- }
- .play-btn.small {
- padding: 8px;
- width: 28px;
- height: 28px;
- font-size: 14px;
- }
- .voice-icon {
- font-size: 14px;
- line-height: 1;
- }
- .play-icon {
- font-size: 14px;
- line-height: 1;
- }
- .action-buttons {
- display: flex;
- flex-direction: column;
- gap: 8px;
- margin-left: 8px;
- }
- .action-buttons-row {
- display: flex;
- gap: 8px;
- align-items: center;
- justify-content: flex-end;
- }
- .add-dialogue-btn,
- .add-section-btn {
- padding: 12px 24px;
- background: white;
- border: 2px dashed #d9d9d9;
- border-radius: 10px;
- cursor: pointer;
- transition: all 0.3s ease;
- font-weight: 500;
- color: #666;
- margin-top: 16px;
- width: 100%;
- text-align: center;
- }
- .add-dialogue-btn:hover,
- .add-section-btn:hover {
- border-color: #c18484;
- color: white;
- background: rgba(193, 132, 132, 0.6);
- transform: translateY(-1px);
- box-shadow: 0 4px 12px rgba(64, 158, 255, 0.15);
- }
- /* 预览页面 */
- .preview-container {
- width: 100%;
- height: 100%;
- background: white;
- border-radius: 16px;
- padding: 30px;
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
- display: flex;
- flex-direction: column;
- }
- .scrollable-content {
- flex: 1;
- overflow-y: auto;
- margin-bottom: 20px;
- padding-right: 10px;
- }
- .scrollable-content::-webkit-scrollbar {
- width: 6px;
- }
- .scrollable-content::-webkit-scrollbar-track {
- background: #f1f1f1;
- border-radius: 3px;
- }
- .scrollable-content::-webkit-scrollbar-thumb {
- background: #c1c1c1;
- border-radius: 3px;
- }
- .scrollable-content::-webkit-scrollbar-thumb:hover {
- background: #a1a1a1;
- }
- .preview-content {
- margin-top: 20px;
- margin-bottom: 30px;
- }
- .preview-actions {
- margin-top: auto;
- display: flex;
- justify-content: flex-end;
- gap: 12px;
- }
- .validation-result {
- padding: 16px 20px;
- border-radius: 10px;
- font-weight: 500;
- font-size: 14px;
- }
- .validation-result.valid {
- background: #f6ffed;
- border: 2px solid #b7eb8f;
- color: #52c41a;
- box-shadow: 0 2px 8px rgba(82, 196, 26, 0.1);
- }
- .validation-result.invalid {
- background: #fff2f0;
- border: 2px solid #ffccc7;
- color: #ff4d4f;
- box-shadow: 0 2px 8px rgba(255, 77, 79, 0.1);
- }
- .preview-section {
- margin-bottom: 40px;
- padding: 40px;
- border-radius: 12px;
- border: 1px solid #e8e8e8;
- min-height: 300px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .preview-section h4 {
- margin-top: 0;
- color: #333;
- font-size: 18px;
- font-weight: 600;
- margin-bottom: 20px;
- }
- .preview-section-content {
- background: rgba(255, 255, 255, 0.2);
- padding: 20px;
- border-radius: 12px;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
- backdrop-filter: blur(5px);
- width: 80%;
- }
- .preview-media {
- margin: 20px 0;
- padding: 16px;
- background: rgba(255, 255, 255, 0.8);
- border-radius: 10px;
- border: 1px solid #e8e8e8;
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex-wrap: wrap;
- }
- .preview-media-left {
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .preview-media-right {
- display: flex;
- align-items: center;
- gap: 12px;
- }
- .preview-image img {
- max-width: 250px;
- border-radius: 8px;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
- transition: transform 0.3s ease;
- }
- .preview-image img:hover {
- transform: scale(1.05);
- }
- .preview-audio {
- float: right;
- margin-right: 20px;
- display: flex;
- align-items: center;
- gap: 8px;
- }
- .preview-dialogue {
- margin-bottom: 20px;
- padding: 16px;
- background: white;
- border-radius: 10px;
- border: 1px solid #e8e8e8;
- transition: all 0.3s ease;
- }
- .dialogue-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 8px;
- }
- .preview-dialogue:hover {
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
- }
- .dialogue-role {
- font-weight: 600;
- color: #409eff;
- font-size: 14px;
- }
- .dialogue-text {
- line-height: 1.6;
- font-size: 14px;
- color: #333;
- }
- /* Markdown 样式 */
- .dialogue-text h1,
- .dialogue-text h2,
- .dialogue-text h3,
- .dialogue-text h4,
- .dialogue-text h5,
- .dialogue-text h6 {
- margin: 16px 0 8px 0;
- font-weight: 600;
- line-height: 1.2;
- }
- .dialogue-text h1 {
- font-size: 24px;
- }
- .dialogue-text h2 {
- font-size: 20px;
- }
- .dialogue-text h3 {
- font-size: 18px;
- }
- .dialogue-text h4 {
- font-size: 16px;
- }
- .dialogue-text h5 {
- font-size: 14px;
- }
- .dialogue-text h6 {
- font-size: 12px;
- }
- .dialogue-text p {
- margin: 8px 0;
- }
- .dialogue-text ul,
- .dialogue-text ol {
- margin: 8px 0;
- padding-left: 24px;
- }
- .dialogue-text li {
- margin: 4px 0;
- }
- .dialogue-text strong {
- font-weight: 600;
- }
- .dialogue-text em {
- font-style: italic;
- }
- .dialogue-text a {
- color: #409eff;
- text-decoration: none;
- }
- .dialogue-text a:hover {
- text-decoration: underline;
- }
- .dialogue-text code {
- background: #f5f5f5;
- padding: 2px 4px;
- border-radius: 4px;
- font-family: 'Courier New', Courier, monospace;
- font-size: 14px;
- }
- .dialogue-text pre {
- background: #f5f5f5;
- padding: 12px;
- border-radius: 8px;
- overflow-x: auto;
- margin: 12px 0;
- }
- .dialogue-text pre code {
- background: none;
- padding: 0;
- }
- .voiceover-preview {
- margin-top: 12px;
- padding-top: 12px;
- border-top: 1px solid #f0f0f0;
- }
- .preview-actions {
- display: flex;
- justify-content: center;
- gap: 20px;
- padding-top: 24px;
- border-top: 1px solid #e8e8e8;
- }
- .primary-btn,
- .secondary-btn {
- padding: 14px 32px;
- border: none;
- border-radius: 12px;
- font-size: 16px;
- font-weight: 600;
- cursor: pointer;
- transition: all 0.3s ease;
- position: relative;
- overflow: hidden;
- }
- .primary-btn {
- background: linear-gradient(135deg, #409eff, #1890ff);
- color: white;
- box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
- }
- .primary-btn:hover {
- transform: translateY(-2px);
- box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
- }
- .primary-btn:disabled {
- background: #91c5f7;
- cursor: not-allowed;
- transform: none;
- box-shadow: none;
- }
- .secondary-btn {
- background: white;
- color: #333;
- border: 2px solid #e8e8e8;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
- }
- .secondary-btn:hover {
- background: #fafafa;
- border-color: #409eff;
- color: #409eff;
- transform: translateY(-2px);
- box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
- }
- </style>
|