123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- import { defineComponent, onMounted, reactive, ref } from 'vue';
- import { useUserStore } from '/src/store/modules/users';
- import styles from './index.module.less';
- import { state } from '/src/state';
- import { NButton, NModal, NSpace, NSpin } from 'naive-ui';
- import { exitFullscreen } from '/src/utils';
- export default defineComponent({
- name: 'notation-a',
- setup() {
- const show = ref(false);
- const previewModal = ref(false);
- const previewParams = ref({} as any);
- const removeVisiable = ref(false);
- const userStore = useUserStore();
- const Authorization = userStore.getToken || '';
- const iframeRef = ref();
- console.log(Authorization);
- const notationOpenCreate = sessionStorage.getItem('notation-open-create');
- const openCreateUrl = notationOpenCreate == '1' ? '&addShow=1' : '';
- sessionStorage.removeItem('notation-open-create');
- const data = reactive({
- src: `${
- /(192|localhost)/.test(location.origin)
- ? // ?
- 'https://test.lexiaoya.cn'
- : // 'http://localhost:3050'
- location.origin
- }/notation/#/create?Authorization=${Authorization}${openCreateUrl}`
- // src: `http://localhost:3050/#/create?Authorization=${Authorization}`
- });
- const fscreen = () => {
- const el = document.documentElement as any;
- //进入全屏
- (el.requestFullscreen && el.requestFullscreen()) ||
- (el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
- (el.webkitRequestFullscreen && el.webkitRequestFullscreen()) ||
- (el.msRequestFullscreen && el.msRequestFullscreen());
- };
- const handleOpen = (e: MessageEvent) => {
- console.log(e.data, 'data');
- if (e.data.api === 'notation_open') {
- if (state.application) {
- show.value = true;
- previewModal.value = true;
- previewParams.value = {
- url: e.data.url
- };
- fscreen();
- } else {
- window.open(e.data.url);
- }
- } else if (e.data.api === 'notation_exit') {
- console.log('进来');
- removeVisiable.value = true;
- }
- };
- onMounted(() => {
- window.addEventListener('message', handleOpen);
- });
- return () => (
- <div class={styles.wrap}>
- <iframe ref={iframeRef} src={data.src}></iframe>
- <NModal
- v-model:show={previewModal.value}
- class={styles.previewWindow}
- showIcon={false}
- displayDirective="show">
- <NSpin show={show.value} style="--n-opacity-spinning: 1;">
- <iframe
- class={styles.previewIframe}
- onLoad={() => {
- show.value = false;
- }}
- frameborder="0"
- src={previewParams.value.url}></iframe>
- </NSpin>
- </NModal>
- <NModal
- v-model:show={removeVisiable.value}
- preset="card"
- class={['modalTitle', styles.removeVisiable]}
- title={'退出制谱'}>
- <div class={styles.studentRemove}>
- <p>是否退出制谱功能?</p>
- <NSpace class={styles.btnGroupModal} justify="center">
- <NButton
- round
- type="primary"
- onClick={() => {
- previewModal.value = false;
- previewParams.value.url = '';
- removeVisiable.value = false;
- // 给制谱发消息
- iframeRef.value.contentWindow.postMessage(
- {
- api: 'reload'
- },
- '*'
- );
- if (state.application) {
- document.exitFullscreen
- ? document.exitFullscreen()
- : document.mozCancelFullScreen
- ? document.mozCancelFullScreen()
- : document.webkitExitFullscreen
- ? document.webkitExitFullscreen()
- : '';
- }
- }}>
- 确定
- </NButton>
- <NButton round onClick={() => (removeVisiable.value = false)}>
- 取消
- </NButton>
- </NSpace>
- </div>
- </NModal>
- </div>
- );
- }
- });
|