2022-04-21 18:20:39 +08:00
|
|
|
<template>
|
|
|
|
<component :is="currentRole === 'admin' ? AdminDashboard : EditorDashboard" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2022-04-22 01:16:02 +08:00
|
|
|
import { useUserStore } from "@/store/modules/user"
|
|
|
|
import { computed, onBeforeMount, ref } from "vue"
|
|
|
|
import AdminDashboard from "./admin/index.vue"
|
|
|
|
import EditorDashboard from "./editor/index.vue"
|
2022-04-21 18:20:39 +08:00
|
|
|
|
2022-04-22 01:16:02 +08:00
|
|
|
const currentRole = ref("admin")
|
2022-04-21 18:20:39 +08:00
|
|
|
const roles = computed(() => {
|
|
|
|
return useUserStore().roles
|
|
|
|
})
|
|
|
|
onBeforeMount(() => {
|
2022-04-22 01:16:02 +08:00
|
|
|
if (!roles.value.includes("admin")) {
|
|
|
|
currentRole.value = "editor"
|
2022-04-21 18:20:39 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|