perf: 代码优化 views/dashboard
This commit is contained in:
parent
e8d0f9ba9d
commit
c265e64676
@ -1,18 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from "vue"
|
|
||||||
import { useUserStore } from "@/store/modules/user"
|
import { useUserStore } from "@/store/modules/user"
|
||||||
import AdminDashboard from "./admin/index.vue"
|
import Admin from "./components/Admin.vue"
|
||||||
import EditorDashboard from "./editor/index.vue"
|
import Editor from "./components/Editor.vue"
|
||||||
|
|
||||||
type CurrentRole = "admin" | "editor"
|
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const currentRole = ref<CurrentRole>("admin")
|
const isAdmin = userStore.roles.includes("admin")
|
||||||
if (!userStore.roles.includes("admin")) {
|
|
||||||
currentRole.value = "editor"
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<component :is="currentRole === 'admin' ? AdminDashboard : EditorDashboard" />
|
<component :is="isAdmin ? Admin : Editor" />
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user