index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="main-container">
  3. <div class="menu">
  4. <span
  5. v-for="item in menuList"
  6. :key="item.id"
  7. v-t="item.name"
  8. :class="['menu-tab', { active: currentTab === item.tab }]"
  9. @click="currentTab = item.tab"
  10. />
  11. </div>
  12. <keep-alive>
  13. <component :is="currentTabComponent" />
  14. </keep-alive>
  15. </div>
  16. </template>
  17. <script>
  18. import TaskList from './TaskList';
  19. import CurriculaList from './CurriculaList';
  20. import { updateWordPack } from '@/utils/i18n';
  21. export default {
  22. name: 'Main',
  23. components: {
  24. TaskList,
  25. CurriculaList
  26. },
  27. data() {
  28. return {
  29. currentTab: this.$route.query.tab || 'TaskList',
  30. menuList: [
  31. {
  32. id: 1,
  33. name: '任务列表',
  34. tab: 'TaskList'
  35. },
  36. {
  37. id: 2,
  38. name: '课程列表',
  39. tab: 'CurriculaList'
  40. }
  41. ]
  42. };
  43. },
  44. computed: {
  45. currentTabComponent: function () {
  46. return this.currentTab;
  47. }
  48. },
  49. created() {
  50. updateWordPack({
  51. word_key_list: [
  52. 'Learn_Task_Panel',
  53. 'Learn_Course_Management',
  54. 'Learn_Task_No_Started',
  55. 'Learn_Task_Has_Begun',
  56. 'Learn_Task_Over'
  57. ]
  58. });
  59. }
  60. };
  61. </script>
  62. <style lang="scss" scoped>
  63. @import '~@/styles/mixin.scss';
  64. .main-container {
  65. @include container;
  66. height: calc(100% - 19px);
  67. // 切换菜单
  68. .menu {
  69. width: 318px;
  70. border-radius: 30px;
  71. margin-bottom: 32px;
  72. background-color: #ebebeb;
  73. &-tab {
  74. display: inline-block;
  75. height: 48px;
  76. line-height: 30px;
  77. font-size: 20px;
  78. padding: 9px 39px;
  79. border-radius: 30px;
  80. background-color: #ebebeb;
  81. color: #9f9f9f;
  82. cursor: pointer;
  83. &.active {
  84. color: #fff;
  85. font-weight: 700;
  86. background-color: $basicColor;
  87. }
  88. }
  89. }
  90. }
  91. </style>