index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <a-layout>
  3. <a-layout-sider v-model:collapsed="collapsed" :trigger="null" collapsible collapsedWidth="0">
  4. <div class="classTitle">
  5. <div>{{ classDetail.courseName }}</div>
  6. </div>
  7. <a-menu
  8. v-model:openKeys="openKeys"
  9. v-model:selectedKeys="selectedKeys"
  10. theme="dark"
  11. mode="inline"
  12. @click="menuClick"
  13. >
  14. <a-sub-menu :key="String(idx + 1)" v-for="(item, idx) in classTimeList">
  15. <template #title>{{ item.name }}</template>
  16. <a-menu-item :key="itemc.id" v-for="(itemc, idxc) in item.classHours">
  17. <span class="mr-2">
  18. <CheckSquareOutlined v-if="selectedKeys.includes(itemc.id)" />
  19. <BorderOutlined v-else />
  20. </span>
  21. <span>{{ itemc.name }}</span>
  22. </a-menu-item>
  23. </a-sub-menu>
  24. </a-menu>
  25. </a-layout-sider>
  26. <a-layout>
  27. <a-layout-header style="padding: 0 20px">
  28. <div class="flex-between">
  29. <div>
  30. <menu-unfold-outlined
  31. v-if="collapsed"
  32. class="trigger"
  33. @click="() => (collapsed = !collapsed)"
  34. style="font-size: 30px; color: #fff"
  35. />
  36. <menu-fold-outlined
  37. v-else
  38. class="trigger"
  39. @click="() => (collapsed = !collapsed)"
  40. style="font-size: 30px; color: #fff"
  41. />
  42. </div>
  43. <div @click="isLike">
  44. <a-tooltip title="收藏" style="cursor: pointer" :getPopupContainer="(trigger) => trigger.parentElement">
  45. <heart-outlined :style="{ 'font-size': '20px', color: classDetail.isCollect ? '#ff4d4f' : '#fff' }" />
  46. </a-tooltip>
  47. </div>
  48. </div>
  49. </a-layout-header>
  50. <a-layout-content style="overflow-y: auto">
  51. <a-card :bordered="false">
  52. <div v-if="videoUrl">
  53. <video
  54. style="height: 900px; width: 100%; background-color: #000"
  55. ref="videoRef"
  56. controls
  57. Controlslist="nodownload noplaybackrate noremoteplayback disablePictureInPicture"
  58. @timeupdate="timeUpdate"
  59. :currentTime="currentTimenew"
  60. :poster="videoPoster"
  61. >
  62. <source :src="videoUrl" type="video/mp4" />
  63. <source :src="videoUrl" type="video/ogg" />
  64. 您的浏览器不支持 HTML5 video 标签。
  65. </video>
  66. </div>
  67. <rightMenu
  68. :idsObj="idsObj"
  69. :dataList="classTimeData"
  70. ref="rightNenuRef"
  71. @videoSpeed="videoSpeed"
  72. @videoStopTime="videoStopTime"
  73. :videoObj="videoObj"
  74. :classDetailParams="classDetailParams"
  75. ></rightMenu>
  76. </a-card>
  77. <a-card :bordered="false" class="mt-3">
  78. <div>
  79. <div>
  80. <div v-for="(item, idx) in webCon">
  81. <a :href="item.href" target="_blank">{{ item.title }}</a>
  82. </div>
  83. </div>
  84. <a-divider />
  85. <div>
  86. 在小学和初中,我们已经接触过一些集合.例如,自然数的集合,同一平面内到一个定点的距离等于定长的点的集合(即圆)等.为了更有效地使用集合语言,我们需要进一步了解集合的有关知识.下面先从集合的含义开始.
  87. 看下面的例子:<br />
  88. (1)1~10之间的所有偶数;<br />
  89. (2)立德中学今年人学的全体高一学生;<br />
  90. (3)所有的正方形;<br />
  91. (4)到直线l的距离等于定长d的所有点<br />
  92. (5)方程x’-3x+2=0的所有实数根;<br />
  93. (6)地球上的四大洋.<br />
  94. 例(1)中,我们把1~10之间的每一个偶数作为元素,这些元素的全体就是一个集合;同样地,<br />
  95. 例(2)中,把立德中学今年人学的每一位高一学生作为元素,这些元素的全体也是一个集合.
  96. </div>
  97. </div>
  98. </a-card>
  99. <div style="display: flex; justify-content: center">
  100. <a-card :bordered="false" class="mt-2" style="width: 100%; padding-right: 30px">
  101. <a-tabs v-model:activeKey="tabsActiveKey">
  102. <a-tab-pane key="1" tab="讲义" style="height: 800px">
  103. <handouts
  104. :itemObj="itemObj"
  105. :hourId="classHourData.id"
  106. v-if="classHourData"
  107. :videoObj="videoObj"
  108. ></handouts>
  109. </a-tab-pane>
  110. <a-tab-pane key="2" tab="字幕" style="height: 800px">
  111. <subtitleBox :url="danmuObj.url" v-if="tabsActiveKey == 2" @videoSpeed="videoSpeed"></subtitleBox>
  112. </a-tab-pane>
  113. <a-tab-pane key="3" tab="笔记" style="min-height: 800px">
  114. <note
  115. :idsObj="idsObj"
  116. ref="noteRef"
  117. v-if="tabsActiveKey == 3"
  118. @videoSpeed="videoSpeed"
  119. @videoStopTime="videoStopTime"
  120. ></note>
  121. </a-tab-pane>
  122. <a-tab-pane key="4" tab="问答" style="min-height: 800px">
  123. <askDiv
  124. :idsObj="idsObj"
  125. ref="askDivRef"
  126. v-if="tabsActiveKey == 4"
  127. @videoSpeed="videoSpeed"
  128. @videoStopTime="videoStopTime"
  129. ></askDiv>
  130. </a-tab-pane>
  131. </a-tabs>
  132. </a-card>
  133. </div>
  134. <forumBtn :forumData="forumData" resourceType="0"></forumBtn>
  135. </a-layout-content>
  136. </a-layout>
  137. </a-layout>
  138. </template>
  139. <script setup name="classCentre">
  140. import classCentre from '@/api/student/classCentre'
  141. import rightMenu from './rightMenu.vue'
  142. import { useRoute, useRouter } from 'vue-router'
  143. import sysConfig from '@/config/index'
  144. import note from './note.vue'
  145. import askDiv from './ask.vue'
  146. import handouts from './handouts.vue'
  147. import subtitleBox from './subtitle.vue'
  148. import Broadcast from '@/utils/Broadcast.js'
  149. const route = useRoute()
  150. const router = useRouter()
  151. const classDetail = ref({})
  152. const classTimeList = ref([])
  153. const classTimeData = ref([])
  154. const openKeys = ref(['1'])
  155. const selectedKeys = ref([])
  156. const collapsed = ref(false)
  157. const videoRef = ref()
  158. const currentTimenew = ref(0)
  159. const idsObj = computed(() => {
  160. let item = findNodeByKey(classTimeList.value, selectedKeys.value[0], classTimeList.value[0])
  161. return {
  162. courseId: route.query.id,
  163. chapterId: selectedKeys.value[0],
  164. hourId: classHourData.value?.id,
  165. ...item
  166. }
  167. })
  168. function findNodeByKey(list, id, parent = null) {
  169. for (const item of list) {
  170. const itemWithParent = {
  171. ...item,
  172. parent: parent
  173. }
  174. if (itemWithParent.id === id) {
  175. return itemWithParent
  176. }
  177. if (item.classHours && Array.isArray(item.classHours)) {
  178. const found = findNodeByKey(item.classHours, id, itemWithParent)
  179. if (found) return found
  180. }
  181. }
  182. return null
  183. }
  184. const videoPoster = computed(() => {
  185. return classTimeData.value.find((r) => r.funcType == 0)?.url
  186. })
  187. const getClassData = () => {
  188. classCentre.addViewCount({ courseId: route.query.id })
  189. classCentre.courseDetail({ courseId: route.query.id }).then((data) => {
  190. classDetail.value = data
  191. classCentre.coursechapterList({ courseId: data.courseId }).then((data) => {
  192. classTimeList.value = data
  193. selectedKeys.value = selectedKeys.value[0] ? selectedKeys.value : [data[0]?.classHours[0].id]
  194. if (selectedKeys.value[0]) {
  195. menuClick()
  196. }
  197. })
  198. })
  199. }
  200. const getClassStatus = (e) => {
  201. classCentre
  202. .classGetStatus({
  203. examPaperId: e.relateId
  204. })
  205. .then((res) => {
  206. const idx = classTimeData.value.findIndex((item) => item.funcType == e.funcType)
  207. classTimeData.value[idx].status = res.isFinish
  208. classTimeData.value[idx].answerId = res.answerId
  209. })
  210. }
  211. const classHourData = ref()
  212. const rightNenuRef = ref()
  213. const menuClick = (e) => {
  214. rightNenuRef.value.onClose()
  215. if (e) {
  216. addClassPlan(1)
  217. }
  218. classCentre.courseTimeDetail({ id: e?.key ? e.key : selectedKeys.value[0] }).then((data) => {
  219. classHourData.value = data
  220. classTimeData.value = data.courseRelates.map((r) => {
  221. return {
  222. ...r,
  223. url: sysConfig.FILE_URL + r.url
  224. }
  225. })
  226. videoUrl.value = classTimeData.value.find((r) => r.funcType == 1)?.url
  227. nextTick(() => {
  228. videoRef.value.src = classTimeData.value.find((r) => r.funcType == 1)?.url
  229. videoStart()
  230. footprintClassAdd()
  231. getVideoTime()
  232. const funcType4Item = classTimeData.value.find((r) => r.funcType == 4)
  233. const funcType5Item = classTimeData.value.find((r) => r.funcType == 5)
  234. if (funcType4Item) {
  235. getClassStatus(funcType4Item)
  236. }
  237. if (funcType5Item) {
  238. getClassStatus(funcType5Item)
  239. }
  240. })
  241. })
  242. }
  243. const tabsActiveKey = ref('1')
  244. const noteRef = ref()
  245. const askDivRef = ref()
  246. const itemObj = computed(() => {
  247. let item = classTimeData.value.length > 0 ? classTimeData.value.find((r) => r.funcType == 2) : { url: '' }
  248. return item
  249. })
  250. const danmuObj = computed(() => {
  251. let item = classTimeData.value.length > 0 ? classTimeData.value.find((r) => r.funcType == 3) : { url: '' }
  252. return item
  253. })
  254. const videoUrl = ref('')
  255. const newsschedule = ref(0)
  256. const currTime = ref(null)
  257. const maxTime = ref(0)
  258. const initialtime = ref(0)
  259. const videoContext = ref()
  260. const timeStamp1 = ref()
  261. const allTime = ref()
  262. const biNum = ref()
  263. const currentTime = ref()
  264. const videoObj = computed(() => {
  265. return {
  266. initialtime: initialtime.value,
  267. currentTime: videoRef.value?.currentTime
  268. }
  269. })
  270. const videoStart = () => {
  271. videoContext.value = videoRef.value
  272. if (initialtime.value > 0) {
  273. videoContext.value.currentTime = initialtime.value
  274. timeStamp1.value = initialtime.value
  275. }
  276. }
  277. const timeUpdate = (e) => {
  278. //获取当前播放时间 durationinitialtime
  279. if (timeStamp1.value != parseInt(e.target.currentTime)) {
  280. allTime.value = parseInt(e.target.duration) //视频总时长(秒)
  281. //对播放的时间进行整
  282. timeStamp1.value = parseInt(e.target.currentTime) //播放进度 (秒)
  283. biNum.value = Math.floor((timeStamp1.value / allTime.value) * 10000) / 100 //暂时没用到
  284. currentTime.value = e.target.currentTime
  285. if (e.srcElement.currentTime - currTime.value > 3) {
  286. addClassPlan(3)
  287. }
  288. if (currTime.value - e.srcElement.currentTime > 3) {
  289. addClassPlan(3)
  290. }
  291. currTime.value = e.srcElement.currentTime
  292. }
  293. }
  294. const videoJumpTime = ref(false)
  295. const videoSpeed = (e) => {
  296. videoJumpTime.value = true
  297. currentTimenew.value = parseFloat(e.startTime)
  298. }
  299. const forumData = computed(() => {
  300. let item = findNodeByKey(classTimeList.value, selectedKeys.value[0], classTimeList.value[0]) ?? {}
  301. if (!item.src) {
  302. item.src = classTimeData.value.find((r) => r.funcType == 1)?.url
  303. }
  304. return {
  305. id: classHourData.value?.id,
  306. title: item.parent?.name,
  307. videoUrl: btoa(encodeURIComponent(videoRef.value?.src ? videoRef.value.src : item.src)),
  308. courseId: route.query.id,
  309. chapterId: selectedKeys.value[0],
  310. courseName: classDetail.value?.courseName,
  311. chapterName: classHourData.value?.name
  312. }
  313. })
  314. const showPdf = ref(true)
  315. function errorHandler() {
  316. showPdf.value = false
  317. }
  318. const getVideoTime = () => {
  319. classCentre
  320. .theLastDetail({
  321. funcType: 1,
  322. type: 1,
  323. hourId: classHourData.value?.id
  324. })
  325. .then((data) => {
  326. if (data.endTime) {
  327. initialtime.value = parseFloat(data.endTime) / 1000
  328. currentTimenew.value = parseFloat(data.endTime) / 1000
  329. }
  330. })
  331. }
  332. // 毫秒转换时分秒
  333. function msToHMS(ms) {
  334. if (typeof ms !== 'number' || isNaN(ms)) return '00:00:00'
  335. let totalSeconds = Math.floor(ms / 1000)
  336. let hours = String(Math.floor(totalSeconds / 3600)).padStart(2, '0')
  337. let minutes = String(Math.floor((totalSeconds % 3600) / 60)).padStart(2, '0')
  338. let seconds = String(totalSeconds % 60).padStart(2, '0')
  339. return `${hours}:${minutes}:${seconds}`
  340. }
  341. // 时分秒转换毫秒
  342. function hmsToMs(hms) {
  343. if (!hms) return 0
  344. const parts = hms.split(':').map((p) => parseFloat(p.replace(',', '.')))
  345. // 支持 hh:mm:ss 或 mm:ss
  346. let ms = 0
  347. if (parts.length === 3) {
  348. ms = (parts[0] * 3600 + parts[1] * 60 + parts[2]) * 1000
  349. } else if (parts.length === 2) {
  350. ms = (parts[0] * 60 + parts[1]) * 1000
  351. } else if (parts.length === 1) {
  352. ms = parts[0] * 1000
  353. }
  354. return ms
  355. }
  356. const nowTimesStr = Date.now()
  357. const outNowTimesStr = ref()
  358. const addClassPlan = (type) => {
  359. outNowTimesStr.value = Date.now()
  360. let progress = parseFloat((videoRef.value?.currentTime / videoRef.value?.duration) * 100)
  361. if (
  362. (progress || progress == 0) &&
  363. (initialtime.value || initialtime.value == 0) &&
  364. (videoRef.value.currentTime || videoRef.value.currentTime == 0)
  365. ) {
  366. classCentre.classPlanAdd({
  367. startTime: parseFloat(initialtime.value),
  368. endTime: Math.round(videoRef.value.currentTime * 1000),
  369. progress: Math.round(progress),
  370. hourId: classHourData.value?.id,
  371. stayTime: outNowTimesStr.value - nowTimesStr,
  372. type: type,
  373. funcType: 1,
  374. ...classDetailParams.value
  375. })
  376. }
  377. }
  378. const isLike = () => {
  379. classCentre
  380. .classCollectAdd(
  381. {
  382. courseId: route.query.id
  383. },
  384. classDetail.value.isCollect
  385. )
  386. .then(() => {
  387. classCentre.courseDetail({ courseId: route.query.id }).then((data) => {
  388. classDetail.value = data
  389. })
  390. })
  391. }
  392. const classDetailParams = computed(() => {
  393. return {
  394. hourName: classHourData.value?.name,
  395. chapterName: classHourData.value?.name,
  396. courseName: classDetail.value?.courseName,
  397. hourId: classHourData.value?.id,
  398. chapterId: selectedKeys.value[0],
  399. courseId: classDetail.value?.courseId,
  400. fileId: classHourData.value?.courseRelates.find((r) => r.funcType == 1)?.relateId,
  401. fileName: classHourData.value?.courseRelates.find((r) => r.funcType == 1)?.name,
  402. filePath: classHourData.value?.courseRelates.find((r) => r.funcType == 1)?.url
  403. }
  404. })
  405. //足迹
  406. const footprintClassAdd = () => {
  407. classCentre.footprintClassAdd({
  408. ...classDetailParams.value
  409. })
  410. }
  411. // 监听消息
  412. const stopListening = Broadcast.on('getClassDetail', (event) => {
  413. if (event.type == 1) {
  414. getClassData()
  415. }
  416. })
  417. const videoStopTime = (callback) => {
  418. videoRef.value.pause()
  419. callback && callback(videoRef.value.currentTime)
  420. }
  421. const webCon = ref([
  422. {
  423. title: '1.1 集合的概念',
  424. href: '/webEmpty'
  425. },
  426. {
  427. title: '1.2 集合间的基本关系',
  428. href: '/webEmpty'
  429. },
  430. {
  431. title: '1.3 集合的基本运算',
  432. href: '/webEmpty'
  433. },
  434. {
  435. title: '1.4 充分条件与必要条件',
  436. href: '/webEmpty'
  437. },
  438. {
  439. title: '1.5 全称量词与存在量词',
  440. href: '/webEmpty'
  441. }
  442. ])
  443. onMounted(() => {
  444. getClassData()
  445. })
  446. onBeforeUnmount(() => {
  447. stopListening()
  448. addClassPlan(1)
  449. })
  450. </script>
  451. <style scoped lang="less">
  452. .classTitle {
  453. height: 64px;
  454. width: 200px;
  455. font-size: 18px;
  456. color: #ccc;
  457. display: flex;
  458. justify-content: center;
  459. align-items: center;
  460. }
  461. .flex-between {
  462. display: flex;
  463. justify-content: space-between;
  464. }
  465. </style>