import { defineComponent, onMounted, onUnmounted, 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'; import { useRouter } from 'vue-router'; export default defineComponent({ name: 'notation-a', setup() { const router = useRouter(); 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); }); onUnmounted(() => { window.removeEventListener('message', handleOpen); }); return () => (
是否退出制谱功能?