AppMenu.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div>
  3. <div class="row">
  4. <div class="col-12 col-md-8 offset-sm-2 col-lg-6 offset-md-3">
  5. <h2>Menu</h2>
  6. </div>
  7. </div>
  8. <keep-alive include="menu-login">
  9. <component
  10. :is="menuPage"
  11. @enter-online="enterOnline"
  12. @enter-game-creation="enterGameCreation"
  13. @enter-local="enterLocal"
  14. @back="menuPage = previousPage.pop()"
  15. @home="
  16. menuPage = 'menu-login';
  17. previousPage = [];
  18. "
  19. :username="username"
  20. v-on="$listeners"
  21. ></component>
  22. </keep-alive>
  23. </div>
  24. </template>
  25. <script>
  26. import MenuLogin from './login/MenuLogin';
  27. import MenuOnlineRoom from './online-room/MenuOnlineRoom';
  28. import MenuGameCreation from './game-creation/MenuGameCreation';
  29. export default {
  30. data() {
  31. return {
  32. previousPage: [],
  33. menuPage: 'menu-login',
  34. username: ''
  35. };
  36. },
  37. components: {
  38. MenuLogin,
  39. MenuOnlineRoom,
  40. MenuGameCreation
  41. },
  42. methods: {
  43. enterLocal() {
  44. alert('Not implemented yet, give us time ! :)');
  45. },
  46. enterOnline(username) {
  47. this.previousPage.push(this.menuPage);
  48. console.log('enter online with username : ' + username);
  49. this.username = username;
  50. this.menuPage = 'menu-online-room';
  51. },
  52. enterGameCreation() {
  53. this.previousPage.push(this.menuPage);
  54. this.menuPage = 'menu-game-creation';
  55. }
  56. }
  57. };
  58. </script>
  59. <style scoped></style>