index.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
  1. <template>
  2. <div class="common-preview">
  3. <div class="common-preview__header">
  4. <div class="courseware">
  5. <span class="flow-nodename">{{ courseware_info.cur_audit_flow_node_name }}</span>
  6. <slot name="middle" :courseware="courseware_info"></slot>
  7. <div class="group">
  8. <el-checkbox v-model="isShowGroup">显示分组</el-checkbox>
  9. <el-checkbox v-model="groupShowAll">分组显示全部</el-checkbox>
  10. <el-checkbox v-model="isJudgeCorrect">判断对错</el-checkbox>
  11. <el-checkbox v-model="isShowAnswer" :disabled="!isJudgeCorrect">显示答案</el-checkbox>
  12. </div>
  13. <span class="link">
  14. <el-select v-model="lang" placeholder="请选择语言" size="mini" class="lang-select">
  15. <el-option v-for="item in langList" :key="item.type" :label="item.name" :value="item.type" />
  16. </el-select>
  17. </span>
  18. <div class="operator">
  19. <slot name="operator" :courseware="courseware_info"></slot>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="audit-content">
  24. <!-- 左侧菜单栏 -->
  25. <aside v-if="navigationShow" class="left-menu">
  26. <div class="courseware-info">
  27. <div class="cover-image">
  28. <img v-if="project.cover_image_file_url.length > 0" :src="project.cover_image_file_url" alt="cover-image" />
  29. </div>
  30. <div class="info-content">
  31. <div class="catalogue-icon" @click="toggleNavigationShow">
  32. <SvgIcon icon-class="catalogue" size="54" />
  33. </div>
  34. <div class="courseware">
  35. <div class="name nowrap-ellipsis" :title="courseware_info.book_name">
  36. {{ courseware_info.book_name }}
  37. </div>
  38. <div class="editor" :title="project.editor">
  39. {{ project.editor }}
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <!-- 教材章节树 -->
  45. <div class="courseware-tree">
  46. <div
  47. v-for="{ id: nodeId, name, deep, is_leaf_chapter } in node_list"
  48. :key="nodeId"
  49. :class="['menu-item', { active: curSelectId === nodeId }, { courseware: isTrue(is_leaf_chapter) }]"
  50. :style="computedNameStyle(deep, isTrue(is_leaf_chapter))"
  51. @click="selectChapterNode(nodeId, isTrue(is_leaf_chapter))"
  52. >
  53. <span class="name nowrap-ellipsis" :title="name">
  54. {{ name }}
  55. </span>
  56. </div>
  57. </div>
  58. </aside>
  59. <div
  60. ref="previewMain"
  61. class="main-container"
  62. :style="{ paddingLeft: navigationShow ? '15px' : '315px', paddingRight: sidebarShow ? '15px' : '315px' }"
  63. >
  64. <!-- 左侧菜单栏 - 收缩 -->
  65. <div v-if="!navigationShow" class="catalogue-bar" @click="toggleNavigationShow">
  66. <SvgIcon icon-class="catalogue" size="54" />
  67. </div>
  68. <main :class="['preview-main']">
  69. <div class="preview-left"></div>
  70. <CoursewarePreview
  71. v-if="courseware_info.book_name"
  72. ref="courserware"
  73. :is-show-group="isShowGroup"
  74. :group-show-all="groupShowAll"
  75. :group-row-list="content_group_row_list"
  76. :data="data"
  77. :component-list="component_list"
  78. :background="background"
  79. :can-remark="isTrue(courseware_info.is_my_audit_task) && isTrue(courseware_info.is_can_add_audit_remark)"
  80. :show-remark="false"
  81. :project="project"
  82. :component-remark-obj="remark_list_obj"
  83. @computeScroll="computeScroll"
  84. />
  85. <div class="preview-right"></div>
  86. </main>
  87. <!-- 右侧菜单栏 - 收缩 -->
  88. <aside v-if="!sidebarShow" class="sidebar-bar">
  89. <aside class="toolbar">
  90. <div class="toolbar-special">
  91. <!-- <img :src="require('@/assets/icon/sidebar-fullscreen.png')" alt="全屏" />
  92. <img :src="require('@/assets/icon/sidebar-toolkit.png')" alt="工具箱" /> -->
  93. <img :src="require(`@/assets/icon/arrow-down.png`)" alt="伸缩" @click="toggleSidebarShow" />
  94. </div>
  95. </aside>
  96. </aside>
  97. </div>
  98. <div v-if="!sidebarShow" class="back-top" @click="backTop">
  99. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  100. </div>
  101. <!-- 右侧工具栏 -->
  102. <aside v-if="sidebarShow" ref="sidebarMenu" class="sidebar">
  103. <aside class="toolbar">
  104. <div class="toolbar-special">
  105. <!-- <img :src="require('@/assets/icon/sidebar-fullscreen.png')" alt="全屏" />
  106. <img :src="require('@/assets/icon/sidebar-toolkit.png')" alt="工具箱" /> -->
  107. </div>
  108. <div v-if="sidebarShow" class="toolbar-list">
  109. <div
  110. v-for="{ icon, title, handle, param } in sidebarIconList"
  111. :key="icon"
  112. :class="['sidebar-item', { active: curToolbarIcon === icon }]"
  113. :title="title"
  114. @click="handleSidebarClick(handle, param, icon)"
  115. >
  116. <div
  117. class="sidebar-icon icon-mask"
  118. :style="{
  119. backgroundColor: curToolbarIcon === icon ? '#fff' : '#1E2129',
  120. maskImage: `url(${require(`@/assets/icon/sidebar-${icon}.png`)})`,
  121. }"
  122. ></div>
  123. </div>
  124. </div>
  125. <div class="adjustable" @click="toggleSidebarShow">
  126. <img :src="require(`@/assets/icon/arrow-up.png`)" alt="伸缩" />
  127. </div>
  128. </aside>
  129. <div class="content">
  130. <el-drawer
  131. custom-class="custom-drawer"
  132. :visible="drawerType.length > 0"
  133. :with-header="false"
  134. :modal="false"
  135. size="240"
  136. direction="ltr"
  137. :style="drawerStyle"
  138. >
  139. <div class="infinite-list-wrapper">
  140. <h5>{{ drawerTitle }}</h5>
  141. <ul
  142. v-infinite-scroll="loadMore"
  143. class="scroll-container"
  144. infinite-scroll-disabled="disabled"
  145. :infinite-scroll-immediate="false"
  146. >
  147. <li
  148. v-for="(item, index) in file_list"
  149. :key="index"
  150. class="list-item"
  151. @click="handleFileClick(item?.courseware_id, item?.component_id)"
  152. >
  153. <template v-if="parseInt(drawerType) === 0">
  154. <el-image :src="item.file_url" fit="contain" />
  155. <!-- <span class="text-box">{{ item.file_name.slice(0, item.file_name.lastIndexOf('.')) }}</span> -->
  156. </template>
  157. <template v-else-if="parseInt(drawerType) === 1">
  158. <AudioPlay
  159. view-size="middle"
  160. :file-id="item.file_id"
  161. :file-name="item.file_name.slice(0, item.file_name.lastIndexOf('.'))"
  162. :show-slider="true"
  163. :audio-index="index"
  164. />
  165. </template>
  166. <template v-else-if="parseInt(drawerType) === 2">
  167. <VideoPlay view-size="small" :file-id="item.file_id" :video-index="index" />
  168. <!-- <span class="text-box">{{ item.file_name.slice(0, item.file_name.lastIndexOf('.')) }}</span> -->
  169. </template>
  170. </li>
  171. </ul>
  172. <p v-if="loading">加载中...</p>
  173. <p v-if="noMore">没有更多了</p>
  174. </div>
  175. </el-drawer>
  176. </div>
  177. <div class="back-top" @click="backTop">
  178. <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
  179. </div>
  180. </aside>
  181. </div>
  182. <el-dialog title="" :visible="visibleMindMap" width="1100px" class="audit-dialog" @close="dialogClose('MindMap')">
  183. <MindMap
  184. v-if="isChildDataLoad"
  185. ref="mindMapRef"
  186. :project-id="projectId"
  187. :mind-map-json-data="mindMapJsonData"
  188. @child-click="handleNodeClick"
  189. />
  190. </el-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import CoursewarePreview from '@/views/book/courseware/preview/CoursewarePreview.vue';
  195. import { isTrue } from '@/utils/validate';
  196. import MindMap from '@/components/MindMap.vue';
  197. import VideoPlay from '@/views/book/courseware/preview/components/common/VideoPlay.vue';
  198. import AudioPlay from '@/views/book/courseware/preview/components/common/AudioPlay.vue';
  199. import * as OpenCC from 'opencc-js';
  200. import { GetBookCoursewareInfo, GetCoursewareAuditRemarkList, GetProjectInfo } from '@/api/project';
  201. import {
  202. ContentGetCoursewareContent_View,
  203. ChapterGetBookChapterStructExpandList,
  204. GetBookBaseInfo,
  205. MangerGetBookMindMap,
  206. PageQueryBookResourceList,
  207. GetLanguageTypeList,
  208. GetBookUnifiedAttrib,
  209. } from '@/api/book';
  210. export default {
  211. name: 'CommonPreview',
  212. components: {
  213. CoursewarePreview,
  214. MindMap,
  215. VideoPlay,
  216. AudioPlay,
  217. },
  218. provide() {
  219. return {
  220. getLang: () => this.lang,
  221. getChinese: () => this.chinese,
  222. getLangList: () => this.langList,
  223. convertText: this.convertText,
  224. getProjectId: () => this.projectId,
  225. getSelectId: () => this.select_node,
  226. };
  227. },
  228. data() {
  229. const sidebarIconList = [
  230. // { icon: 'search', title: '搜索', handle: '', param: {} },
  231. { icon: 'mindmap', title: '思维导图', handle: 'openMindMap', param: {} },
  232. // { icon: 'knowledge', title: '知识图谱', handle: '', param: {} },
  233. // { icon: 'totalResources', title: '总资源', handle: '', param: {} },
  234. // { icon: 'collect', title: '收藏', handle: '', param: {} },
  235. { icon: 'audio', title: '音频', handle: 'openDrawer', param: { type: '1' } },
  236. { icon: 'image', title: '图片', handle: 'openDrawer', param: { type: '0' } },
  237. { icon: 'video', title: '视频', handle: 'openDrawer', param: { type: '2' } },
  238. // { icon: 'note', title: '笔记', handle: '', param: {} },
  239. // { icon: 'translate', title: '翻译', handle: '', param: {} },
  240. // { icon: 'setting', title: '设置', handle: '', param: {} },
  241. ];
  242. return {
  243. projectId: this.$route.query.book_id || '',
  244. select_node: this.id,
  245. courseware_info: {
  246. book_name: '',
  247. is_can_start_edit: 'false',
  248. is_can_submit_audit: 'false',
  249. is_can_audit_pass: 'false',
  250. is_can_audit_reject: 'false',
  251. is_can_add_audit_remark: 'false',
  252. is_can_finish_audit: 'false',
  253. is_can_request_shangjia_book: 'false',
  254. is_can_request_rollback_project: 'false',
  255. is_can_shangjia_book: 'false',
  256. is_can_rollback_project: 'false',
  257. },
  258. background: {
  259. background_image_url: '',
  260. background_position: {
  261. left: 0,
  262. top: 0,
  263. },
  264. },
  265. node_list: [],
  266. data: { row_list: [] },
  267. component_list: [],
  268. content_group_row_list: [],
  269. remark_list: [],
  270. remark_list_obj: {}, // 存放以组件为对象的数组
  271. visible: false,
  272. remark_content: '',
  273. submit_loading: false,
  274. isTrue,
  275. menuPosition: {
  276. x: -1,
  277. y: -1,
  278. componentId: 'WHOLE',
  279. },
  280. curToolbarIcon: this.isShowAudit ? 'audit' : '',
  281. sidebarIconList,
  282. visibleMindMap: false,
  283. isChildDataLoad: false,
  284. mindMapJsonData: {}, // 思维导图json数据
  285. drawerType: '', // 抽屉类型
  286. drawerStyle: {
  287. top: '0',
  288. height: '0',
  289. right: '0',
  290. },
  291. page_capacity: 10,
  292. cur_page: 1,
  293. file_list: [],
  294. total_count: 0,
  295. loading: true,
  296. lastLoadTime: 0,
  297. minLoadInterval: 3 * 1000,
  298. isShowGroup: false,
  299. groupShowAll: true,
  300. opencc: OpenCC.Converter({ from: 'cn', to: 'tw' }),
  301. langList: [],
  302. lang: 'ZH',
  303. chinese: 'zh-Hans',
  304. isJudgeCorrect: false,
  305. isShowAnswer: false,
  306. unified_attrib: {},
  307. curSelectId: this.id,
  308. navigationShow: true,
  309. sidebarShow: true,
  310. project: {
  311. editor: '', // 作者
  312. cover_image_file_id: null, // 封面图片ID
  313. cover_image_file_url: '', // 封面图片URL
  314. },
  315. };
  316. },
  317. computed: {
  318. disabled() {
  319. const result = this.loading || this.noMore;
  320. return result;
  321. },
  322. noMore() {
  323. const result = this.file_list.length >= this.total_count;
  324. return result;
  325. },
  326. drawerTitle() {
  327. const titleMap = {
  328. 0: '图片资源',
  329. 1: '音频资源',
  330. 2: '视频资源',
  331. };
  332. return titleMap[this.drawerType] || '资源列表';
  333. },
  334. },
  335. watch: {
  336. isJudgeCorrect(newVal) {
  337. if (!newVal) {
  338. this.isShowAnswer = false;
  339. }
  340. this.simulateAnswer(newVal);
  341. },
  342. isShowAnswer() {
  343. this.simulateAnswer();
  344. },
  345. },
  346. mounted() {
  347. this.calcDrawerPosition();
  348. },
  349. created() {
  350. this.getBookBaseInfo();
  351. this.getBookChapterStructExpandList();
  352. this.getBookUnifiedAttr();
  353. this.getProjectInfo();
  354. },
  355. methods: {
  356. getBookBaseInfo() {
  357. GetBookBaseInfo({ id: this.projectId }).then(({ book_info }) => {
  358. this.courseware_info = { ...this.courseware_info, ...book_info, book_name: book_info.name };
  359. if (book_info.cover_image_file_id) {
  360. this.project.cover_image_file_url = book_info.cover_image_file_url;
  361. }
  362. if (book_info.editor) {
  363. this.project.editor = book_info.editor;
  364. }
  365. if (book_info.cover_image_file_url) {
  366. this.project.cover_image_file_url = book_info.cover_image_file_url;
  367. }
  368. });
  369. },
  370. getProjectInfo() {
  371. GetProjectInfo({ id: this.projectId }).then(({ project_info }) => {
  372. if (project_info.cover_image_file_url) {
  373. this.project = project_info;
  374. }
  375. });
  376. },
  377. /**
  378. * 得到教材课件信息
  379. * @param {string} id - 课件ID
  380. */
  381. getBookCoursewareInfo(id) {
  382. GetBookCoursewareInfo({ id, is_contain_producer: 'true', is_contain_auditor: 'true' }).then(
  383. ({ courseware_info }) => {
  384. this.courseware_info = { ...this.courseware_info, ...courseware_info };
  385. this.getLangList();
  386. },
  387. );
  388. },
  389. /**
  390. * 得到课件内容(展示内容)
  391. * @param {string} id - 课件ID
  392. */
  393. getCoursewareComponentContent_View(id) {
  394. ContentGetCoursewareContent_View({ id }).then(({ content, component_list, content_group_row_list }) => {
  395. if (content) {
  396. const _content = JSON.parse(content);
  397. this.data = _content;
  398. this.background = {
  399. background_image_url: _content.background_image_url,
  400. background_position: _content.background_position,
  401. };
  402. } else {
  403. this.data = { row_list: [] };
  404. }
  405. if (component_list) this.component_list = component_list;
  406. if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
  407. });
  408. },
  409. getLangList() {
  410. GetLanguageTypeList({ book_id: this.courseware_info.book_id, is_contain_zh: 'true' }).then(
  411. ({ language_type_list }) => {
  412. this.langList = language_type_list;
  413. },
  414. );
  415. },
  416. /**
  417. * 得到教材章节结构展开列表
  418. */
  419. getBookChapterStructExpandList() {
  420. ChapterGetBookChapterStructExpandList({
  421. book_id: this.projectId,
  422. node_deep_mode: 0,
  423. is_contain_producer: 'true',
  424. is_contain_auditor: 'true',
  425. }).then(({ node_list }) => {
  426. this.node_list = node_list;
  427. });
  428. },
  429. getBookUnifiedAttr() {
  430. GetBookUnifiedAttrib({ book_id: this.projectId }).then(({ content }) => {
  431. if (content) {
  432. this.unified_attrib = JSON.parse(content);
  433. }
  434. });
  435. },
  436. /**
  437. * 选择节点
  438. * @param {string} nodeId - 节点ID
  439. */
  440. selectNode(nodeId) {
  441. this.getCoursewareComponentContent_View(nodeId);
  442. this.getBookCoursewareInfo(nodeId);
  443. this.getCoursewareAuditRemarkList(nodeId);
  444. this.select_node = nodeId;
  445. },
  446. // 审校批注列表
  447. getCoursewareAuditRemarkList(id) {
  448. this.remark_list = [];
  449. let remarkListObj = {};
  450. GetCoursewareAuditRemarkList({
  451. courseware_id: id,
  452. }).then(({ remark_list }) => {
  453. this.remark_list = remark_list;
  454. if (!remark_list) return;
  455. remarkListObj = remark_list.reduce((acc, item) => {
  456. if (!acc[item.component_id]) {
  457. acc[item.component_id] = [];
  458. }
  459. acc[item.component_id].push(item);
  460. return acc;
  461. }, {});
  462. this.remark_list_obj = remarkListObj;
  463. });
  464. },
  465. dialogClose(type) {
  466. this[`visible${type}`] = false;
  467. },
  468. // 计算previewMain滑动距离
  469. computeScroll() {
  470. this.$refs.courserware.handleResult(
  471. this.$refs.previewMain.scrollTop,
  472. this.$refs.previewMain.scrollLeft,
  473. this.select_node,
  474. );
  475. },
  476. /**
  477. * 处理侧边栏图标点击事件
  478. * @param {string} handle - 处理函数名
  479. * @param {any} param - 处理函数参数
  480. * @param {string} icon - 图标名称
  481. */
  482. handleSidebarClick(handle, param, icon) {
  483. if (typeof handle === 'string' && handle && typeof this[handle] === 'function') {
  484. this[handle](param);
  485. }
  486. this.curToolbarIcon = icon;
  487. },
  488. openMindMap() {
  489. MangerGetBookMindMap({ book_id: this.projectId }).then(({ content }) => {
  490. if (content) {
  491. this.mindMapJsonData = JSON.parse(content);
  492. this.isChildDataLoad = true;
  493. }
  494. });
  495. this.visibleMindMap = true;
  496. },
  497. async handleNodeClick(data) {
  498. let [nodeId, componentId] = data.split('#');
  499. if (nodeId) this.selectNode(nodeId);
  500. if (componentId) {
  501. let node = await this.$refs.courserware.findChildComponentByKey(componentId);
  502. if (node) {
  503. await this.$nextTick();
  504. this.$refs.previewMain.scrollTo({
  505. top: node.$el.offsetTop - 50,
  506. left: node.$el.offsetLeft - 50,
  507. behavior: 'smooth',
  508. });
  509. }
  510. }
  511. this.visibleMindMap = false;
  512. },
  513. // 计算抽屉滑出位置
  514. calcDrawerPosition() {
  515. const menu = this.$refs.sidebarMenu;
  516. if (menu) {
  517. const rect = menu.getBoundingClientRect();
  518. this.drawerStyle = {
  519. top: `${rect.top}px`,
  520. height: `${rect.height}px`,
  521. left: `${rect.right - 240}px`,
  522. };
  523. }
  524. },
  525. /**
  526. * 打开抽屉并初始化加载
  527. * @param {Object} param - 抽屉参数
  528. * @param {string} param.type - 抽屉类型(0: 图片, 1: 音频, 2: 视频)
  529. */
  530. openDrawer({ type }) {
  531. if (this.drawerType === type) {
  532. this.drawerType = '';
  533. return;
  534. }
  535. // 重置所有加载状态
  536. this.resetLoadState();
  537. this.drawerType = type; // 假设这是你的类型变量
  538. this.$nextTick(() => {
  539. // 确保DOM更新后触发加载
  540. this.loadMore();
  541. });
  542. },
  543. openAudit() {},
  544. resetLoadState() {
  545. this.cur_page = 1;
  546. this.file_list = [];
  547. this.total_count = 0;
  548. this.loading = false;
  549. this.lastLoadTime = 0; // 重置时间戳,允许立即加载
  550. this.loadCount = 0;
  551. },
  552. // 加载更多数据
  553. async loadMore() {
  554. const now = Date.now();
  555. // 只有当lastLoadTime不为0(不是第一次)且时间间隔太短时才return
  556. if (this.lastLoadTime > 0 && now - this.lastLoadTime < this.minLoadInterval) {
  557. return;
  558. }
  559. if (this.disabled || this.loading) {
  560. if (this.lastLoadTime > 0) {
  561. return;
  562. }
  563. }
  564. this.loading = true;
  565. const params = {
  566. page_capacity: this.page_capacity,
  567. cur_page: this.cur_page,
  568. book_id: this.projectId,
  569. type: parseInt(this.drawerType),
  570. };
  571. await PageQueryBookResourceList(params)
  572. .then(({ total_count, resource_list }) => {
  573. this.total_count = total_count;
  574. // 记录加载前的滚动高度
  575. const scrollContainer = this.$el.querySelector('.el-drawer__body');
  576. const isAtBottom = this.isScrollAtBottom(scrollContainer);
  577. this.file_list = this.cur_page === 1 ? resource_list : [...this.file_list, ...resource_list];
  578. if (!resource_list || resource_list.length === 0) {
  579. return;
  580. }
  581. this.cur_page += 1;
  582. // 只有当前已经在底部时才微调滚动位置
  583. if (isAtBottom) {
  584. this.$nextTick(() => {
  585. // 轻微向上滚动,创造滚动空间
  586. scrollContainer.scrollTop -= 5;
  587. });
  588. }
  589. })
  590. .finally(() => {
  591. this.loading = false;
  592. this.lastLoadTime = now;
  593. });
  594. },
  595. isScrollAtBottom(container) {
  596. if (!container) return false;
  597. return container.scrollHeight - container.scrollTop <= container.clientHeight + 5;
  598. },
  599. async handleFileClick(courseware_id, component_id) {
  600. if (courseware_id) this.selectNode(courseware_id);
  601. if (component_id) {
  602. let node = await this.$refs.courserware.findChildComponentByKey(component_id);
  603. if (node) {
  604. await this.$nextTick();
  605. this.$refs.previewMain.scrollTo({
  606. top: node.offsetTop - 50,
  607. left: node.offsetLeft - 50,
  608. behavior: 'smooth',
  609. });
  610. }
  611. }
  612. },
  613. /**
  614. * 文本转换
  615. * @param {string} text - 要转换的文本
  616. * @returns {string} - 转换后的文本
  617. */
  618. convertText(text) {
  619. if (this.chinese === 'zh-Hant' && this.opencc) {
  620. return this.opencc(text);
  621. }
  622. return text;
  623. },
  624. simulateAnswer(disabled = true) {
  625. this.$refs.courserware.simulateAnswer(this.isJudgeCorrect, this.isShowAnswer, disabled);
  626. },
  627. /**
  628. * 选择节点
  629. * @param {string} nodeId - 节点ID
  630. * @param {boolean} isLeaf - 是否是叶子节点
  631. */
  632. selectChapterNode(nodeId, isLeaf) {
  633. if (!isLeaf) return;
  634. if (this.curSelectId === nodeId) return;
  635. this.curSelectId = nodeId;
  636. this.selectNode(nodeId);
  637. },
  638. /**
  639. * 计算章节名称样式
  640. * @param {number} deep - 节点深度
  641. * @param {boolean} isLeaf - 是否是叶子节点
  642. * @returns {Object} - 样式对象
  643. */
  644. computedNameStyle(deep, isLeaf) {
  645. return {
  646. 'padding-left': `${(deep - 1) * 8}px`,
  647. cursor: isLeaf ? 'pointer' : 'auto',
  648. };
  649. },
  650. /**
  651. * 切换左侧导航栏显示与隐藏
  652. */
  653. toggleNavigationShow() {
  654. this.navigationShow = !this.navigationShow;
  655. },
  656. /**
  657. * 切换右侧工具栏显示与隐藏
  658. */
  659. toggleSidebarShow() {
  660. this.sidebarShow = !this.sidebarShow;
  661. },
  662. backTop() {
  663. this.$refs.previewMain.scrollTo({
  664. top: 0,
  665. left: 0,
  666. behavior: 'smooth',
  667. });
  668. },
  669. },
  670. };
  671. </script>
  672. <style lang="scss" scoped>
  673. @use '@/styles/mixin.scss' as *;
  674. $total-width: $courseware-width + $courseware-left-margin + $courseware-right-margin;
  675. .common-preview {
  676. &__header {
  677. position: sticky;
  678. top: 0;
  679. left: 0;
  680. z-index: 9;
  681. display: flex;
  682. align-items: center;
  683. height: 40px;
  684. padding: 6px 4px;
  685. margin-bottom: 5px;
  686. background-color: #fff;
  687. border-top: $border;
  688. border-bottom: $border;
  689. > .courseware {
  690. display: flex;
  691. flex-grow: 1;
  692. column-gap: 16px;
  693. align-items: center;
  694. justify-content: space-between;
  695. height: 40px;
  696. .lang-select {
  697. :deep .el-input {
  698. width: 100px;
  699. }
  700. :deep .el-input__inner {
  701. height: 24px;
  702. line-height: 24px;
  703. background-color: #fff;
  704. }
  705. :deep .el-input__icon {
  706. line-height: 24px;
  707. }
  708. }
  709. .flow-nodename {
  710. flex: 1;
  711. }
  712. .group {
  713. display: flex;
  714. align-items: center;
  715. }
  716. .operator {
  717. display: flex;
  718. column-gap: 8px;
  719. align-items: center;
  720. .link {
  721. + .link {
  722. margin-left: 0;
  723. &::before {
  724. margin-right: 8px;
  725. color: #999;
  726. content: '|';
  727. }
  728. }
  729. }
  730. }
  731. }
  732. }
  733. .main-container {
  734. position: relative;
  735. flex: 1;
  736. min-width: 1110px;
  737. padding: 15px 0;
  738. overflow: auto;
  739. background-color: #ececec;
  740. .catalogue-bar {
  741. position: absolute;
  742. top: 15px;
  743. left: 0;
  744. display: flex;
  745. align-items: center;
  746. justify-content: center;
  747. width: 54px;
  748. height: 54px;
  749. margin: -9px 6px 0 240px;
  750. cursor: pointer;
  751. background-color: #fff;
  752. border-radius: 2px;
  753. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  754. }
  755. .sidebar-bar {
  756. position: absolute;
  757. top: 0;
  758. right: 240px;
  759. display: flex;
  760. width: 60px;
  761. height: calc(100vh - 166px);
  762. .toolbar {
  763. display: flex;
  764. flex-direction: column;
  765. align-items: center;
  766. width: 60px;
  767. height: 100%;
  768. img {
  769. cursor: pointer;
  770. }
  771. &-special {
  772. display: flex;
  773. flex-direction: column;
  774. row-gap: 16px;
  775. align-items: center;
  776. width: 100%;
  777. margin-bottom: 24px;
  778. background-color: #fff;
  779. img {
  780. width: 36px;
  781. height: 36px;
  782. }
  783. }
  784. }
  785. }
  786. }
  787. .back-top {
  788. position: absolute;
  789. right: 240px;
  790. bottom: 0;
  791. display: flex;
  792. place-content: center center;
  793. align-items: center;
  794. width: 60px;
  795. height: 60px;
  796. cursor: pointer;
  797. background-color: #fff;
  798. }
  799. main.preview-main {
  800. display: flex;
  801. flex: 1;
  802. width: calc($total-width);
  803. min-width: calc($total-width);
  804. max-width: calc($total-width);
  805. min-height: 100%;
  806. margin: 0 auto;
  807. background-color: #fff;
  808. border-radius: 4px;
  809. box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
  810. .preview-left {
  811. width: $courseware-left-margin;
  812. min-width: $courseware-left-margin;
  813. max-width: $courseware-left-margin;
  814. background-color: $courseware-bgColor;
  815. }
  816. .preview-right {
  817. width: $courseware-right-margin;
  818. min-width: $courseware-right-margin;
  819. max-width: $courseware-right-margin;
  820. background-color: $courseware-bgColor;
  821. }
  822. &.no-audit {
  823. margin: 0 auto;
  824. }
  825. }
  826. .audit-content {
  827. display: flex;
  828. min-width: 1400px;
  829. height: calc(100vh - 46px);
  830. .left-menu {
  831. display: flex;
  832. flex-direction: column;
  833. width: $catalogue-width;
  834. font-family: 'Microsoft YaHei', 'Arial', sans-serif;
  835. background-color: #fff;
  836. .courseware-info {
  837. display: flex;
  838. column-gap: 18px;
  839. width: 100%;
  840. height: 186px;
  841. padding: 6px 6px 24px;
  842. border-bottom: $border;
  843. .cover-image {
  844. display: flex;
  845. align-items: center;
  846. justify-content: center;
  847. width: 111px;
  848. height: 157px;
  849. background-color: rgba(229, 229, 229, 100%);
  850. img {
  851. max-width: 111px;
  852. max-height: 157px;
  853. }
  854. }
  855. .info-content {
  856. display: flex;
  857. flex-direction: column;
  858. justify-content: space-between;
  859. .catalogue-icon {
  860. text-align: right;
  861. .svg-icon {
  862. cursor: pointer;
  863. }
  864. }
  865. .courseware {
  866. width: 159px;
  867. height: 64px;
  868. font-size: 16px;
  869. .name {
  870. font-weight: bold;
  871. }
  872. .editor {
  873. display: -webkit-box;
  874. overflow: hidden;
  875. text-overflow: ellipsis;
  876. word-break: break-word;
  877. white-space: normal;
  878. -webkit-line-clamp: 2; /* 多行省略行数,按需调整 */
  879. -webkit-box-orient: vertical;
  880. }
  881. }
  882. }
  883. }
  884. .courseware-tree {
  885. display: flex;
  886. flex: 1;
  887. flex-direction: column;
  888. row-gap: 8px;
  889. padding: 12px;
  890. margin-top: 12px;
  891. overflow: auto;
  892. .menu-item {
  893. display: flex;
  894. align-items: center;
  895. &:not(.courseware) {
  896. font-weight: bold;
  897. }
  898. &.courseware {
  899. &:hover {
  900. .name {
  901. background-color: #f3f3f3;
  902. }
  903. }
  904. }
  905. .svg-icon {
  906. margin-left: 4px;
  907. &.my-edit-task {
  908. color: $right-color;
  909. }
  910. }
  911. .name {
  912. flex: 1;
  913. padding: 4px 8px 4px 4px;
  914. border-radius: 4px;
  915. }
  916. &.active {
  917. .name {
  918. font-weight: bold;
  919. color: #4095e5;
  920. }
  921. }
  922. }
  923. }
  924. }
  925. .sidebar {
  926. position: relative;
  927. display: flex;
  928. width: $sidebar-width;
  929. .toolbar {
  930. display: flex;
  931. flex-direction: column;
  932. align-items: center;
  933. width: 60px;
  934. height: 100%;
  935. background-color: rgba(247, 248, 250, 100%);
  936. img {
  937. cursor: pointer;
  938. }
  939. &-special {
  940. display: flex;
  941. flex-direction: column;
  942. row-gap: 16px;
  943. margin-bottom: 24px;
  944. }
  945. &-list {
  946. display: flex;
  947. flex-direction: column;
  948. row-gap: 16px;
  949. align-items: center;
  950. width: 100%;
  951. .sidebar-item {
  952. width: 100%;
  953. text-align: center;
  954. .sidebar-icon {
  955. width: 36px;
  956. height: 36px;
  957. cursor: pointer;
  958. }
  959. &.active {
  960. background-color: #4095e5;
  961. }
  962. }
  963. }
  964. }
  965. .content {
  966. flex: 1;
  967. background-color: #fff;
  968. :deep .el-drawer {
  969. width: 240px !important;
  970. border: 1px solid #e5e5e5;
  971. transition: none !important;
  972. animation: none !important;
  973. .el-drawer__body {
  974. height: calc(100vh - 200px);
  975. overflow-y: auto;
  976. h5 {
  977. padding: 0 5px;
  978. margin: 0;
  979. font-size: 18px;
  980. line-height: 40px;
  981. background: #f2f3f5;
  982. }
  983. .scroll-container {
  984. display: flex;
  985. flex-direction: column;
  986. row-gap: 8px;
  987. margin: 6px;
  988. .list-item {
  989. display: flex;
  990. align-items: center;
  991. cursor: pointer;
  992. border: 1px solid #ccc;
  993. border-radius: 8px;
  994. :deep .el-slider {
  995. .el-slider__runway {
  996. background-color: #eee;
  997. }
  998. }
  999. .el-image {
  1000. display: flex;
  1001. width: 100%;
  1002. min-width: 100%;
  1003. height: 90px;
  1004. background-color: #ccc;
  1005. border-radius: 8px;
  1006. }
  1007. .video-play {
  1008. width: 100%;
  1009. min-width: 100%;
  1010. }
  1011. .text-box {
  1012. word-break: break-word;
  1013. }
  1014. }
  1015. }
  1016. }
  1017. p {
  1018. color: #999;
  1019. text-align: center;
  1020. }
  1021. }
  1022. }
  1023. .back-top {
  1024. position: absolute;
  1025. bottom: 0;
  1026. left: 0;
  1027. display: flex;
  1028. place-content: center center;
  1029. align-items: center;
  1030. width: 60px;
  1031. height: 60px;
  1032. cursor: pointer;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. :deep .scroll-container .audio-wrapper .audio-middle {
  1038. width: 210px !important;
  1039. padding: 6px 8px !important;
  1040. border: none;
  1041. border-radius: 8px;
  1042. .audio-name {
  1043. text-align: left;
  1044. }
  1045. .slider-area {
  1046. column-gap: 8px !important;
  1047. }
  1048. }
  1049. :deep .audit-dialog {
  1050. .el-dialog__body {
  1051. height: calc(100vh - 260px);
  1052. padding: 5px 20px;
  1053. }
  1054. .mind-map-container .mind-map {
  1055. height: calc(100vh - 310px);
  1056. }
  1057. }
  1058. </style>
  1059. <style lang="scss">
  1060. .tox-tinymce-aux {
  1061. z-index: 9999 !important;
  1062. }
  1063. </style>