diff --git a/monisuo-admin/src/components/app-sidebar/data/sidebar-data.ts b/monisuo-admin/src/components/app-sidebar/data/sidebar-data.ts index 5bfe870..35fd5c0 100644 --- a/monisuo-admin/src/components/app-sidebar/data/sidebar-data.ts +++ b/monisuo-admin/src/components/app-sidebar/data/sidebar-data.ts @@ -1,41 +1,24 @@ -import { - AudioWaveform, - Command, - GalleryVerticalEnd, -} from 'lucide-vue-next' - import { useSidebar } from '@/composables/use-sidebar' +import { useAuthStore } from '@/stores/auth' -import type { SidebarData, Team, User } from '../types' - -const user: User = { - name: 'shadcn', - email: 'm@example.com', - avatar: '/avatars/shadcn.jpg', -} - -const teams: Team[] = [ - { - name: 'Acme Inc', - logo: GalleryVerticalEnd, - plan: 'Enterprise', - }, - { - name: 'Acme Corp.', - logo: AudioWaveform, - plan: 'Startup', - }, - { - name: 'Evil Corp.', - logo: Command, - plan: 'Free', - }, -] +import type { SidebarData, User } from '../types' const { navData } = useSidebar() +const authStore = useAuthStore() + +// 从 auth store 获取用户信息,转换为 sidebar User 类型 +const user = computed(() => { + const adminInfo = authStore.adminInfo + return { + name: adminInfo?.nickname || adminInfo?.username || 'Admin', + email: adminInfo?.username || '', + avatar: adminInfo?.avatar || '/avatars/admin.jpg', + } +}) export const sidebarData: SidebarData = { - user, - teams, + get user() { + return user.value + }, navMain: navData.value!, } diff --git a/monisuo-admin/src/components/app-sidebar/index.vue b/monisuo-admin/src/components/app-sidebar/index.vue index e630335..6bc284f 100644 --- a/monisuo-admin/src/components/app-sidebar/index.vue +++ b/monisuo-admin/src/components/app-sidebar/index.vue @@ -1,18 +1,18 @@