detail.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import { defineComponent, onMounted, reactive, ref, watch } from 'vue';
  2. import styles from './index.module.less';
  3. import {
  4. NButton,
  5. // NBreadcrumb,
  6. // NBreadcrumbItem,
  7. // NScrollbar,
  8. NSlider,
  9. NSpace,
  10. NSpin
  11. } from 'naive-ui';
  12. import iconT from '/src/views/content-information/images/icon-t.png';
  13. import iconAddT from '/src/views/content-information/images/icon-add-t.png';
  14. import iconPlusT from '/src/views/content-information/images/icon-plus-t.png';
  15. import {
  16. api_lessonCoursewareDetail_listKnowledge,
  17. api_lessonCoursewareKnowledgeDetail
  18. } from '/src/views/content-information/api';
  19. import TheEmpty from '/src/components/TheEmpty';
  20. import { PageEnum } from '/src/enums/pageEnum';
  21. export default defineComponent({
  22. name: 'cotnent-knowledge',
  23. props: {
  24. id: {
  25. type: String,
  26. default: ''
  27. },
  28. type: {
  29. type: String,
  30. default: ''
  31. },
  32. activeStatus: {
  33. type: Boolean,
  34. default: false
  35. }
  36. },
  37. emits: ['close', 'confirm'],
  38. setup(props, { emit }) {
  39. const content = ref(false);
  40. const musicContentRef = ref();
  41. const state = reactive({
  42. fontSize: 18,
  43. tableList: [] as any,
  44. selectKey: null,
  45. details: {} as any
  46. });
  47. const getDetail = async () => {
  48. content.value = true;
  49. try {
  50. const { data } = await api_lessonCoursewareKnowledgeDetail({
  51. id: props.id
  52. });
  53. state.details = data;
  54. } catch {
  55. //
  56. }
  57. content.value = false;
  58. };
  59. onMounted(() => {
  60. getDetail();
  61. });
  62. watch(
  63. () => props.activeStatus,
  64. () => {
  65. // if (!props.activeStatus) {
  66. // handleChangeAudio('pause');
  67. // }
  68. }
  69. );
  70. return () => (
  71. <div
  72. class={[
  73. styles.containerDetail,
  74. props.type === 'preview' && styles.detailPreview
  75. ]}>
  76. {/* <div class={styles.detail2}> */}
  77. <div class={styles.contentWrap}>
  78. <div class={styles.musicStaff}>
  79. <NSpin
  80. show={content.value}
  81. ref={musicContentRef}
  82. class={
  83. !content.value && !state.details?.desc ? styles.empty : ''
  84. }>
  85. {state.details?.desc ? (
  86. <div
  87. class={styles.musicContent}
  88. v-html={state.details?.desc}
  89. style={{ fontSize: state.fontSize + 'px' }}></div>
  90. ) : (
  91. ''
  92. )}
  93. {!content.value && !state.details?.desc && <TheEmpty />}
  94. </NSpin>
  95. </div>
  96. <div class={styles.changeSizeSection}>
  97. <img src={iconT} class={styles.iconT} />
  98. <img
  99. src={iconAddT}
  100. class={styles.iconAddT}
  101. onClick={() => {
  102. if (state.fontSize >= 32) return;
  103. state.fontSize += 1;
  104. }}
  105. />
  106. <NSlider
  107. v-model:value={state.fontSize}
  108. vertical
  109. min={12}
  110. placement="left"
  111. max={32}
  112. />
  113. <img
  114. src={iconPlusT}
  115. class={styles.iconPlusT}
  116. onClick={() => {
  117. if (state.fontSize <= 12) return;
  118. state.fontSize -= 1;
  119. }}
  120. />
  121. </div>
  122. </div>
  123. {/* </div> */}
  124. </div>
  125. );
  126. }
  127. });