Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-21 03:19:19 +08:00

perf: 代码优化 views/dashboard

This commit is contained in:
pany 2023-06-16 18:12:53 +08:00
parent e8d0f9ba9d
commit c265e64676
3 changed files with 4 additions and 10 deletions

View File

@ -1,18 +1,12 @@
<script lang="ts" setup>
import { ref } from "vue"
import { useUserStore } from "@/store/modules/user"
import AdminDashboard from "./admin/index.vue"
import EditorDashboard from "./editor/index.vue"
type CurrentRole = "admin" | "editor"
import Admin from "./components/Admin.vue"
import Editor from "./components/Editor.vue"
const userStore = useUserStore()
const currentRole = ref<CurrentRole>("admin")
if (!userStore.roles.includes("admin")) {
currentRole.value = "editor"
}
const isAdmin = userStore.roles.includes("admin")
</script>
<template>
<component :is="currentRole === 'admin' ? AdminDashboard : EditorDashboard" />
<component :is="isAdmin ? Admin : Editor" />
</template>