index.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { defineComponent, ref } from 'vue';
  2. import styles from './index.module.less';
  3. import { useUserStore } from '/src/store/modules/users';
  4. import { vaildMusicScoreUrl } from '/src/utils/urlUtils';
  5. export default defineComponent({
  6. name: 'song-modal',
  7. props: {
  8. item: {
  9. type: Object,
  10. default: () => ({})
  11. }
  12. },
  13. setup(props) {
  14. const userStore = useUserStore();
  15. const iframeRef = ref();
  16. const isLoaded = ref(false);
  17. // const origin = /(localhost|192)/.test(location.host)
  18. // ? 'https://test.lexiaoya.cn'
  19. // : location.origin;
  20. const src = `${vaildMusicScoreUrl()}/instrument?v=${+new Date()}&modelType=practise&id=${
  21. props.item.content
  22. }&Authorization=${userStore.getToken}`;
  23. return () => (
  24. <div class={styles.musicScore}>
  25. <iframe
  26. ref={iframeRef}
  27. onLoad={() => {
  28. // emit('setIframe', iframeRef.value);
  29. isLoaded.value = true;
  30. }}
  31. class={[styles.container, 'musicIframe']}
  32. frameborder="0"
  33. src={src}></iframe>
  34. </div>
  35. );
  36. }
  37. });