import { defineComponent, ref } from 'vue';
import styles from './index.module.less';
import { useUserStore } from '/src/store/modules/users';
import { vaildMusicScoreUrl } from '/src/utils/urlUtils';

export default defineComponent({
  name: 'song-modal',
  props: {
    item: {
      type: Object,
      default: () => ({})
    }
  },
  setup(props) {
    const userStore = useUserStore();
    const iframeRef = ref();
    const isLoaded = ref(false);
    // const origin = /(localhost|192)/.test(location.host)
    //   ? 'https://test.lexiaoya.cn'
    //   : location.origin;
    const src = `${vaildMusicScoreUrl()}/instrument?v=${+new Date()}&modelType=practise&id=${
      props.item.content
    }&Authorization=${userStore.getToken}`;
    return () => (
      <div class={styles.musicScore}>
        <iframe
          ref={iframeRef}
          onLoad={() => {
            // emit('setIframe', iframeRef.value);
            isLoaded.value = true;
          }}
          class={[styles.container, 'musicIframe']}
          frameborder="0"
          src={src}></iframe>
      </div>
    );
  }
});
