pen.tsx 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import { defineComponent, toRefs, ref, PropType, reactive, toRef } from 'vue';
  2. import styles from './pen.module.less';
  3. import { ToolType } from '../../index';
  4. import { NButton, NModal, NSpace } from 'naive-ui';
  5. import { iframeDislableKeyboard } from '/src/utils';
  6. import useDrag from '@/hooks/useDrag';
  7. import Dragbom from '@/hooks/useDrag/dragbom';
  8. import { useUserStore } from '@/store/modules/users';
  9. export default defineComponent({
  10. name: 'pen-page',
  11. props: {
  12. show: {
  13. type: Boolean,
  14. default: false
  15. },
  16. type: {
  17. type: String as PropType<ToolType>,
  18. default: 'pen'
  19. },
  20. close: {
  21. type: Function,
  22. default: () => ({})
  23. },
  24. callStudents: {
  25. type: Array,
  26. default: () => []
  27. },
  28. imagePos: {
  29. type: String,
  30. default: 'left'
  31. },
  32. isDrag: {
  33. type: Boolean,
  34. default: false
  35. }
  36. },
  37. setup(props) {
  38. const { show, type } = toRefs(props);
  39. // const modelAttendStatus = ref(false);
  40. const penIframeRefId = `penIframeRef${+new Date()}`;
  41. const modal = reactive({
  42. status: false,
  43. title: type.value === 'pen' ? '退出批注' : '退出白板',
  44. content:
  45. type.value === 'pen' ? '确认是否退出批注?' : '确认是否退出白板?'
  46. });
  47. const firstRender = ref(true);
  48. const origin = /(localhost|192)/.test(location.host)
  49. ? 'https://test.lexiaoya.cn/'
  50. : // 'http://localhost:5002/'
  51. location.origin;
  52. let src = `${origin}/classroom-whiteboard?t=${+new Date()}`;
  53. if (props.type === 'call') {
  54. src = `${origin}/roll-call/index.html?t=${+new Date()}&platform=modal&imagePos=${
  55. props.imagePos
  56. }`;
  57. }
  58. // 拖动
  59. let penBoxDragData: any;
  60. let penBoxClass: string;
  61. if (props.isDrag) {
  62. const users = useUserStore();
  63. penBoxClass = 'penBoxClass_drag';
  64. penBoxDragData = useDrag(
  65. [`${penBoxClass}>.n-card-header`, `${penBoxClass} .bom_drag`],
  66. penBoxClass,
  67. toRef(modal, 'status'),
  68. users.info.id
  69. );
  70. }
  71. return () => (
  72. <div
  73. class={[
  74. styles.pen,
  75. type.value === 'whiteboard' ? styles.whiteboard : '',
  76. firstRender.value ? styles.dely : '',
  77. show.value ? styles.open : styles.hide
  78. ]}>
  79. <iframe
  80. class={styles.iframe}
  81. id={penIframeRefId}
  82. frameborder="0"
  83. width="100vw"
  84. height="100vh"
  85. src={src}
  86. onLoad={(val: any) => {
  87. firstRender.value = false;
  88. if (props.type === 'call') {
  89. const iframeRef: any = document.getElementById(penIframeRefId);
  90. if (iframeRef && iframeRef.contentWindow.renderData) {
  91. iframeRef.contentWindow.renderData(props.callStudents);
  92. }
  93. }
  94. iframeDislableKeyboard(val.target);
  95. }}></iframe>
  96. {props.type !== 'call' && (
  97. <div class={styles.rightItem} onClick={() => (modal.status = true)}>
  98. <svg
  99. width="28px"
  100. height="28px"
  101. viewBox="0 0 34 34"
  102. version="1.1"
  103. xmlns="http://www.w3.org/2000/svg">
  104. <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
  105. <g
  106. transform="translate(-1842.000000, -1016.000000)"
  107. stroke="#FFFFFF">
  108. <g transform="translate(980.000000, 1006.000000)">
  109. <g transform="translate(862.000000, 10.000000)">
  110. <g transform="translate(4.000000, 5.000000)">
  111. <g
  112. transform="translate(8.058241, 5.009812)"
  113. fill="#FFFFFF"
  114. fill-rule="nonzero"
  115. stroke-width="0.3">
  116. <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>
  117. </g>
  118. <path
  119. 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"
  120. stroke-width="3.5"
  121. stroke-linecap="round"
  122. stroke-linejoin="round"></path>
  123. </g>
  124. </g>
  125. </g>
  126. </g>
  127. </g>
  128. </svg>
  129. </div>
  130. )}
  131. {/* 布置作业 */}
  132. <NModal
  133. style={props.isDrag ? penBoxDragData.styleDrag.value : {}}
  134. z-index={3000}
  135. transformOrigin="center"
  136. v-model:show={modal.status}
  137. preset="card"
  138. // class={styles.attendClassModal}
  139. title={modal.title}
  140. class={['modalTitle', styles.removeVisiable, penBoxClass]}>
  141. <div class={styles.studentRemove}>
  142. <p>{modal.content}</p>
  143. {/* <div class={styles.modelAttendContent}>
  144. {data.modalAttendMessage}
  145. </div> */}
  146. <NSpace class={styles.btnGroupModal} justify="center">
  147. <NButton
  148. type="default"
  149. round
  150. onClick={() => {
  151. modal.status = false;
  152. }}>
  153. 取消
  154. </NButton>
  155. <NButton
  156. type="primary"
  157. round
  158. onClick={() => {
  159. // data.modelTrainStatus = true;
  160. modal.status = false;
  161. props.close();
  162. }}>
  163. 确认
  164. </NButton>
  165. </NSpace>
  166. {props.isDrag && <Dragbom></Dragbom>}
  167. </div>
  168. </NModal>
  169. </div>
  170. );
  171. }
  172. });