您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.web.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { App } from './features/app/components/App.web';
  4. import { getLogger } from './features/base/logging/functions';
  5. import Platform from './features/base/react/Platform.web';
  6. import { getJitsiMeetGlobalNS, getJitsiMeetGlobalNSConnectionTimes } from './features/base/util/helpers';
  7. import DialInSummaryApp from './features/invite/components/dial-in-summary/web/DialInSummaryApp';
  8. import PrejoinApp from './features/prejoin/components/web/PrejoinApp';
  9. import WhiteboardApp from './features/whiteboard/components/web/WhiteboardApp';
  10. const logger = getLogger('index.web');
  11. // Add global loggers.
  12. window.addEventListener('error', ev => {
  13. logger.error(
  14. `UnhandledError: ${ev.message}`,
  15. `Script: ${ev.filename}`,
  16. `Line: ${ev.lineno}`,
  17. `Column: ${ev.colno}`,
  18. 'StackTrace: ', ev.error?.stack);
  19. });
  20. window.addEventListener('unhandledrejection', ev => {
  21. logger.error(
  22. `UnhandledPromiseRejection: ${ev.reason}`,
  23. 'StackTrace: ', ev.reason?.stack);
  24. });
  25. // Workaround for the issue when returning to a page with the back button and
  26. // the page is loaded from the 'back-forward' cache on iOS which causes nothing
  27. // to be rendered.
  28. if (Platform.OS === 'ios') {
  29. window.addEventListener('pageshow', event => {
  30. // Detect pages loaded from the 'back-forward' cache
  31. // (https://webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/)
  32. if (event.persisted) {
  33. // Maybe there is a more graceful approach but in the moment of
  34. // writing nothing else resolves the issue. I tried to execute our
  35. // DOMContentLoaded handler but it seems that the 'onpageshow' event
  36. // is triggered only when 'window.location.reload()' code exists.
  37. window.location.reload();
  38. }
  39. });
  40. }
  41. const globalNS = getJitsiMeetGlobalNS();
  42. const connectionTimes = getJitsiMeetGlobalNSConnectionTimes();
  43. // Used for automated performance tests.
  44. connectionTimes['index.loaded'] = window.indexLoadedTime;
  45. window.addEventListener('load', () => {
  46. connectionTimes['window.loaded'] = window.loadedEventTime;
  47. });
  48. document.addEventListener('DOMContentLoaded', () => {
  49. const now = window.performance.now();
  50. connectionTimes['document.ready'] = now;
  51. logger.log('(TIME) document ready:\t', now);
  52. });
  53. globalNS.entryPoints = {
  54. APP: App,
  55. PREJOIN: PrejoinApp,
  56. DIALIN: DialInSummaryApp,
  57. WHITEBOARD: WhiteboardApp
  58. };
  59. globalNS.renderEntryPoint = ({
  60. Component,
  61. props = {},
  62. elementId = 'react'
  63. }) => {
  64. ReactDOM.render(
  65. <Component { ...props } />,
  66. document.getElementById(elementId)
  67. );
  68. };