index.vue 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630
  1. <template>
  2. <div class="pptist-student-viewer" :class="{ 'fullscreen': isFullscreen, 'laser-pen': laserPen }">
  3. <!-- Loading状态显示 -->
  4. <div v-if="isLoading" class="loading-overlay">
  5. <div class="loading-content">
  6. <div class="loading-spinner"></div>
  7. <div class="loading-text">正在加载课程内容...</div>
  8. </div>
  9. </div>
  10. <!-- 左侧导航栏 -->
  11. <div class="layout-content-left" v-show="type == '1'" :class="{ collapsed: slidePanelCollapsed }">
  12. <div class="thumbnails">
  13. <div class="viewer-header slide-header">
  14. <h3 v-show="!slidePanelCollapsed">幻灯片导航</h3>
  15. <button class="collapse-btn" @click="slidePanelCollapsed = !slidePanelCollapsed" :title="slidePanelCollapsed ? '展开' : '收起'">
  16. <span v-if="slidePanelCollapsed">›</span>
  17. <span v-else>‹</span>
  18. </button>
  19. </div>
  20. <div v-show="!slidePanelCollapsed">
  21. <div class="thumbnail-list">
  22. <div v-for="(slide, index) in slides" :key="slide.id" class="thumbnail-item"
  23. :class="{ 'active': slideIndex === index }" @click="goToSlide(index)">
  24. <div class="label">{{ fillDigit(index + 1, 2) }}</div>
  25. <ThumbnailSlide class="thumbnail" :slide="slide" :size="168" :visible="true" @click="goToSlide(index)" />
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <!-- 中间放映区域 -->
  32. <div class="layout-content-center">
  33. <div class="viewer-header" :class="{ 'hidden': isFullscreen }">
  34. <div class="slide-title">幻灯片 {{ slideIndex + 1 }}</div>
  35. <div class="viewer-controls">
  36. <button @click="previousSlide" :disabled="slideIndex === 0" title="上一页" v-if="!isFollowModeActive || props.type == '1'">
  37. <IconLeftTwo class="control-icon" />
  38. </button>
  39. <button @click="nextSlide" :disabled="slideIndex === slides.length - 1" title="下一页" v-if="!isFollowModeActive || props.type == '1'">
  40. <IconRightTwo class="control-icon" />
  41. </button>
  42. <!-- <button @click="resetZoom" title="重置缩放">
  43. <IconUndo class="control-icon" />
  44. </button> -->
  45. <button @click="enterFullscreen" title="全屏">
  46. <IconFullScreenOne class="control-icon" />
  47. </button>
  48. <!-- 只有创建人才显示跟随模式按钮 -->
  49. <button
  50. v-if="isCreator"
  51. @click="toggleFollowMode"
  52. :class="{ 'follow-active': isFollowModeActive }"
  53. >
  54. {{ isFollowModeActive ? '关闭跟随模式' : '开启跟随模式' }}
  55. </button>
  56. <!-- <button @click="backToEditor" class="back-btn" title="返回编辑">
  57. <IconEdit class="control-icon" />
  58. </button> -->
  59. </div>
  60. </div>
  61. <div class="viewer-canvas" ref="viewerCanvasRef">
  62. <!-- 全屏时:使用放映功能 -->
  63. <!-- <ScreenSlideList :slideWidth="slideWidth"
  64. :slideHeight="slideHeight" :animationIndex="0" :turnSlideToId="() => { }"
  65. :manualExitFullscreen="() => { }" /> -->
  66. <!-- 不全屏时:使用编辑模式的显示比例和居中逻辑 -->
  67. <div class="slide-list-wrap" :style="{
  68. width: isFullscreen ? '100%' : (slideWidth * canvasScale) + 'px',
  69. height: isFullscreen ? '100%' : (slideHeight * canvasScale) + 'px',
  70. left: isFullscreen ? '0' : `${(containerWidth - slideWidth * canvasScale) / 2}px`,
  71. top: isFullscreen ? '0' : `${(containerHeight - slideHeight * canvasScale) / 2}px`
  72. }">
  73. <div class="viewport" v-if="false">
  74. <div class="background" :style="backgroundStyle"></div>
  75. <ScreenElement v-for="(element, index) in elementList" :key="element.id" :elementInfo="element"
  76. :elementIndex="index + 1" :animationIndex="0" :turnSlideToId="() => { }"
  77. :manualExitFullscreen="() => { }" />
  78. </div>
  79. <ScreenSlideList :slideWidth="slideWidth * canvasScale" :slideHeight="slideHeight * canvasScale"
  80. :animationIndex="0" :turnSlideToId="() => { }" :manualExitFullscreen="() => { }" />
  81. </div>
  82. <!-- 全屏时的左右下角工具按钮 -->
  83. <div v-if="isFullscreen && (!isFollowModeActive || props.type == '1')" class="tools-left">
  84. <IconLeftTwo class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="previousSlide" />
  85. <IconRightTwo class="tool-btn" theme="two-tone" :fill="['#111', '#fff']" @click="nextSlide" />
  86. </div>
  87. <!-- 作业提交按钮 - 当当前幻灯片包含iframe时显示 -->
  88. <div v-if="currentSlideHasIframe" class="homework-submit-btn" :class="{ 'submitting': isSubmitting }"
  89. :style="{ right: getHomeworkButtonRight() + 'px' }" @click="handleHomeworkSubmit"
  90. v-tooltip="isSubmitting ? '作业提交中...' : '作业提交'">
  91. <IconEdit v-if="!isSubmitting" class="tool-btn" />
  92. <div v-else class="loading-spinner"></div>
  93. <span class="btn-text">{{ isSubmitting ? '提交中...' : '作业提交' }}</span>
  94. </div>
  95. <!-- 刷新iframe按钮 -->
  96. <div class="refresh-page-btn"
  97. v-if="currentSlideHasIframe"
  98. :style="{ right: getRefreshButtonRight() + 'px' }"
  99. @click="handleRefreshPage"
  100. v-tooltip="'刷新iframe内容'">
  101. <Refresh class="tool-btn" />
  102. <span class="btn-text">刷新</span>
  103. </div>
  104. <!-- 功能组件 -->
  105. <SlideThumbnails v-if="slideThumbnailModelVisible" :turnSlideToIndex="goToSlide"
  106. @close="slideThumbnailModelVisible = false" />
  107. <WritingBoardTool :slideWidth="slideWidth" :slideHeight="slideHeight" v-if="writingBoardToolVisible"
  108. @close="writingBoardToolVisible = false" />
  109. <CountdownTimer v-if="timerlVisible" @close="timerlVisible = false" />
  110. <div v-if="isFullscreen && (!isFollowModeActive || props.type == '1')" class="tools-right" :class="{ 'visible': rightToolsVisible }"
  111. @mouseleave="rightToolsVisible = false" @mouseenter="rightToolsVisible = true">
  112. <div class="content">
  113. <div class="tool-btn page-number" @click="slideThumbnailModelVisible = true">幻灯片 {{ slideIndex +
  114. 1 }} / {{ slides.length }}</div>
  115. <IconWrite class="tool-btn" v-tooltip="'画笔工具'" @click="writingBoardToolVisible = true" />
  116. <IconMagic class="tool-btn" v-tooltip="'激光笔'" :class="{ 'active': laserPen }" @click="toggleLaserPen" />
  117. <IconStopwatchStart class="tool-btn" v-tooltip="'计时器'" @click="timerlVisible = !timerlVisible" />
  118. <IconOffScreenOne class="tool-btn" v-tooltip="'退出全屏'" @click="enterFullscreen" />
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="layout-content-right" v-show="type == '1'" :class="{ collapsed: workPanelCollapsed }">
  124. <div class="thumbnails">
  125. <div class="viewer-header right-panel-header">
  126. <h3 v-show="!workPanelCollapsed">{{
  127. rightPanelMode === 'homework' ? '作业区' :
  128. rightPanelMode === 'dialogue' ? '对话区' : '统计'
  129. }}</h3>
  130. <button class="collapse-btn" @click="workPanelCollapsed = !workPanelCollapsed" :title="workPanelCollapsed ? '展开' : '收起'">
  131. <span v-if="workPanelCollapsed">›</span>
  132. <span v-else>‹</span>
  133. </button>
  134. </div>
  135. <!-- 侧边导航标签 - 无论展开还是收缩都显示在左侧 -->
  136. <div class="side-nav-tabs">
  137. <button
  138. v-if="currentSlideHasIframe"
  139. class="side-nav-btn"
  140. :class="{ active: rightPanelMode === 'homework' }"
  141. @click="switchToHomework"
  142. title="作业"
  143. >
  144. <img :src="rightPanelMode === 'homework' ? homeworkActiveIcon : homeworkIcon" alt="作业">
  145. </button>
  146. <button
  147. v-if="isChoiceQuestion"
  148. class="side-nav-btn"
  149. :class="{ active: rightPanelMode === 'choice' }"
  150. @click="switchToChoice"
  151. title="统计"
  152. >
  153. <img :src="rightPanelMode === 'choice' ? choiceActiveIcon : choiceIcon" alt="统计">
  154. </button>
  155. <button
  156. class="side-nav-btn"
  157. :class="{ active: rightPanelMode === 'dialogue' }"
  158. @click="switchToDialogue"
  159. title="对话"
  160. >
  161. <img :src="rightPanelMode === 'dialogue' ? dialogueActiveIcon : dialogueIcon" alt="对话">
  162. </button>
  163. </div>
  164. <!-- 作业区内容 -->
  165. <div v-show="!workPanelCollapsed && rightPanelMode === 'homework'" class="panel-content">
  166. <div class="homework-title">已提交</div>
  167. <div v-if="workLoading" class="homework-loading">正在加载作业...</div>
  168. <div v-else>
  169. <div v-if="workArray && workArray.length" class="homework-grid">
  170. <button class="homework-btn" v-for="(work, idx) in workArray" :key="work.id ?? idx" :title="work.name" @click="openWorkModal(work)">
  171. <span class="homework-btn__text">{{ work.name }}</span>
  172. </button>
  173. </div>
  174. <div class="homework-empty" v-else>
  175. 暂无作业提交
  176. </div>
  177. </div>
  178. <!-- 未提交作业的学生列表 -->
  179. <div v-if="unsubmittedStudents && unsubmittedStudents.length > 0" class="homework-title" style="margin-top: 20px;">未提交</div>
  180. <div v-if="unsubmittedStudents && unsubmittedStudents.length > 0">
  181. <div v-if="studentLoading" class="homework-loading">正在加载学生信息...</div>
  182. <div v-else>
  183. <div class="homework-grid">
  184. <button class="homework-btn unsubmitted" v-for="(student, idx) in unsubmittedStudents" :key="student.id ?? idx" :title="student.name" disabled>
  185. <span class="homework-btn__text">{{ student.name }}</span>
  186. </button>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. <!-- 对话区内容 -->
  192. <div v-show="!workPanelCollapsed && rightPanelMode === 'dialogue'" class="panel-content">
  193. <DialoguePanel :userid="props.userid" :courseid="props.courseid"/>
  194. </div>
  195. <!-- 选择题统计内容 -->
  196. <div v-show="!workPanelCollapsed && rightPanelMode === 'choice'" class="panel-content">
  197. <ChoiceStatistics :workArray="workArray" :elementList="elementList" />
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <ShotWorkModal v-model:visible="visibleShot" :work="selectedWork" />
  203. <QAWorkModal v-model:visible="visibleQA" :work="selectedWork" />
  204. <ChoiceWorkModal v-model:visible="visibleChoice" :work="selectedWork" />
  205. <AIWorkModal v-model:visible="visibleAI" :work="selectedWork" />
  206. </template>
  207. <script lang="ts" setup>
  208. import { computed, ref, onMounted, onUnmounted, nextTick, inject, watch } from 'vue'
  209. import { storeToRefs } from 'pinia'
  210. import { useSlidesStore } from '@/store'
  211. import { ElementTypes } from '@/types/slides'
  212. import { fillDigit } from '@/utils/common'
  213. import ThumbnailSlide from '@/views/components/ThumbnailSlide/index.vue'
  214. import ScreenSlideList from '@/views/Screen/ScreenSlideList.vue'
  215. import ScreenElement from '@/views/Screen/ScreenElement.vue'
  216. import SlideThumbnails from '@/views/Screen/SlideThumbnails.vue'
  217. import WritingBoardTool from '@/views/Screen/WritingBoardTool.vue'
  218. import CountdownTimer from '@/views/Screen/CountdownTimer.vue'
  219. import useSlideBackgroundStyle from '@/hooks/useSlideBackgroundStyle'
  220. import useImport from '@/hooks/useImport'
  221. import message from '@/utils/message'
  222. import api from '@/services/course'
  223. import ShotWorkModal from './components/ShotWorkModal.vue'
  224. import QAWorkModal from './components/QAWorkModal.vue'
  225. import ChoiceWorkModal from './components/ChoiceWorkModal.vue'
  226. import AIWorkModal from './components/AIWorkModal.vue'
  227. import DialoguePanel from './components/DialoguePanel.vue'
  228. import ChoiceStatistics from './components/ChoiceStatistics.vue'
  229. import * as Y from 'yjs'
  230. import { WebsocketProvider } from 'y-websocket'
  231. import { Refresh } from '@icon-park/vue-next'
  232. // 导入图片资源
  233. import homeworkIcon from '@/assets/img/homework.png'
  234. import homeworkActiveIcon from '@/assets/img/homework-active.png'
  235. import dialogueIcon from '@/assets/img/dialogue.png'
  236. import dialogueActiveIcon from '@/assets/img/dialogue-active.png'
  237. import choiceIcon from '@/assets/img/choice.png'
  238. import choiceActiveIcon from '@/assets/img/choice-active.png'
  239. // 定义组件props
  240. interface Props {
  241. courseid?: string | null
  242. userid?: string | null
  243. oid?: string | null
  244. org?: string | null
  245. cid?: string | null
  246. type?: string | null
  247. }
  248. const props = withDefaults(defineProps<Props>(), {
  249. courseid: null,
  250. userid: null,
  251. oid: null,
  252. org: null,
  253. cid: null,
  254. type: null,
  255. })
  256. // 图标组件通过全局注册,无需导入
  257. const slidesStore = useSlidesStore()
  258. const { slides, slideIndex, currentSlide, viewportSize, viewportRatio } = storeToRefs(slidesStore)
  259. // 添加容器引用,用于计算幻灯片尺寸
  260. const viewerCanvasRef = ref<HTMLElement>()
  261. // 放映相关的状态
  262. const canvasScale = ref(1) // 画布缩放比例
  263. const isFullscreen = ref(false) // 是否全屏
  264. const containerWidth = ref(0) // 容器宽度
  265. const containerHeight = ref(0) // 容器高度
  266. // 全屏工具相关状态
  267. const rightToolsVisible = ref(false)
  268. const writingBoardToolVisible = ref(false)
  269. const timerlVisible = ref(false)
  270. const slideThumbnailModelVisible = ref(false)
  271. const laserPen = ref(false)
  272. // 作业提交状态
  273. const isSubmitting = ref(false)
  274. // 控制组件显示的开关
  275. const showSlideList = ref(true)
  276. const slideWidth = ref(0)
  277. const slideHeight = ref(0)
  278. // 添加loading状态
  279. const isLoading = ref(false)
  280. const workLoading = ref(false)
  281. const studentLoading = ref(false)
  282. // 作业数组
  283. type WorkItem = {
  284. id?: string | number
  285. name: string
  286. type: number | string
  287. [key: string]: any
  288. }
  289. const workArray = ref<WorkItem[]>([])
  290. // 作业弹窗相关
  291. const selectedWork = ref<any>(null)
  292. const visibleShot = ref(false)
  293. const visibleQA = ref(false)
  294. const visibleChoice = ref(false)
  295. const visibleAI = ref(false)
  296. // 作业区收缩状态
  297. const workPanelCollapsed = ref(false)
  298. // 幻灯片导航收缩状态
  299. const slidePanelCollapsed = ref(false)
  300. // 右侧面板当前显示的内容:'homework' | 'dialogue' | 'choice'
  301. const rightPanelMode = ref<'homework' | 'dialogue' | 'choice'>('homework')
  302. // 移除定时器相关代码,改用socket监听
  303. const courseDetail = ref<any>({})
  304. const studentArray = ref<any>([])
  305. // 跟随模式相关状态
  306. const isCreator = ref(false) // 是否为创建人
  307. const isFollowModeActive = ref(false) // 跟随模式是否开启
  308. // 计算未提交作业的学生
  309. const unsubmittedStudents = computed(() => {
  310. if (!studentArray.value || !workArray.value) return []
  311. // 获取已提交作业的学生姓名
  312. const submittedNames = workArray.value.map(work => work.name)
  313. // 过滤出未提交作业的学生
  314. return studentArray.value.filter((student: any) => !submittedNames.includes(student.name))
  315. })
  316. const docSocket = ref<Y.Doc | null>(null)
  317. const yMessage = ref<any | null>(null)
  318. const providerSocket = ref<WebsocketProvider | null>(null)
  319. const mId = ref<string | null>(null)
  320. // 切换到作业区
  321. const switchToHomework = () => {
  322. rightPanelMode.value = 'homework'
  323. if (workPanelCollapsed.value) {
  324. workPanelCollapsed.value = false
  325. }
  326. }
  327. // 切换到对话区
  328. const switchToDialogue = () => {
  329. rightPanelMode.value = 'dialogue'
  330. if (workPanelCollapsed.value) {
  331. workPanelCollapsed.value = false
  332. }
  333. }
  334. // 切换到选择题统计
  335. const switchToChoice = () => {
  336. rightPanelMode.value = 'choice'
  337. if (workPanelCollapsed.value) {
  338. workPanelCollapsed.value = false
  339. }
  340. }
  341. // 自动切换到可用的面板
  342. const autoSwitchToAvailablePanel = () => {
  343. // 如果当前在作业区但没有iframe,自动切换到其他可用面板
  344. if (rightPanelMode.value === 'homework' && !currentSlideHasIframe.value) {
  345. if (isChoiceQuestion.value) {
  346. rightPanelMode.value = 'choice'
  347. console.log('自动切换到统计面板')
  348. }
  349. else {
  350. rightPanelMode.value = 'dialogue'
  351. console.log('自动切换到对话面板')
  352. }
  353. }
  354. // 如果当前在统计面板但不是选择题,自动切换到对话面板
  355. else if (rightPanelMode.value === 'choice' && !isChoiceQuestion.value) {
  356. rightPanelMode.value = 'dialogue'
  357. console.log('自动切换到对话面板')
  358. }
  359. }
  360. // 移除定时器相关函数,改用socket监听
  361. // 收缩/展开后重新计算中间画布尺寸(在 DOM 更新并完成过渡后)
  362. watch([() => workPanelCollapsed.value, () => slidePanelCollapsed.value], async () => {
  363. // 等待本次 DOM 更新
  364. await nextTick()
  365. // 先在下一帧计算一次,确保初步布局就绪
  366. requestAnimationFrame(() => {
  367. calculateScale()
  368. })
  369. // 再在过渡结束后(与左右栏 width .2s 过渡一致)复算一次,确保最终尺寸
  370. setTimeout(() => {
  371. calculateScale()
  372. }, 220)
  373. }, { flush: 'post' })
  374. const openWorkModal = (work: WorkItem) => {
  375. selectedWork.value = work
  376. const t = Number(work?.type)
  377. // if (t !== 1) {
  378. // message.warning('暂未开发完成')
  379. // return
  380. // }
  381. visibleShot.value = false
  382. visibleQA.value = false
  383. visibleChoice.value = false
  384. visibleAI.value = false
  385. if (t === 1) {
  386. visibleShot.value = true
  387. }
  388. else if (t === 3) {
  389. visibleQA.value = true
  390. }
  391. else if (t === 8) {
  392. visibleChoice.value = true
  393. }
  394. else if (t === 20) {
  395. visibleAI.value = true
  396. }
  397. else {
  398. message.info('暂不支持的作业类型')
  399. }
  400. }
  401. // 计算幻灯片尺寸的函数
  402. const calculateSlideSize = () => {
  403. const slideWrapRef = isFullscreen.value ? document.body : viewerCanvasRef.value
  404. const winWidth = slideWrapRef?.clientWidth || 0
  405. const winHeight = slideWrapRef?.clientHeight || 0
  406. // 根据视口比例计算最佳尺寸
  407. if (winHeight / winWidth === viewportRatio.value) {
  408. slideWidth.value = winWidth
  409. slideHeight.value = winHeight
  410. }
  411. else if (winHeight / winWidth > viewportRatio.value) {
  412. slideWidth.value = winWidth
  413. slideHeight.value = winWidth * viewportRatio.value
  414. }
  415. else {
  416. slideWidth.value = winHeight / viewportRatio.value
  417. slideHeight.value = winHeight
  418. }
  419. console.log('calculateSlideSize', slideWidth.value, slideHeight.value, viewportRatio.value, canvasScale.value)
  420. }
  421. // 使用编辑模式的缩放逻辑
  422. const calculateScale = () => {
  423. console.log('calculateScale 开始执行')
  424. // 获取容器尺寸
  425. const container = viewerCanvasRef.value || document.querySelector('.viewer-canvas')
  426. if (container) {
  427. containerWidth.value = container.clientWidth
  428. containerHeight.value = container.clientHeight
  429. console.log('容器尺寸:', {
  430. width: containerWidth.value,
  431. height: containerHeight.value
  432. })
  433. // 计算基础尺寸
  434. const baseWidth = viewportSize.value
  435. const baseHeight = viewportSize.value * viewportRatio.value
  436. console.log('基础尺寸:', {
  437. baseWidth,
  438. baseHeight,
  439. viewportSize: viewportSize.value,
  440. viewportRatio: viewportRatio.value
  441. })
  442. // 计算缩放比例,让幻灯片能够合理利用空间
  443. const scaleX = containerWidth.value / baseWidth
  444. const scaleY = containerHeight.value / baseHeight
  445. console.log('原始缩放比例:', { scaleX, scaleY })
  446. // 选择较小的缩放比例,确保幻灯片完全显示且居中,留10%边距
  447. const scale = Math.min(scaleX, scaleY) * 0.9
  448. console.log('最终缩放比例:', scale)
  449. canvasScale.value = isFullscreen.value ? 1 : props.type == '1' ? 1 : 1
  450. // canvasScale.value = 1
  451. }
  452. else {
  453. console.error('找不到容器元素')
  454. }
  455. // 计算幻灯片尺寸
  456. nextTick(() => {
  457. setTimeout(() => {
  458. calculateSlideSize()
  459. }, 500)
  460. })
  461. }
  462. // 简化:直接使用放映功能的缩放逻辑
  463. const resetZoom = () => {
  464. calculateScale()
  465. }
  466. // 背景样式
  467. const background = computed(() => currentSlide.value?.background)
  468. const { backgroundStyle } = useSlideBackgroundStyle(background)
  469. // 计算当前幻灯片的元素列表
  470. const elementList = computed(() => {
  471. return currentSlide.value?.elements || []
  472. })
  473. // 检查当前是否为选择题(toolType为45)
  474. const isChoiceQuestion = computed(() => {
  475. const frame = elementList.value.find(element => element.type === ElementTypes.FRAME)
  476. return frame?.toolType === 45
  477. })
  478. // 检测当前幻灯片是否包含iframe元素
  479. const currentSlideHasIframe = computed(() => {
  480. console.log('elementList.value', elementList.value)
  481. return elementList.value.some(element => element.type === ElementTypes.FRAME)
  482. })
  483. // 跳转到指定幻灯片
  484. const goToSlide = (index: number) => {
  485. console.log('goToSlide 被调用,目标索引:', index)
  486. console.log('当前索引:', slideIndex.value)
  487. if (index >= 0 && index < slides.value.length) {
  488. slidesStore.updateSlideIndex(index)
  489. console.log('更新后的索引:', slideIndex.value)
  490. }
  491. else {
  492. console.warn('goToSlide: 无效的索引:', index)
  493. }
  494. }
  495. // 上一页
  496. const previousSlide = () => {
  497. if (slideIndex.value > 0) {
  498. const newIndex = slideIndex.value - 1
  499. console.log('上一页,从', slideIndex.value, '到', newIndex)
  500. slidesStore.updateSlideIndex(newIndex)
  501. }
  502. }
  503. // 下一页
  504. const nextSlide = () => {
  505. if (slideIndex.value < slides.value.length - 1) {
  506. const newIndex = slideIndex.value + 1
  507. console.log('下一页,从', slideIndex.value, '到', newIndex)
  508. slidesStore.updateSlideIndex(newIndex)
  509. }
  510. }
  511. // 监听slideIndex变化,调用getWork
  512. watch(() => slideIndex.value, (newIndex, oldIndex) => {
  513. console.log('slideIndex变化,调用getWork', { newIndex, oldIndex })
  514. if (newIndex !== oldIndex && typeof newIndex === 'number') {
  515. // 检查新页面是否有iframe
  516. const hasIframe = currentSlideHasIframe.value
  517. if (hasIframe) {
  518. console.log('当前页面有iframe,获取作业数据')
  519. console.log('触发getWork,当前幻灯片索引:', newIndex)
  520. getWork()
  521. }
  522. if (props.type == '1' && isFollowModeActive.value && isCreator.value) {
  523. api.updateCourseFollowC(newIndex, props.courseid as string)
  524. sendMessage({slideIndex: newIndex, courseid: props.courseid, type: 'slideIndex'})
  525. }
  526. // 自动切换到可用的面板
  527. autoSwitchToAvailablePanel()
  528. }
  529. }, { immediate: false, deep: false })
  530. // 监听iframe状态变化,自动切换面板
  531. watch(() => currentSlideHasIframe.value, (hasIframe) => {
  532. if (!hasIframe) {
  533. autoSwitchToAvailablePanel()
  534. }
  535. }, { immediate: false })
  536. // 全屏
  537. const enterFullscreen = () => {
  538. if (document.fullscreenElement) {
  539. document.exitFullscreen()
  540. }
  541. else {
  542. document.documentElement.requestFullscreen()
  543. }
  544. }
  545. // 监听全屏状态变化
  546. const handleFullscreenChange = () => {
  547. isFullscreen.value = !!document.fullscreenElement
  548. if (isFullscreen.value) {
  549. // 全屏时不需要计算缩放,直接使用放映功能
  550. console.log('进入全屏模式')
  551. }
  552. else {
  553. // 退出全屏时重置所有工具状态并重新计算缩放比例
  554. console.log('退出全屏模式,重置工具状态')
  555. // 重置所有工具状态
  556. rightToolsVisible.value = false
  557. writingBoardToolVisible.value = false
  558. timerlVisible.value = false
  559. slideThumbnailModelVisible.value = false
  560. laserPen.value = false
  561. // 重新计算缩放比例
  562. nextTick(() => {
  563. setTimeout(() => {
  564. calculateScale()
  565. }, 1000)
  566. })
  567. }
  568. }
  569. // 切换激光笔模式
  570. const toggleLaserPen = () => {
  571. laserPen.value = !laserPen.value
  572. console.log('激光笔状态:', laserPen.value ? '开启' : '关闭')
  573. }
  574. // 获取导入导出功能
  575. const { readJSON, exportJSON2, getFile } = useImport()
  576. // 根据iframe的URL查找对应的幻灯片索引
  577. const findSlideIndexByIframeUrl = (iframeUrl: string): number => {
  578. try {
  579. console.log('查找iframe对应的幻灯片索引,iframe URL:', iframeUrl)
  580. // 遍历所有幻灯片,查找包含该iframe URL的幻灯片
  581. for (let i = 0; i < slides.value.length; i++) {
  582. const slide = slides.value[i]
  583. // 检查幻灯片的元素中是否有iframe
  584. if (slide.elements && slide.elements.length > 0) {
  585. for (const element of slide.elements) {
  586. // 检查是否是iframe元素
  587. if (element.type === ElementTypes.FRAME) {
  588. // 检查iframe的src是否匹配
  589. if (element.url === iframeUrl) {
  590. console.log(`找到匹配的幻灯片,索引: ${i}, 幻灯片ID: ${slide.id}`)
  591. return i
  592. }
  593. }
  594. }
  595. }
  596. }
  597. // 如果没有找到匹配的幻灯片,返回当前幻灯片索引
  598. console.log('未找到匹配的幻灯片,使用当前幻灯片索引:', slideIndex.value)
  599. return slideIndex.value
  600. }
  601. catch (error) {
  602. console.error('查找幻灯片索引时出错:', error)
  603. return slideIndex.value
  604. }
  605. }
  606. // 处理iframe链接,为包含workPage的iframe添加必要参数
  607. // 处理iframe链接,为包含workPage的iframe添加必要参数
  608. const processIframeLinks = async () => {
  609. try {
  610. console.log('开始处理iframe链接')
  611. console.log('当前props:', { courseid: props.courseid, userid: props.userid })
  612. // 从slides数据中查找包含iframe的元素
  613. let hasIframe = false
  614. // 由于有异步操作,需整体用Promise.all处理
  615. const updatedSlides = await Promise.all(
  616. slides.value.map(async (slide, slideIndex) => {
  617. if (slide.elements && slide.elements.length > 0) {
  618. // 这里不能直接用async map,否则会导致类型不对
  619. const updatedElements = await Promise.all(
  620. slide.elements.map(async (element) => {
  621. // 检查是否是iframe元素
  622. if (element.type === ElementTypes.FRAME && element.url) {
  623. const iframeSrc = element.url
  624. const toolType = element.toolType
  625. if (iframeSrc.includes('workPage')) {
  626. hasIframe = true
  627. console.log(`处理幻灯片 ${slideIndex + 1} 中的iframe链接:`, iframeSrc)
  628. try {
  629. // 解析URL,处理hash部分
  630. let baseUrl = iframeSrc
  631. let hashPart = ''
  632. // 分离base URL和hash部分
  633. if (iframeSrc.includes('#')) {
  634. const parts = iframeSrc.split('#')
  635. baseUrl = parts[0]
  636. hashPart = parts[1]
  637. }
  638. // 构建新的hash部分,添加参数
  639. // 使用当前幻灯片索引作为task参数
  640. let newHash = hashPart
  641. if (newHash.includes('?')) {
  642. // 如果hash中已经有查询参数,添加&
  643. newHash += `&courseid=${props.courseid || ''}&userid=${props.userid || ''}&stage=0&task=${slideIndex}&tool=0`
  644. }
  645. else {
  646. // 如果hash中没有查询参数,添加?
  647. newHash += `?courseid=${props.courseid || ''}&userid=${props.userid || ''}&stage=0&task=${slideIndex}&tool=0`
  648. }
  649. // 构建新的URL
  650. const newUrl = `${baseUrl}#${newHash}`
  651. console.log(`幻灯片 ${slideIndex + 1} 的iframe链接已更新:`, newUrl)
  652. // 返回更新后的元素
  653. return {
  654. ...element,
  655. url: newUrl
  656. }
  657. }
  658. catch (error) {
  659. console.error(`处理幻灯片 ${slideIndex + 1} 的iframe链接时出错:`, error)
  660. return element
  661. }
  662. }
  663. else if (toolType == 73) {
  664. hasIframe = true
  665. // 先尝试获取iframe的contentWindow,如果获取不到再使用HTML方式
  666. try {
  667. // 创建一个临时的iframe来测试是否能获取contentWindow
  668. const tempIframe = document.createElement('iframe')
  669. tempIframe.style.display = 'none'
  670. tempIframe.src = iframeSrc
  671. // 先将临时iframe添加到body,否则onload事件不会触发
  672. document.body.appendChild(tempIframe)
  673. // 等待iframe加载完成
  674. await new Promise((resolve, reject) => {
  675. tempIframe.onload = resolve
  676. tempIframe.onerror = reject
  677. // 可选:设置超时时间,避免长时间无响应
  678. setTimeout(() => reject(new Error('Timeout')), 5000)
  679. })
  680. // 尝试获取contentWindow
  681. if (tempIframe.contentWindow && tempIframe.contentWindow.document) {
  682. console.log(`iframe ${iframeSrc} 可以获取contentWindow,使用直接加载方式`)
  683. // 移除临时iframe
  684. document.body.removeChild(tempIframe)
  685. return {
  686. ...element,
  687. isHTML: false,
  688. url: iframeSrc
  689. }
  690. }
  691. // 加载完成但无法获取contentWindow,也要移除iframe
  692. document.body.removeChild(tempIframe)
  693. }
  694. catch (error) {
  695. console.log(`iframe ${iframeSrc} 无法获取contentWindow,使用HTML方式:`, error)
  696. }
  697. // 如果无法获取contentWindow,使用HTML方式
  698. const html = await api.getHTML(iframeSrc)
  699. // const html = await api.getHTML('https://knowledge.cocorobo.cn/zh-CN/story-telling/a7fa08b8-cf60-11ef-93e3-12e77c4cb76b')
  700. console.log('html', html)
  701. console.log(`处理幻灯片 ${slideIndex + 1} 中的iframe链接:`, iframeSrc)
  702. return {
  703. ...element,
  704. isHTML: true,
  705. url: html
  706. }
  707. }
  708. }
  709. // 不是iframe元素或不需要处理,直接返回
  710. return element
  711. })
  712. )
  713. // 返回更新后的幻灯片
  714. return {
  715. ...slide,
  716. elements: updatedElements
  717. }
  718. }
  719. // 没有元素的幻灯片直接返回
  720. return slide
  721. })
  722. )
  723. if (hasIframe) {
  724. console.log('找到iframe元素,更新slides数据')
  725. // 更新store中的slides数据
  726. slidesStore.setSlides(updatedSlides)
  727. console.log('slides数据更新完成')
  728. }
  729. else {
  730. console.log('未找到包含workPage的iframe元素')
  731. }
  732. console.log('iframe链接处理完成')
  733. }
  734. catch (error) {
  735. console.error('处理iframe链接时出错:', error)
  736. }
  737. }
  738. // 导入JSON功能
  739. const importJSON = (jsonData: any) => {
  740. try {
  741. console.log('Student importJSON 开始执行')
  742. const result = readJSON(jsonData, true)
  743. if (result.success) {
  744. console.log('Student importJSON 成功,开始重新渲染')
  745. // 强制重新渲染:先隐藏组件
  746. showSlideList.value = false
  747. // 重新计算画布尺寸和缩放比例
  748. nextTick(() => {
  749. calculateScale()
  750. // 延迟500ms后重新显示组件,确保重新渲染完成
  751. setTimeout(() => {
  752. showSlideList.value = true
  753. // 只有当当前页面存在iframe时才获取作业数据
  754. if (currentSlideHasIframe.value && props.type == '1') {
  755. getWork()
  756. }
  757. selectCourseSLook()
  758. console.log('组件重新渲染完成')
  759. }, 500)
  760. })
  761. return true
  762. }
  763. console.error('Student importJSON 失败:', result.error)
  764. return false
  765. }
  766. catch (error) {
  767. console.error('Student importJSON 执行失败:', error)
  768. return false
  769. }
  770. }
  771. // 导出JSON功能
  772. const exportJSON = () => {
  773. try {
  774. console.log('Student exportJSON 开始执行,调用 useImport.exportJSON2')
  775. // 直接调用 useImport 中的 exportJSON2 函数
  776. const exportData = exportJSON2()
  777. if (exportData) {
  778. return exportData
  779. }
  780. console.error('Student exportJSON 失败: exportJSON2 返回空数据')
  781. return false
  782. }
  783. catch (error) {
  784. console.error('Student exportJSON 执行失败:', error)
  785. return false
  786. }
  787. }
  788. // 返回编辑器
  789. const backToEditor = () => {
  790. // 通过路由跳转到编辑模式
  791. window.location.href = '/'
  792. }
  793. const submitWork = async (slideIndex: number, atool: string, content: string, type: string) => {
  794. const res = await api.submitWork({
  795. uid: props.userid as string,
  796. cid: props.courseid as string,
  797. stage: '0',
  798. task: String(slideIndex), // 转为字符串
  799. tool: '0',
  800. atool: atool,
  801. content: content,
  802. type: type
  803. })
  804. getWork()
  805. console.log(res)
  806. }
  807. // 文件上传到AWS S3的函数
  808. const uploadFile = (file: File): Promise<string> => {
  809. return new Promise((resolve, reject) => {
  810. try {
  811. // 检查AWS SDK是否可用
  812. if (!(window as any).AWS) {
  813. reject(new Error('AWS SDK not loaded'))
  814. return
  815. }
  816. const credentials = {
  817. accessKeyId: 'AKIATLPEDU37QV5CHLMH',
  818. secretAccessKey: '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'
  819. }
  820. // 配置AWS
  821. ;(window as any).AWS.config.update(credentials)
  822. ;(window as any).AWS.config.region = 'cn-northwest-1'
  823. // 创建S3实例
  824. const bucket = new (window as any).AWS.S3({ params: { Bucket: 'ccrb' } })
  825. if (file) {
  826. // 生成唯一的文件名
  827. const fileExtension = file.name.split('.').pop()
  828. const fileName = `${file.name.split('.')[0]}_${Date.now()}.${fileExtension}`
  829. const params = {
  830. Key: fileName,
  831. ContentType: file.type,
  832. Body: file,
  833. ACL: 'public-read'
  834. }
  835. const options = {
  836. partSize: 2048 * 1024 * 1024, // 2GB分片
  837. queueSize: 2,
  838. leavePartsOnError: true
  839. }
  840. bucket
  841. .upload(params, options)
  842. .on('httpUploadProgress', (evt: any) => {
  843. // 这里可以添加进度条逻辑
  844. const progress = Math.round((evt.loaded * 100) / evt.total)
  845. console.log(`Uploaded: ${progress}%`)
  846. })
  847. .send((err: any, data: any) => {
  848. if (err) {
  849. console.error('Upload failed:', err)
  850. message.error('文件上传失败')
  851. reject(err)
  852. }
  853. else {
  854. console.log('Upload successful:', data.Location)
  855. resolve(data.Location)
  856. }
  857. })
  858. }
  859. else {
  860. reject(new Error('No file provided'))
  861. }
  862. }
  863. catch (error) {
  864. console.error('Upload error:', error)
  865. reject(error)
  866. }
  867. })
  868. }
  869. // 作业提交功能(优化版)
  870. const handleHomeworkSubmit = async () => {
  871. console.log('作业提交按钮被点击')
  872. // 防抖:如果正在提交中,直接返回
  873. if (isSubmitting.value) {
  874. console.log('作业正在提交中,忽略重复点击')
  875. return
  876. }
  877. isSubmitting.value = true
  878. try {
  879. // 获取所有iframe元素
  880. const iframes = document.querySelectorAll('.viewer-canvas .screen-slide')[slideIndex.value].querySelectorAll('iframe')
  881. console.log('找到iframe元素数量:', iframes.length)
  882. if (iframes.length === 0) {
  883. message.warning('当前页面没有找到iframe元素')
  884. return
  885. }
  886. let hasSubmitWork = false
  887. for (let i = 0; i < iframes.length; i++) {
  888. const iframe = iframes[i] as HTMLIFrameElement
  889. const iframeSrc = iframe.src
  890. console.log(`iframe ${i + 1} 链接:`, iframeSrc)
  891. // 检查iframe链接是否包含workPage
  892. if (iframeSrc && iframeSrc.includes('workPage')) {
  893. console.log('找到包含workPage的iframe,尝试执行submitWork')
  894. try {
  895. const iframeWindow = iframe.contentWindow as Window & { submitWork?: (...args: any[]) => unknown }
  896. if (iframeWindow && typeof iframeWindow.submitWork === 'function') {
  897. console.log('执行iframe中的submitWork方法,参数可变')
  898. const iframeSlideIndex = slideIndex.value
  899. const submitArgs = [iframeSlideIndex]
  900. // 支持同步和异步submitWork
  901. const result = await iframeWindow.submitWork(...submitArgs)
  902. if (result instanceof Promise) {
  903. await result
  904. console.log('submitWork异步执行完成')
  905. }
  906. else {
  907. console.log('submitWork同步执行完成')
  908. message.success('作业提交成功')
  909. hasSubmitWork = true
  910. // 发送作业提交成功的socket消息
  911. sendMessage({
  912. type: 'homework_submitted',
  913. courseid: props.courseid,
  914. slideIndex: slideIndex.value,
  915. userid: props.userid
  916. })
  917. }
  918. break
  919. }
  920. else {
  921. console.log('iframe中没有找到submitWork方法')
  922. }
  923. }
  924. catch (error) {
  925. console.error('访问iframe内容时出错:', error)
  926. }
  927. }
  928. else if (iframeSrc && (iframeSrc.includes('aichat.cocorobo') || iframeSrc.includes('knowledge.cocorobo'))) {
  929. console.log('找到包含aichat.cocorobo或knowledge.cocorobo的iframe,尝试执行submitWork')
  930. // 由于TS类型检查,需通过 any 绕过类型限制
  931. const iframeWindow = iframe.contentWindow as any
  932. if (iframeWindow && iframeWindow.exposed_outputs) {
  933. console.log('执行iframe中的submitWork方法,参数可变')
  934. const iframeSlideIndex = slideIndex.value
  935. const Cow = JSON.stringify(iframeWindow.exposed_outputs)
  936. // 这里假设 submitWork 是全局可用的函数
  937. await submitWork(iframeSlideIndex, '72', Cow, '20')
  938. message.success('作业提交成功')
  939. hasSubmitWork = true
  940. // 发送作业提交成功的socket消息
  941. sendMessage({
  942. type: 'homework_submitted',
  943. courseid: props.courseid,
  944. slideIndex: slideIndex.value,
  945. userid: props.userid
  946. })
  947. }
  948. }
  949. else {
  950. // message.warning('当前页面暂不支持作业提交')
  951. console.log('尝试截图当前页面并提交')
  952. // return
  953. try {
  954. // 尝试使用html2canvas,对iframe支持更好
  955. let imageData: string
  956. const screenSlides = document.querySelectorAll('.viewer-canvas .screen-slide')
  957. let iframeElement: HTMLIFrameElement | null = null
  958. let iframeBody: HTMLElement | null = null
  959. // 获取iframe元素
  960. if (
  961. screenSlides &&
  962. screenSlides[slideIndex.value] &&
  963. screenSlides[slideIndex.value].querySelector('iframe')
  964. ) {
  965. iframeElement = screenSlides[slideIndex.value].querySelector('iframe') as HTMLIFrameElement
  966. }
  967. else {
  968. throw new Error('未能获取到iframe元素,无法截图')
  969. }
  970. // 获取iframe内部的body元素(同源)
  971. if (
  972. iframeElement.contentWindow &&
  973. iframeElement.contentWindow.document &&
  974. iframeElement.contentWindow.document.body
  975. ) {
  976. // 获取页面的所有注释节点
  977. const comments = []
  978. const childNodes = iframeElement.contentWindow.document.createTreeWalker(iframeElement.contentWindow.document.body, NodeFilter.SHOW_COMMENT, null)
  979. while (childNodes.nextNode()) {
  980. comments.push(childNodes.currentNode)
  981. }
  982. // 移除所有注释节点
  983. comments.forEach(comment => {
  984. comment?.parentNode?.removeChild(comment)
  985. })
  986. iframeBody = iframeElement.contentWindow.document.body as HTMLElement
  987. }
  988. else {
  989. throw new Error('未能获取到iframe的body元素,无法截图')
  990. }
  991. try {
  992. // 直接对iframe内部的body进行截图
  993. const html2canvas = await import('html2canvas')
  994. const canvas = await html2canvas.default(iframeBody, {
  995. useCORS: true,
  996. allowTaint: true,
  997. scale: 1,
  998. backgroundColor: '#ffffff',
  999. logging: false,
  1000. foreignObjectRendering: true,
  1001. removeContainer: true
  1002. })
  1003. imageData = canvas.toDataURL('image/png', 0.95)
  1004. console.log('成功截图iframe内部内容')
  1005. }
  1006. catch (html2canvasError) {
  1007. console.log('html2canvas失败,尝试html-to-image:', html2canvasError)
  1008. try {
  1009. // 回退到html-to-image
  1010. const { toPng } = await import('html-to-image')
  1011. imageData = await toPng(iframeBody, {
  1012. quality: 0.95,
  1013. backgroundColor: '#ffffff',
  1014. filter: (node) => {
  1015. if (node.tagName === 'SCRIPT' || node.tagName === 'STYLE') {
  1016. return false
  1017. }
  1018. return true
  1019. }
  1020. })
  1021. console.log('使用html-to-image截图成功')
  1022. }
  1023. catch (htmlToImageError) {
  1024. console.log('html-to-image也失败了,使用canvas绘制方案:', htmlToImageError)
  1025. message.error('截图提交失败')
  1026. return
  1027. /*
  1028. // 最后的备用方案:使用canvas绘制
  1029. const canvas = document.createElement('canvas')
  1030. const ctx = canvas.getContext('2d')
  1031. if (ctx) {
  1032. canvas.width = iframeElement.offsetWidth || 800
  1033. canvas.height = iframeElement.offsetHeight || 600
  1034. // 绘制背景
  1035. const gradient = ctx.createLinearGradient(0, 0, 0, canvas.height)
  1036. gradient.addColorStop(0, '#f8f9fa')
  1037. gradient.addColorStop(1, '#e9ecef')
  1038. ctx.fillStyle = gradient
  1039. ctx.fillRect(0, 0, canvas.width, canvas.height)
  1040. // 绘制边框
  1041. ctx.strokeStyle = '#dee2e6'
  1042. ctx.lineWidth = 3
  1043. ctx.strokeRect(2, 2, canvas.width - 4, canvas.height - 4)
  1044. // 绘制内边框
  1045. ctx.strokeStyle = '#ffffff'
  1046. ctx.lineWidth = 1
  1047. ctx.strokeRect(5, 5, canvas.width - 10, canvas.height - 10)
  1048. // 绘制iframe图标
  1049. ctx.fillStyle = '#6c757d'
  1050. ctx.font = 'bold 48px Arial'
  1051. ctx.textAlign = 'center'
  1052. ctx.fillText('', canvas.width / 2, canvas.height / 2 - 40)
  1053. // 绘制标题
  1054. ctx.font = 'bold 20px Arial'
  1055. ctx.fillStyle = '#495057'
  1056. ctx.fillText('iframe内容', canvas.width / 2, canvas.height / 2 + 20)
  1057. // 绘制URL
  1058. const src = iframeElement.src
  1059. if (src) {
  1060. ctx.font = '14px Arial'
  1061. ctx.fillStyle = '#6c757d'
  1062. const url = src.length > 80 ? src.substring(0, 80) + '...' : src
  1063. ctx.fillText(url, canvas.width / 2, canvas.height / 2 + 50)
  1064. }
  1065. // 绘制提示信息
  1066. ctx.font = '12px Arial'
  1067. ctx.fillStyle = '#adb5bd'
  1068. ctx.fillText('(截图失败)', canvas.width / 2, canvas.height / 2 + 80)
  1069. // 绘制装饰性元素
  1070. ctx.strokeStyle = '#dee2e6'
  1071. ctx.lineWidth = 1
  1072. ctx.setLineDash([5, 5])
  1073. ctx.strokeRect(20, 20, canvas.width - 40, canvas.height - 40)
  1074. ctx.setLineDash([])
  1075. imageData = canvas.toDataURL('image/png', 0.95)
  1076. console.log('使用canvas绘制方案截图成功')
  1077. }
  1078. else {
  1079. throw new Error('无法创建canvas上下文')
  1080. }*/
  1081. }
  1082. // 将base64字符串转换为File对象
  1083. const base64ToFile = (base64String: string, filename: string): File => {
  1084. const arr = base64String.split(',')
  1085. const mime = arr[0].match(/:(.*?);/)?.[1] || 'image/png'
  1086. const bstr = atob(arr[1])
  1087. let n = bstr.length
  1088. const u8arr = new Uint8Array(n)
  1089. while (n--) {
  1090. u8arr[n] = bstr.charCodeAt(n)
  1091. }
  1092. return new File([u8arr], filename, { type: mime })
  1093. }
  1094. const imageFile = base64ToFile(imageData, `screenshot_${Date.now()}.png`)
  1095. const imageUrl = await uploadFile(imageFile)
  1096. // 提交截图
  1097. await submitWork(slideIndex.value, '73', imageUrl, '1') // 73表示截图工具,21表示图片类型
  1098. message.success('页面截图提交成功')
  1099. hasSubmitWork = true
  1100. // 发送作业提交成功的socket消息
  1101. sendMessage({
  1102. type: 'homework_submitted',
  1103. courseid: props.courseid,
  1104. slideIndex: slideIndex.value,
  1105. userid: props.userid
  1106. })
  1107. }
  1108. }
  1109. catch (error) {
  1110. console.error('截图提交失败:', error)
  1111. message.error('截图提交失败')
  1112. }
  1113. }
  1114. }
  1115. if (!hasSubmitWork) {
  1116. message.info('未找到可用的作业提交功能')
  1117. isSubmitting.value = false
  1118. }
  1119. }
  1120. catch (error) {
  1121. console.error('作业提交过程中出错:', error)
  1122. message.error('作业提交失败')
  1123. isSubmitting.value = false
  1124. }
  1125. finally {
  1126. isSubmitting.value = false
  1127. }
  1128. }
  1129. // 刷新iframe功能
  1130. const handleRefreshPage = () => {
  1131. console.log('刷新iframe按钮被点击')
  1132. try {
  1133. // 获取当前幻灯片中的所有iframe元素
  1134. const iframes = document.querySelectorAll('.viewer-canvas .screen-slide')[slideIndex.value].querySelectorAll('iframe')
  1135. console.log('找到iframe元素数量:', iframes.length)
  1136. if (iframes.length === 0) {
  1137. message.warning('当前页面没有找到iframe元素')
  1138. return
  1139. }
  1140. let refreshedCount = 0
  1141. // 遍历所有iframe并刷新
  1142. for (let i = 0; i < iframes.length; i++) {
  1143. const iframe = iframes[i] as HTMLIFrameElement
  1144. const currentSrc = iframe.src
  1145. if (currentSrc) {
  1146. console.log(`刷新iframe ${i + 1}:`, currentSrc)
  1147. // 保存当前src
  1148. const originalSrc = currentSrc
  1149. // 清空src触发刷新
  1150. iframe.src = ''
  1151. // 短暂延迟后恢复src,确保刷新生效
  1152. setTimeout(() => {
  1153. iframe.src = originalSrc
  1154. console.log(`iframe ${i + 1} 刷新完成`)
  1155. }, 100)
  1156. refreshedCount++
  1157. }
  1158. }
  1159. if (refreshedCount > 0) {
  1160. message.success(`刷新完成`)
  1161. // 如果当前页面有iframe,重新获取作业数据
  1162. if (currentSlideHasIframe.value && props.type == '1') {
  1163. setTimeout(() => {
  1164. getWork()
  1165. }, 500) // 延迟500ms等待iframe加载完成
  1166. }
  1167. }
  1168. else {
  1169. message.info('没有找到可刷新的iframe')
  1170. }
  1171. }
  1172. catch (error) {
  1173. console.error('刷新iframe时出错:', error)
  1174. message.error('刷新iframe失败')
  1175. }
  1176. }
  1177. // 获取作业提交按钮的右侧位置
  1178. const getHomeworkButtonRight = () => {
  1179. if (isFullscreen.value) {
  1180. return 30 // 全屏时按钮在右侧30px
  1181. }
  1182. if (props.type === '1') {
  1183. // 展开作业区:按钮更靠左;收起时:按钮更靠右侧
  1184. return workPanelCollapsed.value ? 60 : 430
  1185. }
  1186. return 30 // type=2时按钮在右侧30px
  1187. }
  1188. // 获取刷新按钮的右侧位置
  1189. const getRefreshButtonRight = () => {
  1190. if (isFullscreen.value) {
  1191. return 160 // 全屏时按钮在右侧150px
  1192. }
  1193. if (props.type === '1') {
  1194. // 展开作业区:按钮更靠左;收起时:按钮更靠右侧
  1195. return workPanelCollapsed.value ? 190 : 560
  1196. }
  1197. return 160 // type=2时按钮在右侧150px
  1198. }
  1199. // 键盘快捷键
  1200. const handleKeydown = (e: KeyboardEvent) => {
  1201. switch (e.key) {
  1202. case 'ArrowLeft':
  1203. e.preventDefault()
  1204. if (!isFollowModeActive.value || props.type == '1') {
  1205. previousSlide()
  1206. }
  1207. break
  1208. case 'PageUp':
  1209. e.preventDefault()
  1210. if (!isFollowModeActive.value || props.type == '1') {
  1211. previousSlide()
  1212. }
  1213. break
  1214. case 'ArrowRight':
  1215. e.preventDefault()
  1216. if (!isFollowModeActive.value || props.type == '1') {
  1217. nextSlide()
  1218. }
  1219. break
  1220. case 'PageDown':
  1221. case ' ':
  1222. e.preventDefault()
  1223. if (!isFollowModeActive.value || props.type == '1') {
  1224. nextSlide()
  1225. }
  1226. break
  1227. case 'F11':
  1228. e.preventDefault()
  1229. enterFullscreen()
  1230. break
  1231. case 'Escape':
  1232. if (document.fullscreenElement) {
  1233. document.exitFullscreen()
  1234. }
  1235. break
  1236. default:
  1237. break
  1238. }
  1239. }
  1240. // 事件处理函数
  1241. const handleSlidesDataUpdated = () => {
  1242. console.log('收到 slidesDataUpdated 事件')
  1243. // 强制重新渲染:先隐藏组件
  1244. showSlideList.value = false
  1245. nextTick(() => {
  1246. calculateScale()
  1247. // 延迟500ms后重新显示组件,确保重新渲染完成
  1248. setTimeout(() => {
  1249. showSlideList.value = true
  1250. console.log('组件重新渲染完成')
  1251. // 重新处理iframe链接
  1252. processIframeLinks()
  1253. }, 500)
  1254. console.log('slidesDataUpdated 事件处理完成')
  1255. })
  1256. }
  1257. const handleViewportSizeUpdated = (event: any) => {
  1258. console.log('收到 viewportSizeUpdated 事件:', event.detail)
  1259. // 重新计算缩放比例
  1260. nextTick(() => {
  1261. calculateScale()
  1262. console.log('viewportSizeUpdated 事件处理完成')
  1263. })
  1264. }
  1265. const getCourseDetail = async () => {
  1266. isLoading.value = true
  1267. try {
  1268. const res = await api.getCourseDetail(props.courseid as string)
  1269. console.log(res)
  1270. const courseData = res[0][0]
  1271. courseDetail.value = courseData
  1272. selectWorksStudent()
  1273. checkIsCreator()
  1274. const pptJSONUrl = JSON.parse(courseData.chapters).pptData ? JSON.parse(courseData.chapters).pptData : ''
  1275. console.log(pptJSONUrl)
  1276. if (pptJSONUrl) {
  1277. const pptdata = await getFile(pptJSONUrl)
  1278. // pptdata.data 是 ArrayBuffer,需要先转成字符串再解析为 JSON
  1279. let jsonStr = ''
  1280. if (pptdata && pptdata.data) {
  1281. // 先将 ArrayBuffer 转为字符串
  1282. const uint8Array = new Uint8Array(pptdata.data)
  1283. jsonStr = new TextDecoder('utf-8').decode(uint8Array)
  1284. try {
  1285. const jsonObj = JSON.parse(jsonStr)
  1286. importJSON(jsonObj)
  1287. }
  1288. catch (e) {
  1289. console.error('解析pptdata.data失败:', e)
  1290. }
  1291. }
  1292. }
  1293. }
  1294. catch (error) {
  1295. console.error('获取课程详情失败:', error)
  1296. message.error('获取课程详情失败')
  1297. isLoading.value = false
  1298. }
  1299. finally {
  1300. isLoading.value = false
  1301. // if (props.type == '2') {
  1302. // console.log('判断是否是学生进入全屏')
  1303. // function panFull() {
  1304. // console.log('判断是否是学生进入全屏111')
  1305. // if (!document.fullscreenElement) {
  1306. // setTimeout(() => {
  1307. // if (!document.fullscreenElement) {
  1308. // if (document.documentElement.requestFullscreen) {
  1309. // document.documentElement.requestFullscreen()
  1310. // }
  1311. // else if (document.documentElement.mozRequestFullScreen) { // Firefox
  1312. // document.documentElement.mozRequestFullScreen()
  1313. // }
  1314. // else if (document.documentElement.webkitRequestFullscreen) { // Chrome, Safari and Opera
  1315. // document.documentElement.webkitRequestFullscreen()
  1316. // }
  1317. // else if (document.documentElement.msRequestFullscreen) { // IE/Edge
  1318. // document.documentElement.msRequestFullscreen()
  1319. // }
  1320. // panFull()
  1321. // }
  1322. // }, 50)
  1323. // }
  1324. // }
  1325. // nextTick(() => {
  1326. // setTimeout(() => {
  1327. // // enterFullscreen();
  1328. // panFull()
  1329. // }, 50)
  1330. // })
  1331. // }
  1332. }
  1333. }
  1334. const getWorkLoading = ref<any>(false)
  1335. const getWork = async (isUpdate = false) => {
  1336. try {
  1337. if (getWorkLoading.value) {
  1338. return
  1339. }
  1340. if (!isUpdate) {
  1341. workLoading.value = true
  1342. }
  1343. getWorkLoading.value = true
  1344. console.log('getWork 开始执行,参数:', {
  1345. courseid: props.courseid,
  1346. slideIndex: slideIndex.value,
  1347. type: props.type,
  1348. isUpdate
  1349. })
  1350. if (!props.courseid) {
  1351. console.warn('getWork: courseid 未提供,跳过执行')
  1352. if (!isUpdate) workLoading.value = false
  1353. return
  1354. }
  1355. const res = await api.selectSWorks(props.courseid, '0', slideIndex.value.toString())
  1356. console.log('getWork 执行成功,结果:', res)
  1357. const frame = elementList.value.find(element => element.type === ElementTypes.FRAME)
  1358. console.log('frame:', frame)
  1359. const toolType = frame?.toolType ?? ''
  1360. const newWorkArray = props.cid
  1361. ? res[0].filter((work: any) => {
  1362. return props.type == '1' || (props.type == '2' && work.classid.includes(props.cid)) && (work.atool === toolType || !toolType)
  1363. })
  1364. : res[0]
  1365. // 如果是更新模式,只有当数据真正变化时才更新
  1366. if (isUpdate) {
  1367. const hasChanged = checkWorkArrayChanged(workArray.value, newWorkArray)
  1368. if (hasChanged) {
  1369. console.log('检测到作业数据变化,更新显示')
  1370. workArray.value = newWorkArray
  1371. }
  1372. else {
  1373. console.log('作业数据无变化,跳过更新')
  1374. }
  1375. }
  1376. else {
  1377. workArray.value = newWorkArray
  1378. }
  1379. console.log('getWork 执行成功,结果:', workArray.value)
  1380. getWorkLoading.value = false
  1381. }
  1382. catch (error) {
  1383. console.error('getWork 执行失败:', error)
  1384. if (!isUpdate) {
  1385. message.error('获取作业信息失败')
  1386. }
  1387. getWorkLoading.value = false
  1388. }
  1389. finally {
  1390. if (!isUpdate) {
  1391. workLoading.value = false
  1392. }
  1393. getWorkLoading.value = false
  1394. }
  1395. }
  1396. const selectWorksStudent = async () => {
  1397. studentLoading.value = true
  1398. try {
  1399. const res = await api.selectWorksStudent(props.oid as string, courseDetail.value.juri as string)
  1400. console.log('selectWorksStudent', res)
  1401. const students = res[0]
  1402. console.log('students', students)
  1403. if (props.cid) {
  1404. studentArray.value = students.filter((student: any) => student.classid.includes(props.cid))
  1405. }
  1406. else {
  1407. studentArray.value = students
  1408. }
  1409. }
  1410. catch (error) {
  1411. console.error('获取学生信息失败:', error)
  1412. message.error('获取学生信息失败')
  1413. }
  1414. finally {
  1415. studentLoading.value = false
  1416. }
  1417. }
  1418. // 检查作业数组是否发生变化
  1419. const checkWorkArrayChanged = (oldArray: WorkItem[], newArray: WorkItem[]): boolean => {
  1420. if (oldArray.length !== newArray.length) return true
  1421. // 检查每个作业的 id 和 name 是否一致
  1422. for (let i = 0; i < oldArray.length; i++) {
  1423. const oldWork = oldArray[i]
  1424. const newWork = newArray[i]
  1425. if (oldWork.id !== newWork.id || oldWork.name !== newWork.name || oldWork.content !== newWork.content) {
  1426. return true
  1427. }
  1428. }
  1429. return false
  1430. }
  1431. // 查询课程跟随状态
  1432. const selectCourseSLook = async () => {
  1433. const res = await api.selectCourseSLook(props.courseid as string)
  1434. console.log('selectCourseSLook', res)
  1435. if (res[0][0].follow == 2) {
  1436. if (props.type == '2') {
  1437. goToSlide(Number(res[0][0].followC))
  1438. }
  1439. isFollowModeActive.value = true
  1440. }
  1441. else {
  1442. isFollowModeActive.value = false
  1443. }
  1444. }
  1445. // 切换跟随模式
  1446. const toggleFollowMode = async () => {
  1447. try {
  1448. const newFollowState = !isFollowModeActive.value
  1449. const sopen = newFollowState ? 2 : 1
  1450. // 调用API更新跟随状态
  1451. const res = await api.updateCourseFollow(sopen, props.courseid as string)
  1452. console.log('更新跟随模式状态:', res)
  1453. sendMessage({sopen: newFollowState, courseid: props.courseid, type: 'sopen'})
  1454. if (res) {
  1455. isFollowModeActive.value = newFollowState
  1456. message.success(newFollowState ? '跟随模式已开启' : '跟随模式已关闭')
  1457. // 如果开启跟随模式,设置当前幻灯片为跟随目标
  1458. if (newFollowState) {
  1459. await api.updateCourseFollowC(slideIndex.value, props.courseid as string)
  1460. console.log('设置当前幻灯片为跟随目标:', slideIndex.value)
  1461. }
  1462. }
  1463. else {
  1464. message.error('操作失败,请重试')
  1465. }
  1466. }
  1467. catch (error) {
  1468. console.error('切换跟随模式失败:', error)
  1469. message.error('操作失败,请重试')
  1470. }
  1471. }
  1472. // 检查是否为创建人
  1473. const checkIsCreator = () => {
  1474. // 这里可以根据实际业务逻辑判断是否为创建人
  1475. // 比如通过props中的userid与课程创建者ID比较
  1476. if (courseDetail.value && props.userid) {
  1477. isCreator.value = courseDetail.value.userid === props.userid
  1478. }
  1479. }
  1480. /**
  1481. * 初始化消息监听
  1482. */
  1483. const messageInit = () => {
  1484. if (docSocket.value && !yMessage.value) {
  1485. console.log('获取message', docSocket.value, yMessage.value)
  1486. yMessage.value = docSocket.value.getArray('message')
  1487. yMessage.value.observe((e: any) => {
  1488. e.changes.added.forEach((i: any) => {
  1489. const message = i.content.getContent()[0]
  1490. console.log('yMessage', message)
  1491. const _nowTime = new Date()
  1492. const _msgTime = new Date(message.timestamp)
  1493. if (
  1494. (_nowTime as any) - (_msgTime as any) <= 1000 * 10 &&
  1495. message.mId !== mId.value
  1496. ) {
  1497. // 10秒内且不是自己发的消息
  1498. getMessages(message)
  1499. }
  1500. })
  1501. })
  1502. }
  1503. }
  1504. /**
  1505. * 发送消息
  1506. */
  1507. const sendMessage = (obj: any) => {
  1508. if (docSocket.value && yMessage.value) {
  1509. const message = obj
  1510. obj.timestamp = new Date().toISOString()
  1511. obj.mId = mId.value
  1512. docSocket.value.transact(() => {
  1513. yMessage.value.push([message])
  1514. })
  1515. }
  1516. }
  1517. /**
  1518. * 处理收到的消息
  1519. */
  1520. const getMessages = (msgObj: any) => {
  1521. console.log('message', msgObj)
  1522. // 处理幻灯片切换消息
  1523. if (props.type == '2' && msgObj.slideIndex && msgObj.type === 'slideIndex') {
  1524. goToSlide(msgObj.slideIndex)
  1525. }
  1526. // 处理跟随模式状态变化
  1527. if (props.type == '2' && msgObj.type === 'sopen') {
  1528. selectCourseSLook()
  1529. }
  1530. // 处理作业提交消息 - 当有人提交作业时,重新获取作业数据
  1531. if (props.type == '1' && msgObj.type === 'homework_submitted' && msgObj.courseid === props.courseid) {
  1532. console.log('收到作业提交消息,重新获取作业数据')
  1533. // 延迟一点时间,确保后端数据已更新
  1534. setTimeout(() => {
  1535. if (currentSlideHasIframe.value) {
  1536. getWork(true) // 传入true表示是更新模式
  1537. }
  1538. }, 1000)
  1539. }
  1540. }
  1541. onMounted(() => {
  1542. document.addEventListener('keydown', handleKeydown)
  1543. // 处理URL参数
  1544. if (props.courseid || props.type) {
  1545. console.log('收到URL参数:', { courseid: props.courseid, type: props.type })
  1546. // 这里可以根据courseid和type进行相应的处理
  1547. // 比如加载特定的课程数据、设置特定的显示模式等
  1548. if (props.courseid) {
  1549. console.log('课程ID:', props.courseid)
  1550. // TODO: 根据courseid加载对应的课程数据
  1551. }
  1552. if (props.type) {
  1553. console.log('类型:', props.type)
  1554. // TODO: 根据type设置特定的显示模式或功能
  1555. }
  1556. }
  1557. getCourseDetail()
  1558. // 计算初始缩放比例
  1559. nextTick(() => {
  1560. calculateScale()
  1561. // 处理iframe链接
  1562. processIframeLinks()
  1563. // 初始化时检查并自动切换到可用面板
  1564. autoSwitchToAvailablePanel()
  1565. })
  1566. // 监听窗口大小变化
  1567. window.addEventListener('resize', calculateScale)
  1568. // 监听全屏状态变化
  1569. document.addEventListener('fullscreenchange', handleFullscreenChange)
  1570. // 监听幻灯片数据更新事件(来自useImport的readJSON)
  1571. window.addEventListener('slidesDataUpdated', handleSlidesDataUpdated)
  1572. // 监听视口尺寸更新事件
  1573. window.addEventListener('viewportSizeUpdated', handleViewportSizeUpdated)
  1574. // 将导入导出功能暴露到window上,方便调试和外部调用
  1575. ; (window as any).PPTistStudent = {
  1576. importJSON,
  1577. exportJSON,
  1578. slides: slidesStore.slides,
  1579. currentSlide: computed(() => slidesStore.currentSlide),
  1580. slideIndex: computed(() => slidesStore.slideIndex),
  1581. goToSlide,
  1582. previousSlide,
  1583. nextSlide,
  1584. enterFullscreen,
  1585. toggleLaserPen,
  1586. // 添加URL参数到全局对象中
  1587. courseid: props.courseid,
  1588. type: props.type
  1589. }
  1590. console.log('PPTist Student View 已加载,可通过 window.PPTistStudent 访问功能')
  1591. console.log('URL参数:', { courseid: props.courseid, type: props.type })
  1592. if (api.yweb_socket && !docSocket.value) {
  1593. docSocket.value = new Y.Doc()
  1594. providerSocket.value = new WebsocketProvider(api.yweb_socket,
  1595. 'PPT' + props.courseid,
  1596. docSocket.value
  1597. )
  1598. providerSocket.value.on('status', (event: any) => {
  1599. console.log('👉', event.status)
  1600. if (event.status === 'connected') {
  1601. console.log('👉连接成功websocket(teachingMode)')
  1602. mId.value = Math.random().toString(36).substr(2, 9)
  1603. messageInit()
  1604. }
  1605. })
  1606. }
  1607. })
  1608. onUnmounted(() => {
  1609. document.removeEventListener('keydown', handleKeydown)
  1610. window.removeEventListener('resize', calculateScale)
  1611. document.removeEventListener('fullscreenchange', handleFullscreenChange)
  1612. // 移除幻灯片数据更新事件监听器
  1613. window.removeEventListener('slidesDataUpdated', handleSlidesDataUpdated)
  1614. // 移除视口尺寸更新事件监听器
  1615. window.removeEventListener('viewportSizeUpdated', handleViewportSizeUpdated)
  1616. // 移除定时器清理代码,已改用socket监听
  1617. // 清理window上的引用
  1618. if ((window as any).PPTistStudent) {
  1619. delete (window as any).PPTistStudent
  1620. console.log('PPTist Student View 已卸载,window.PPTistStudent 已清理')
  1621. }
  1622. })
  1623. </script>
  1624. <style lang="scss" scoped>
  1625. .pptist-student-viewer {
  1626. height: 100vh;
  1627. display: flex;
  1628. background-color: #f5f5f5;
  1629. // 全屏模式样式
  1630. &.fullscreen {
  1631. .layout-content-left {
  1632. display: none; // 全屏时隐藏左侧导航栏
  1633. }
  1634. .layout-content-right {
  1635. display: none; // 全屏时隐藏左侧导航栏
  1636. }
  1637. .viewer-header {
  1638. display: none; // 全屏时隐藏顶部标题栏
  1639. }
  1640. }
  1641. // 激光笔模式样式
  1642. &.laser-pen {
  1643. cursor: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABHNCSVQICAgIfAhkiAAACCJJREFUWIXtmLuO3MYShv/qZl9IzqwXo2BkSAtsIK+z8wwOBcOJ9C56Cr2LlThQcgBnfofVBnswXlgTaLHaIdk3dtcJOKOzd8n2MeDABRDDgKz/m+pudv0N/BN/Luj/kYSZJQBxJR8DKESU/2zuPwTIzAKnpxqHhxUuLir0vYSUAkS0ewA5F7Rtxv7+iNPTEYeHkYjKXwrIzHK9XtultRohaKSkkFIVhqGCEAIxTvm0ZpRSTNOMUGqEUgnGxLX3cblc+t9T2S8GXK1W9dP53OLiwoLZhMtLQ4CiGBVKkchZIOcpn5QMKQuEyKx1YiCZvb0AooD9ff/rZuMPDg7cl+hWn3uAmQWABut1g/PzOnZdTd5bMY6aQtAIQQGQGEd5bYirKgPIZExiY2IKIbK1XpeinzaN2s7b4XPD/iAgM0ucn7fYbNrQ963Juaauq8k5i3E01PcG46iQs0TO1wGlzJAyo6oS2jagqgLGUQNQwTllvJeYzwUz9w8N+b2AzCxwft6i72fBuZkYhnbcbBqKsSbvazhnEIJBzqrEqGQpAlO1AaKShShC6wQpE4UQUNcBKenReyXm8yoIIYwQtNXq7qvkQxVssNm0wbmZuLiYUQgtnGtps2ngfQ3vLaVkEKOmGKcqMtMWkEnKTFonaB3Z+4AQPFmreD6vSAghxpECAFMKY7EoALovBlytVjXW6yb0fSuGoaUQWrq8nKHvW/R9S943xbmavJ+qmNIO8FMFIWXert7A1gYxjprHsSLmaTHt7UF0HYdSilmv82q1ynctnFuAzCzx8aPF+Xltcq7HzaaBcy36vsUwzKjrZhiGRgxDA+8tUjIUgkbOEqVMgEIUkjLDmAjvgwjBI6WKxlHybp5KyVRKMcaMGIb0dLFIzBxvzsdbgOv12i69t7HrpgURY02bTYO+b6nrZui6qZLONdz3jTg5ORDHx0f48OExQpgBAIzp8OjRez46Oi7Pnq1ot5BKETQVgYmosJRj6rrEQNJCxLX3EUB/LyAzC3z8qOGcIe8tOWdpmm81ed9gGJpdJdF1rXz79jucnX1za454P8fZ2ZzOzr6Rx8fvyvPnP38afiEKVVXmqhrJ+wSlIqoqYj73S2s1M7urC0ZcS3x6qhGCDpeXBuOoMY4Gzhl4b4tzNYahgXMNuq4Vb978cCfczTg7+0a8efMDuq6Fcw2GoSnO1fDewjmDcTQYx0kzBI3TU3319euAh4cVUlIEKApBU98bhGAoJSO8N/Dect834u3b73B+/vVn4XZxfv61ePv2O+77Bt5b4b2hlKbcfW8oBE2AQkoKh4fXRvU64MVFhZQqilEhBLX9CCvEqLer1YiTk4MvqtxdlTw5OcAWDDFq5DxphDBtmSlNzcddgMws0fcyDEOFUiQAiZxliVGVGFVJSXEImo6Pj3433Dbo+PiIQ9AlJbXLi5wnrVIm7b6X223wOiAAASkFhBDIWWAcJXKWshQhcpYiZ0k5S3z48PhO9ZcvgV9+ma6XL+8m/PDhMW1ziW1u5Cy3WpO2lOIq11VAAhEhRkLO0z0RgVmAefotRXz6lNyMV6+AxWK6Xr26GzCEGXZb4i7nTifnSXv6Tn7qssTdmf4+cRWQwczQmiHldM/MICogmn6FKDDmzj0Tr18D5+fT9fr13WrGdBCiXMu505Fy0mZmTJYBwPUPdUHOBaUUSFlQVRlS5rzbtqTMJGXGo0fvcXY2vyX+44/T9VA8evSepcy8zcdCFDG1ZBlSTto5FwC3P9RElNG22TTNCCEygAwps9A6Ca2TUCqRMZGPjo4fprg/+OjomIyJQqm0ywspJy0hJu22zVf34+tzcH9/hFIja51gTEJVJUiZoHWEMQFKhfLs2QpPnrz73XRPnrwrz56toFSAMQFaR0g5aRiTWOsEpUbs749XX7u51Y1QKjGQ2JjIbRtgTGClQrE2wFpPbTuU589/xmLx2xfDLRa/lefPf6a2HWCtL9YG3oJy2wY2JjKQoFTC6ekDgIeHEcZEs7cXUFURVTV1wtZ6UdcOTTOgrgfMZn158eKnL6rkkyfvyosXP2E261HXA5pmEHXtYK1HXU9WoKomTWMiDg/j1devbStEVN6/fx+XRIGt9RhHjZQ0Wat4HCsax//1fEQlf//9v8XJyTF9rt1q2+mPtW2PphnY2gHWOrbWcV17ttaDKKy9j4/398u9gACwXC49Pn7UuhQNQI3eT206s2DadptCFEiZqaoS/+tfvnz77X/oRsPKUmYyJpJSAdZ6NM2Aphl4Pu/QND3P5wO0dmo2c5jNHPb3/fKrr/xNnluARJRXq5V/2jQqOKfE1kPsPC8zM1VVLkqNwpiAEAxbq+hGy89SZtq2/MXaIOrasbUDmqZH2/Zo257bdghSOtM07tfNxh/s799yd3d6koODA8fM0ngvw9bgYG9vatOJClfVSFUVYe3UldxhmiBlxtY0kVLTlLHW8Xw+oG17NqYvs1lv6rrHcjkcEN1p5B9ydQPmc2GEoABAdB1TKYWlnDph5wJvbSdPpwvXbCcLUXhrO2FMQF0HttZBa8dtO5TZrDdt26FtewDDfRD3AhJRYeYemKxh2Bqc1HVTm17Xn4y7yFnyDeMurhh33hp3rmuvZjMXpHSmrqehXiz6h04XHjxZIKLMzB0Wi2LW64xhSAwkVFXEOGpo/dmjD2yPPlBVka31mM2caRqH5XLAnz362FUSQLdarfLTxSJpISLmcx8uLw217R8/PLpnzt3S/5KHdvG3Pn67Afr3PMB8APgvOwL+J/5s/BeEBm1u1Gu4+QAAAABJRU5ErkJggg==) 20 20, default !important;
  1644. }
  1645. }
  1646. .layout-content-left {
  1647. width: 200px;
  1648. height: 100%;
  1649. background-color: #fff;
  1650. border-right: 1px solid #e0e0e0;
  1651. overflow-y: auto;
  1652. transition: width .2s ease;
  1653. }
  1654. .layout-content-left.collapsed {
  1655. width: 48px;
  1656. }
  1657. .slide-header {
  1658. display: flex;
  1659. align-items: center;
  1660. justify-content: space-between;
  1661. }
  1662. /* 收缩时头部仅显示按钮,并保持按钮在可用宽度内水平居中 */
  1663. .layout-content-left.collapsed .slide-header {
  1664. justify-content: center;
  1665. padding: 8px;
  1666. }
  1667. .layout-content-right {
  1668. width: 400px;
  1669. height: 100%;
  1670. background-color: #fff;
  1671. border-left: 1px solid #e0e0e0;
  1672. overflow-y: auto;
  1673. transition: width .2s ease;
  1674. position: relative;
  1675. }
  1676. .panel-content {
  1677. margin-right: 52px;
  1678. padding: 0 8px;
  1679. height: calc(100% - 76px);
  1680. overflow: auto;
  1681. }
  1682. .layout-content-right.collapsed {
  1683. width: 52px;
  1684. }
  1685. .right-panel-header {
  1686. display: flex;
  1687. align-items: center;
  1688. justify-content: space-between;
  1689. }
  1690. /* 侧边导航标签样式 */
  1691. .side-nav-tabs {
  1692. position: absolute;
  1693. right: 0;
  1694. top: 60px;
  1695. bottom: 0;
  1696. width: 52px;
  1697. display: flex;
  1698. flex-direction: column;
  1699. gap: 8px;
  1700. padding: 8px 0;
  1701. align-items: center;
  1702. background: #fff;
  1703. border-left: 1px solid #e0e0e0;
  1704. z-index: 10;
  1705. }
  1706. .side-nav-btn {
  1707. width: 45px;
  1708. height: 45px;
  1709. min-height: 45px;
  1710. border: 1px solid #d9d9d9;
  1711. background: #fff;
  1712. border-radius: 6px;
  1713. cursor: pointer;
  1714. transition: all 0.2s;
  1715. display: flex;
  1716. align-items: center;
  1717. justify-content: center;
  1718. padding: 8px;
  1719. gap: 8px;
  1720. overflow: hidden;
  1721. &:hover {
  1722. border-color: #1890ff;
  1723. transform: scale(1.02);
  1724. }
  1725. &.active {
  1726. border-color: #3681fc;
  1727. background: #3681fc;
  1728. box-shadow: 0 0 0 2px rgba(54, 129, 252, 0.2);
  1729. }
  1730. img {
  1731. width: 25px;
  1732. height: 25px;
  1733. object-fit: contain;
  1734. flex-shrink: 0;
  1735. }
  1736. span {
  1737. font-size: 12px;
  1738. font-weight: 500;
  1739. color: #333;
  1740. white-space: nowrap;
  1741. overflow: hidden;
  1742. text-overflow: ellipsis;
  1743. }
  1744. &.active span {
  1745. color: #fff;
  1746. }
  1747. }
  1748. /* 收缩时头部仅显示按钮,并保持按钮在可用宽度内水平居中 */
  1749. .layout-content-right.collapsed .right-panel-header {
  1750. justify-content: center;
  1751. padding: 8px;
  1752. }
  1753. /* 收缩状态下的切换按钮 */
  1754. .collapsed-tabs {
  1755. display: flex;
  1756. flex-direction: column;
  1757. gap: 8px;
  1758. // padding: 8px;
  1759. align-items: center;
  1760. }
  1761. .collapsed-tab-btn {
  1762. width: 32px;
  1763. height: 32px;
  1764. border: 1px solid #d9d9d9;
  1765. background: #fff;
  1766. border-radius: 6px;
  1767. cursor: pointer;
  1768. transition: all 0.2s;
  1769. display: flex;
  1770. align-items: center;
  1771. justify-content: center;
  1772. padding: 0;
  1773. overflow: hidden;
  1774. &:hover {
  1775. border-color: #1890ff;
  1776. transform: scale(1.05);
  1777. }
  1778. &.active {
  1779. border-color: #3681fc;
  1780. background: #3681fc;
  1781. box-shadow: 0 0 0 2px rgba(54, 129, 252, 0.2);
  1782. }
  1783. img {
  1784. width: 20px;
  1785. height: 20px;
  1786. object-fit: contain;
  1787. transition: transform 0.2s;
  1788. }
  1789. &:hover img {
  1790. transform: scale(1.1);
  1791. }
  1792. }
  1793. .collapse-btn {
  1794. display: inline-flex;
  1795. align-items: center;
  1796. justify-content: center;
  1797. width: 32px;
  1798. height: 32px;
  1799. border: 1px solid #d9d9d9;
  1800. border-radius: 8px;
  1801. background: #fff;
  1802. color: #333;
  1803. cursor: pointer;
  1804. line-height: 1;
  1805. font-weight: 700;
  1806. }
  1807. .collapse-btn:hover {
  1808. border-color: #1890ff;
  1809. color: #1890ff;
  1810. }
  1811. .homework-title {
  1812. padding: 12px 12px 0 12px;
  1813. color: #333;
  1814. font-size: 14px;
  1815. font-weight: 600;
  1816. }
  1817. .homework-grid {
  1818. display: grid;
  1819. grid-template-columns: repeat(4, 1fr);
  1820. gap: 16px;
  1821. padding: 12px;
  1822. }
  1823. .homework-btn {
  1824. display: inline-flex;
  1825. align-items: center;
  1826. justify-content: center;
  1827. width: 100%;
  1828. min-width: 0;
  1829. height: 35px;
  1830. border: 1px solid #2f80ed;
  1831. color: #2f80ed;
  1832. background: #fff;
  1833. border-radius: 8px;
  1834. cursor: pointer;
  1835. font-weight: 600;
  1836. overflow: hidden;
  1837. padding: 0 10px;
  1838. text-align: center;
  1839. }
  1840. .homework-btn__text {
  1841. display: block;
  1842. max-width: 100%;
  1843. overflow: hidden;
  1844. white-space: nowrap;
  1845. text-overflow: ellipsis;
  1846. }
  1847. .homework-btn:hover {
  1848. box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  1849. }
  1850. .homework-btn.unsubmitted {
  1851. border-color: #d9d9d9;
  1852. color: #999;
  1853. background: #f5f5f5;
  1854. cursor: not-allowed;
  1855. }
  1856. .homework-btn.unsubmitted:hover {
  1857. box-shadow: none;
  1858. transform: none;
  1859. }
  1860. .homework-loading {
  1861. padding: 12px;
  1862. color: #666;
  1863. font-size: 13px;
  1864. }
  1865. .homework-empty {
  1866. padding: 12px;
  1867. color: #999;
  1868. font-size: 13px;
  1869. }
  1870. .thumbnails {
  1871. padding: 0;
  1872. height: 100%;
  1873. .viewer-header {
  1874. margin-bottom: 16px;
  1875. h3 {
  1876. margin: 0;
  1877. font-size: 16px;
  1878. font-weight: 600;
  1879. color: #333;
  1880. }
  1881. }
  1882. .thumbnail-list {
  1883. width: 100%;
  1884. padding: 0 16px;
  1885. box-sizing: border-box;
  1886. .thumbnail-item {
  1887. position: relative;
  1888. margin-bottom: 12px;
  1889. cursor: pointer;
  1890. border-radius: 8px;
  1891. overflow: hidden;
  1892. transition: all 0.2s ease;
  1893. border: 2px solid rgba(24, 144, 255, 0.2);
  1894. &:hover {
  1895. transform: translateY(-2px);
  1896. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  1897. border-color: rgba(24, 144, 255, 0.4);
  1898. }
  1899. &.active {
  1900. border: 2px solid #1890ff;
  1901. box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  1902. }
  1903. .label {
  1904. position: absolute;
  1905. top: 8px;
  1906. left: 8px;
  1907. background-color: rgba(0, 0, 0, 0.6);
  1908. color: #fff;
  1909. padding: 2px 6px;
  1910. border-radius: 4px;
  1911. font-size: 12px;
  1912. font-weight: 600;
  1913. z-index: 1;
  1914. }
  1915. .thumbnail {
  1916. width: 100%;
  1917. height: auto;
  1918. }
  1919. }
  1920. }
  1921. .page-number {
  1922. text-align: center;
  1923. margin-top: 16px;
  1924. padding: 8px;
  1925. background-color: #f0f0f0;
  1926. border-radius: 4px;
  1927. font-size: 14px;
  1928. color: #666;
  1929. }
  1930. .progress-bar {
  1931. margin-top: 12px;
  1932. height: 6px;
  1933. background-color: #f0f0f0;
  1934. border-radius: 3px;
  1935. overflow: hidden;
  1936. .progress-fill {
  1937. height: 100%;
  1938. background: linear-gradient(90deg, #1890ff, #40a9ff);
  1939. border-radius: 3px;
  1940. transition: width 0.3s ease;
  1941. }
  1942. }
  1943. }
  1944. .layout-content-center {
  1945. flex: 1;
  1946. display: flex;
  1947. flex-direction: column;
  1948. background-color: #000;
  1949. }
  1950. .viewer-header {
  1951. height: 60px;
  1952. background-color: #fff;
  1953. border-bottom: 1px solid #e0e0e0;
  1954. display: flex;
  1955. align-items: center;
  1956. justify-content: space-between;
  1957. padding: 0 8px;
  1958. transition: transform 0.3s ease;
  1959. &.hidden {
  1960. transform: translateY(-100%);
  1961. }
  1962. .slide-title {
  1963. font-size: 18px;
  1964. font-weight: 600;
  1965. color: #333;
  1966. }
  1967. .viewer-controls {
  1968. display: flex;
  1969. gap: 12px;
  1970. button {
  1971. padding: 8px 12px;
  1972. border: 1px solid #d9d9d9;
  1973. border-radius: 6px;
  1974. background-color: #fff;
  1975. color: #333;
  1976. cursor: pointer;
  1977. transition: all 0.2s ease;
  1978. display: flex;
  1979. align-items: center;
  1980. justify-content: center;
  1981. min-width: 40px;
  1982. height: 36px;
  1983. &:hover:not(:disabled) {
  1984. border-color: #1890ff;
  1985. color: #1890ff;
  1986. }
  1987. &:disabled {
  1988. opacity: 0.5;
  1989. cursor: not-allowed;
  1990. }
  1991. &.back-btn {
  1992. background-color: #1890ff;
  1993. color: #fff;
  1994. border-color: #1890ff;
  1995. &:hover {
  1996. background-color: #40a9ff;
  1997. border-color: #40a9ff;
  1998. }
  1999. }
  2000. &.follow-active {
  2001. background-color: #3681fc;
  2002. color: #fff !important;
  2003. border-color: #3681fc;
  2004. &:hover {
  2005. background-color: #2d6fd9;
  2006. border-color: #2d6fd9;
  2007. color: #fff !important;
  2008. }
  2009. }
  2010. .control-icon {
  2011. font-size: 16px;
  2012. }
  2013. }
  2014. }
  2015. }
  2016. .viewer-canvas {
  2017. flex: 1;
  2018. position: relative;
  2019. background-color: rgb(249, 249, 249);
  2020. overflow: hidden;
  2021. // 全屏时隐藏滚动条和边框
  2022. &.fullscreen-mode {
  2023. overflow: hidden !important;
  2024. background-color: transparent !important;
  2025. }
  2026. }
  2027. .slide-list-wrap {
  2028. position: absolute;
  2029. overflow: hidden;
  2030. background-color: #fff;
  2031. box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.01), 0 0 12px 0 rgba(0, 0, 0, 0.1);
  2032. border-radius: 8px;
  2033. /* 全屏时去掉圆角 */
  2034. .pptist-student-viewer.fullscreen & {
  2035. border-radius: 0;
  2036. }
  2037. }
  2038. .loading-indicator {
  2039. position: absolute;
  2040. top: 50%;
  2041. left: 50%;
  2042. transform: translate(-50%, -50%);
  2043. display: flex;
  2044. align-items: center;
  2045. justify-content: center;
  2046. z-index: 10;
  2047. .loading-text {
  2048. color: #666;
  2049. font-size: 14px;
  2050. background-color: rgba(255, 255, 255, 0.9);
  2051. padding: 12px 20px;
  2052. border-radius: 6px;
  2053. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  2054. }
  2055. }
  2056. // 全屏模式样式
  2057. .fullscreen-slide {
  2058. // 使用放映功能的默认样式
  2059. }
  2060. // 全屏工具按钮样式,直接复制放映功能的样式
  2061. .tools-left {
  2062. position: fixed;
  2063. bottom: 8px;
  2064. left: 8px;
  2065. font-size: 25px;
  2066. color: #666;
  2067. z-index: 10;
  2068. .tool-btn {
  2069. opacity: .3;
  2070. cursor: pointer;
  2071. transition: opacity 0.3s;
  2072. &:hover {
  2073. opacity: .95;
  2074. }
  2075. &+.tool-btn {
  2076. margin-left: 8px;
  2077. }
  2078. }
  2079. }
  2080. .tools-right {
  2081. height: 66px;
  2082. position: fixed;
  2083. bottom: -66px;
  2084. right: 0;
  2085. z-index: 5;
  2086. padding: 8px;
  2087. transition: bottom 0.3s;
  2088. &.visible {
  2089. bottom: 0;
  2090. }
  2091. &::after {
  2092. content: '';
  2093. width: 100%;
  2094. height: 66px;
  2095. position: absolute;
  2096. left: 0;
  2097. top: -66px;
  2098. }
  2099. .content {
  2100. width: 100%;
  2101. height: 100%;
  2102. display: flex;
  2103. justify-content: center;
  2104. align-items: center;
  2105. border-radius: 4px;
  2106. font-size: 25px;
  2107. background-color: #fff;
  2108. color: #333;
  2109. padding: 8px 10px;
  2110. box-shadow: 0 2px 12px 0 rgb(56, 56, 56, .2);
  2111. border: 1px solid #e2e6ed;
  2112. }
  2113. .tool-btn {
  2114. cursor: pointer;
  2115. &:hover,
  2116. &.active {
  2117. color: #1890ff;
  2118. }
  2119. &+.tool-btn {
  2120. margin-left: 15px;
  2121. }
  2122. }
  2123. .page-number {
  2124. font-size: 12px;
  2125. padding: 0 12px;
  2126. cursor: pointer;
  2127. }
  2128. }
  2129. .viewport {
  2130. position: relative;
  2131. width: 100%;
  2132. height: 100%;
  2133. background-color: #fff;
  2134. }
  2135. .background {
  2136. width: 100%;
  2137. height: 100%;
  2138. background-position: center;
  2139. position: absolute;
  2140. }
  2141. // 响应式设计
  2142. @media (max-width: 768px) {
  2143. .layout-content-left {
  2144. width: 160px;
  2145. }
  2146. .layout-content-right {
  2147. width: 160px;
  2148. }
  2149. .viewer-header {
  2150. padding: 0 16px;
  2151. .slide-title {
  2152. font-size: 16px;
  2153. }
  2154. .viewer-controls button {
  2155. padding: 6px 12px;
  2156. font-size: 14px;
  2157. }
  2158. }
  2159. }
  2160. /* 作业提交按钮样式 */
  2161. .homework-submit-btn {
  2162. position: fixed;
  2163. bottom: 30px;
  2164. z-index: 100;
  2165. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  2166. color: white;
  2167. padding: 12px 20px;
  2168. border-radius: 25px;
  2169. cursor: pointer;
  2170. display: flex;
  2171. align-items: center;
  2172. gap: 8px;
  2173. box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  2174. transition: all 0.3s ease;
  2175. font-size: 14px;
  2176. font-weight: 500;
  2177. &:hover:not(.submitting) {
  2178. transform: translateY(-2px);
  2179. box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  2180. }
  2181. &:active:not(.submitting) {
  2182. transform: translateY(0);
  2183. }
  2184. &.submitting {
  2185. cursor: not-allowed;
  2186. opacity: 0.8;
  2187. background: linear-gradient(135deg, #999 0%, #666 100%);
  2188. }
  2189. .btn-text {
  2190. white-space: nowrap;
  2191. }
  2192. .tool-btn {
  2193. background: transparent;
  2194. color: white;
  2195. width: 20px;
  2196. height: 20px;
  2197. font-size: 16px;
  2198. &:hover {
  2199. background: transparent;
  2200. transform: none;
  2201. }
  2202. }
  2203. .loading-spinner {
  2204. width: 20px;
  2205. height: 20px;
  2206. border: 2px solid rgba(255, 255, 255, 0.3);
  2207. border-top: 2px solid white;
  2208. border-radius: 50%;
  2209. animation: spin 1s linear infinite;
  2210. }
  2211. }
  2212. /* 刷新网页按钮样式 */
  2213. .refresh-page-btn {
  2214. position: fixed;
  2215. bottom: 30px;
  2216. z-index: 100;
  2217. background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
  2218. color: white;
  2219. padding: 12px 20px;
  2220. border-radius: 25px;
  2221. cursor: pointer;
  2222. display: flex;
  2223. align-items: center;
  2224. gap: 8px;
  2225. box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  2226. transition: all 0.3s ease;
  2227. font-size: 14px;
  2228. font-weight: 500;
  2229. &:hover {
  2230. transform: translateY(-2px);
  2231. box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  2232. }
  2233. &:active {
  2234. transform: translateY(0);
  2235. }
  2236. .btn-text {
  2237. white-space: nowrap;
  2238. }
  2239. .tool-btn {
  2240. background: transparent;
  2241. color: white;
  2242. width: 20px;
  2243. height: 20px;
  2244. font-size: 16px;
  2245. display: flex;
  2246. align-items: center;
  2247. &:hover {
  2248. background: transparent;
  2249. transform: none;
  2250. }
  2251. }
  2252. }
  2253. /* Loading状态样式 */
  2254. .loading-overlay {
  2255. position: absolute;
  2256. top: 0;
  2257. left: 0;
  2258. right: 0;
  2259. bottom: 0;
  2260. background: rgba(255, 255, 255, 0.95);
  2261. display: flex;
  2262. align-items: center;
  2263. justify-content: center;
  2264. z-index: 1000;
  2265. .loading-spinner {
  2266. width: 40px;
  2267. height: 40px;
  2268. border: 4px solid #f3f3f3;
  2269. border-top: 4px solid #1890ff;
  2270. border-radius: 50%;
  2271. animation: spin 1s linear infinite;
  2272. margin: 0 auto 16px;
  2273. }
  2274. }
  2275. .loading-content {
  2276. text-align: center;
  2277. color: #666;
  2278. }
  2279. .loading-text {
  2280. font-size: 14px;
  2281. color: #666;
  2282. }
  2283. @keyframes spin {
  2284. 0% { transform: rotate(0deg); }
  2285. 100% { transform: rotate(360deg); }
  2286. }
  2287. </style>