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

App.web.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { appInit } from '../actions';
  2. import { AbstractApp } from './AbstractApp';
  3. /**
  4. * Root application component.
  5. *
  6. * @extends AbstractApp
  7. */
  8. export class App extends AbstractApp {
  9. /**
  10. * App component's property types.
  11. *
  12. * @static
  13. */
  14. static propTypes = AbstractApp.propTypes
  15. /**
  16. * Inits the app before component will mount.
  17. *
  18. * @inheritdoc
  19. */
  20. componentWillMount(...args) {
  21. super.componentWillMount(...args);
  22. this._getStore().dispatch(appInit());
  23. }
  24. /**
  25. * Gets a Location object from the window with information about the current
  26. * location of the document.
  27. *
  28. * @inheritdoc
  29. */
  30. _getWindowLocation() {
  31. return window.location;
  32. }
  33. /**
  34. * Navigates to a specific Route (via platform-specific means).
  35. *
  36. * @param {Route} route - The Route to which to navigate.
  37. * @protected
  38. * @returns {void}
  39. */
  40. _navigate(route) {
  41. let path = route.path;
  42. const store = this._getStore();
  43. // The syntax :room bellow is defined by react-router. It "matches a URL
  44. // segment up to the next /, ?, or #. The matched string is called a
  45. // param."
  46. path
  47. = path.replace(
  48. /:room/g,
  49. store.getState()['features/base/conference'].room);
  50. // Navigate to the specified Route.
  51. const windowLocation = this._getWindowLocation();
  52. if (windowLocation.pathname === path) {
  53. // The browser is at the specified path already and what remains is
  54. // to make this App instance aware of the route to be rendered at
  55. // the current location.
  56. super._navigate(route);
  57. } else {
  58. // The browser must go to the specified location. Once the specified
  59. // location becomes current, the App will be made aware of the route
  60. // to be rendered at it.
  61. windowLocation.pathname = path;
  62. }
  63. }
  64. }