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

index.web.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 } 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. // Used for automated performance tests.
  43. globalNS.connectionTimes = {
  44. 'index.loaded': window.indexLoadedTime
  45. };
  46. window.addEventListener('load', () => {
  47. globalNS.connectionTimes['window.loaded'] = window.loadedEventTime;
  48. });
  49. document.addEventListener('DOMContentLoaded', () => {
  50. const now = window.performance.now();
  51. globalNS.connectionTimes['document.ready'] = now;
  52. logger.log('(TIME) document ready:\t', now);
  53. });
  54. globalNS.entryPoints = {
  55. APP: App,
  56. PREJOIN: PrejoinApp,
  57. DIALIN: DialInSummaryApp,
  58. WHITEBOARD: WhiteboardApp
  59. };
  60. globalNS.renderEntryPoint = ({
  61. Component,
  62. props = {},
  63. elementId = 'react'
  64. }) => {
  65. ReactDOM.render(
  66. <Component { ...props } />,
  67. document.getElementById(elementId)
  68. );
  69. };