11<script setup lang="ts">
2+ import type { HTMLAttributes } from ' vue'
23import useSettingsStore from ' @/store/modules/settings'
34import useUserStore from ' @/store/modules/user'
5+ import { cn } from ' @/utils'
46import eventBus from ' @/utils/eventBus'
57import Profile from ' ./profile.vue'
68
9+ const props = withDefaults (defineProps <{
10+ onlyAvatar? : boolean
11+ dropdownAlign? : ' start' | ' center' | ' end'
12+ dropdownSide? : ' left' | ' right' | ' top' | ' bottom'
13+ buttonVariant? : ' secondary' | ' ghost'
14+ class? : HTMLAttributes [' class' ]
15+ }>(), {
16+ dropdownAlign: ' end' ,
17+ dropdownSide: ' right' ,
18+ buttonVariant: ' ghost' ,
19+ })
20+
721const router = useRouter ()
822
923const settingsStore = useSettingsStore ()
@@ -14,7 +28,7 @@ const isProfileShow = ref(false)
1428
1529<template >
1630 <FaDropdown
17- align =" end " :items =" [
31+ : align =" dropdownAlign " :side = " dropdownSide " :items =" [
1832 [
1933 { label: settingsStore.settings.home.title, icon: 'i-mdi:home', handle: () => router.push({ path: settingsStore.settings.home.fullPath }), hide: !settingsStore.settings.home.enable },
2034 { label: '个人设置', icon: 'i-mdi:account', handle: () => isProfileShow = true },
@@ -39,20 +53,26 @@ const isProfileShow = ref(false)
3953 {{ userStore.account }}
4054 </div >
4155 <div class =" text-xs text-secondary-foreground/50 font-normal" >
42- 这里可以显示邮箱
56+ [ 这里可以显示邮箱 ]
4357 </div >
4458 </div >
4559 </div >
4660 </div >
4761 </template >
48- <FaButton variant =" ghost" class =" h-9 flex-center gap-1 px-2" >
49- <FaAvatar :src =" userStore.avatar" class =" size-6" >
50- <FaIcon name =" i-carbon:user-avatar-filled-alt" class =" size-6 text-secondary-foreground/50" />
62+ <FaButton
63+ :variant =" buttonVariant" :class =" cn('flex-center gap-1 p-2', {
64+ 'size-8 p-1': onlyAvatar,
65+ }, props.class)"
66+ >
67+ <FaAvatar :src =" userStore.avatar" :class =" cn('size-6', { 'size-full': onlyAvatar })" >
68+ <FaIcon name =" i-carbon:user-avatar-filled" class =" size-6 text-secondary-foreground/50" />
5169 </FaAvatar >
52- <template v-if =" settingsStore .mode === ' pc' " >
53- {{ userStore.account }}
54- <FaIcon name =" i-ep:caret-bottom" />
55- </template >
70+ <div v-if =" settingsStore.mode === 'pc' && !onlyAvatar" class =" min-w-0 flex-center-between flex-1 gap-2" >
71+ <div class =" flex-1 truncate text-start" >
72+ {{ userStore.account }}
73+ </div >
74+ <FaIcon name =" i-material-symbols:expand-all-rounded" />
75+ </div >
5676 </FaButton >
5777 </FaDropdown >
5878 <FaModal v-model =" isProfileShow" align-center :header =" false" :footer =" false" :close-on-click-overlay =" false" :close-on-press-escape =" false" class =" h-500px min-w-600px overflow-hidden" content-class =" min-h-full p-0 flex" >
0 commit comments