index.vue 32 KB

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