123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import {
- PropType,
- defineComponent,
- onMounted,
- onUnmounted,
- ref,
- toRefs,
- watch
- } from 'vue';
- import styles from './index.module.less';
- import { NModal } from 'naive-ui';
- import AttendClass from '../attend-class';
- export default defineComponent({
- name: 'preview-window',
- props: {
- show: {
- type: Boolean,
- default: false
- },
- type: {
- type: String,
- default: ''
- },
- params: {
- type: Object as PropType<any>,
- default: () => ({})
- }
- },
- emit: ['update:show'],
- setup(props, { emit }) {
- const { show, type, params } = toRefs(props);
- watch(
- () => props.show,
- () => {
- show.value = props.show;
- }
- );
- watch(
- () => props.type,
- () => {
- type.value = props.type;
- }
- );
- watch(
- () => props.params,
- () => {
- params.value = props.params;
- }
- );
- const handleOpen = (e: MessageEvent) => {
- if (e.data.api === 'iframe_exit') {
- emit('update:show', false);
- }
- };
- onMounted(() => {
- window.addEventListener('message', handleOpen);
- });
- onUnmounted(() => {
- window.removeEventListener('message', handleOpen);
- });
- return () => (
- <>
- <NModal
- v-model:show={show.value}
- onUpdate:show={() => {
- emit('update:show', show.value);
- }}
- class={styles.previewWindow}
- showIcon={false}
- displayDirective="show">
- <>
- {show.value ? (
- type.value == 'attend' ? (
- <AttendClass
- type={params.value.type || ''}
- subjectId={params.value.subjectId || ''}
- courseId={params.value.courseId || ''}
- detailId={params.value.detailId || ''}
- classGroupId={params.value.classGroupId || ''}
- lessonCourseId={params.value.lessonCourseId || ''}
- classId={params.value.classId || ''}
- preStudentNum={params.value.preStudentNum}
- onClose={() => emit('update:show', false)}
- />
- ) : type.value == 'notation' ? (
- <iframe src={params.value.src}></iframe>
- ) : type.value == 'music' ? (
- <iframe
- src={params.value.src}
- style={{ height: '100vh' }}></iframe>
- ) : (
- ''
- )
- ) : (
- ''
- )}
- </>
- </NModal>
- </>
- );
- }
- });
|