index.vue 575B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <div class="dashboard-container">
  3. <component :is="currentRole"></component>
  4. </div>
  5. </template>
  6. <script>
  7. import { mapGetters } from 'vuex'
  8. import adminDashboard from './admin'
  9. import editorDashboard from './editor'
  10. export default {
  11. name: 'dashboard',
  12. components: { adminDashboard, editorDashboard },
  13. data() {
  14. return {
  15. currentRole: 'adminDashboard'
  16. }
  17. },
  18. computed: {
  19. ...mapGetters([
  20. 'roles'
  21. ])
  22. },
  23. created() {
  24. if (!this.roles.includes('admin')) {
  25. this.currentRole = 'editorDashboard'
  26. }
  27. }
  28. }
  29. </script>