pen.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import { defineComponent, toRefs, ref, PropType, reactive } from 'vue';
  2. import styles from './pen.module.less';
  3. import { ToolType } from '../../index';
  4. import { NButton, NModal, NSpace } from 'naive-ui';
  5. export default defineComponent({
  6. name: 'pen-page',
  7. props: {
  8. show: {
  9. type: Boolean,
  10. default: false
  11. },
  12. type: {
  13. type: String as PropType<ToolType>,
  14. default: 'pen'
  15. },
  16. close: {
  17. type: Function,
  18. default: () => ({})
  19. },
  20. callStudents: {
  21. type: Array,
  22. default: () => []
  23. }
  24. },
  25. setup(props) {
  26. const { show, type } = toRefs(props);
  27. // const modelAttendStatus = ref(false);
  28. const modal = reactive({
  29. status: false,
  30. title: type.value === 'pen' ? '退出批注' : '退出白板',
  31. content:
  32. type.value === 'pen' ? '确认是否退出批注?' : '确认是否退出白板?'
  33. });
  34. const firstRender = ref(true);
  35. const origin = /(localhost|192)/.test(location.host)
  36. ? // ? 'https://test.lexiaoya.cn/'
  37. 'http://localhost:5002/'
  38. : location.origin;
  39. let src = `${origin}/classroom-whiteboard?t=${+new Date()}`;
  40. if (props.type === 'call') {
  41. src = `${origin}/roll-call/index.html?t=${+new Date()}`;
  42. }
  43. return () => (
  44. <div
  45. class={[
  46. styles.pen,
  47. type.value === 'whiteboard' ? styles.whiteboard : '',
  48. firstRender.value ? styles.dely : '',
  49. show.value ? styles.open : styles.hide
  50. ]}>
  51. <iframe
  52. class={styles.iframe}
  53. id="penIframeRef"
  54. frameborder="0"
  55. width="100vw"
  56. height="100vh"
  57. src={src}
  58. onLoad={() => {
  59. firstRender.value = false;
  60. if (props.type === 'call') {
  61. const iframeRef: any = document.getElementById('penIframeRef');
  62. if (iframeRef && iframeRef.contentWindow.renderData) {
  63. iframeRef.contentWindow.renderData(props.callStudents);
  64. }
  65. }
  66. }}></iframe>
  67. {props.type !== 'call' && (
  68. <div class={styles.rightItem} onClick={() => (modal.status = true)}>
  69. <svg
  70. width="28px"
  71. height="28px"
  72. viewBox="0 0 34 34"
  73. version="1.1"
  74. xmlns="http://www.w3.org/2000/svg">
  75. <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
  76. <g
  77. transform="translate(-1842.000000, -1016.000000)"
  78. stroke="#FFFFFF">
  79. <g transform="translate(980.000000, 1006.000000)">
  80. <g transform="translate(862.000000, 10.000000)">
  81. <g transform="translate(4.000000, 5.000000)">
  82. <g
  83. transform="translate(8.058241, 5.009812)"
  84. fill="#FFFFFF"
  85. fill-rule="nonzero"
  86. stroke-width="0.3">
  87. <path d="M11.6084252,-0.15 C11.9880433,-0.15 12.3676614,-0.00518057514 12.6573002,0.284458275 L12.6573002,0.284458275 L18.3141545,5.94131252 C18.6037933,6.23095137 18.7486128,6.61056948 18.7486128,6.99018758 C18.7486128,7.36980569 18.6037933,7.74942379 18.3141545,8.03906264 L18.3141545,8.03906264 L12.6573002,13.6959169 C12.3676614,13.9855557 11.9880433,14.1303752 11.6084252,14.1303752 C11.2288071,14.1303752 10.849189,13.9855557 10.5595501,13.6959169 C10.2699113,13.406278 10.1250918,13.0266599 10.1250918,12.6470418 C10.1250918,12.2674237 10.2699113,11.8878056 10.5595368,11.5981801 L10.5595368,11.5981801 L13.6839174,8.47301484 L1.33333333,8.47352092 C0.923722144,8.47352092 0.552888811,8.30749318 0.284458275,8.03906264 C0.0160277386,7.77063211 -0.15,7.39979877 -0.15,6.99018758 C-0.15,6.61194961 -0.00841906355,6.26678575 0.224608408,6.00476938 C0.462154637,5.73767211 0.794779811,5.55707713 1.16932931,5.51583101 L1.16932931,5.51583101 L13.6841044,5.50627626 L10.5595501,2.38220839 C10.2699113,2.09256954 10.1250918,1.71295144 10.1250918,1.33333333 C10.1250918,0.953715229 10.2699113,0.574097124 10.5595501,0.284458275 C10.849189,-0.00518057514 11.2288071,-0.15 11.6084252,-0.15 Z"></path>
  88. </g>
  89. <path
  90. d="M15,24 L3,24 C1.34314575,24 -1.1293615e-15,22.6568542 0,21 L0,3 C-2.02906125e-16,1.34314575 1.34314575,3.04359188e-16 3,0 L15,0 L15,0"
  91. stroke-width="3.5"
  92. stroke-linecap="round"
  93. stroke-linejoin="round"></path>
  94. </g>
  95. </g>
  96. </g>
  97. </g>
  98. </g>
  99. </svg>
  100. </div>
  101. )}
  102. {/* 布置作业 */}
  103. <NModal
  104. transformOrigin="center"
  105. v-model:show={modal.status}
  106. preset="card"
  107. // class={styles.attendClassModal}
  108. title={modal.title}
  109. class={['modalTitle', styles.removeVisiable]}>
  110. <div class={styles.studentRemove}>
  111. <p>{modal.content}</p>
  112. {/* <div class={styles.modelAttendContent}>
  113. {data.modalAttendMessage}
  114. </div> */}
  115. <NSpace class={styles.btnGroupModal} justify="center">
  116. <NButton
  117. type="default"
  118. round
  119. onClick={() => {
  120. modal.status = false;
  121. }}>
  122. 取消
  123. </NButton>
  124. <NButton
  125. type="primary"
  126. round
  127. onClick={() => {
  128. // data.modelTrainStatus = true;
  129. modal.status = false;
  130. props.close();
  131. }}>
  132. 确认
  133. </NButton>
  134. </NSpace>
  135. </div>
  136. </NModal>
  137. </div>
  138. );
  139. }
  140. });