imGroup.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { defineComponent, ref } from 'vue';
  2. import { useUserStore } from '/src/store/modules/users';
  3. import styles from './index.module.less';
  4. import { NSpin } from 'naive-ui';
  5. export default defineComponent({
  6. name: 'imGroup',
  7. setup() {
  8. const userStore = useUserStore();
  9. const isLoading = ref(false);
  10. const iframeRef = ref();
  11. const isLoaded = ref(false);
  12. // const renderError = ref(false);
  13. // const renderSuccess = ref(false);
  14. const origin = /(localhost|192)/.test(location.host)
  15. ? 'https://test.kt.colexiu.com'
  16. : /online.lexiaoya.cn/.test(location.href)
  17. ? 'https://kt.colexiu.com'
  18. : location.origin;
  19. const src = `${origin}/classroom-im/?v=${+new Date()}&userID=${
  20. userStore.getUserInfo.imUserId
  21. }&Authorization=${userStore.getToken}&t=${+new Date()}`;
  22. return () => (
  23. <div class={styles.imGroupContainer}>
  24. <NSpin show={!isLoaded.value}>
  25. <iframe
  26. ref={iframeRef}
  27. onLoad={() => {
  28. isLoaded.value = true;
  29. }}
  30. class={[styles.container]}
  31. frameborder="0"
  32. src={src}></iframe>
  33. </NSpin>
  34. </div>
  35. );
  36. }
  37. });