imGroup.tsx 1.3 KB

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