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:
parent
e8d0f9ba9d
commit
c265e64676
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user