@@ -29,7 +29,7 @@ const Welcome = {
2929
3030const Avatar = {
3131 template : `
32- <div v-if="$ai.auth?.profileUrl" class="relative" ref="avatarContainer">
32+ <div v-if="$ai.auth?.profileUrl && showComponents.length " class="relative" ref="avatarContainer">
3333 <img
3434 @click.stop="toggleMenu"
3535 :src="$ai.auth.profileUrl"
@@ -39,21 +39,12 @@ const Avatar = {
3939 <div
4040 v-if="showMenu"
4141 @click.stop
42- class="absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 z-50 border" :class="[$styles.messageAssistant]"
43- >
44- <div class="px-4 py-2 text-sm border-b border-[var(--user-border)]">
45- <div class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ $ai.auth.displayName || $ai.auth.userName }}</div>
46- <div class="text-xs whitespace-nowrap overflow-hidden text-ellipsis">{{ $ai.auth.email }}</div>
42+ class="absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 z-50 border" :class="[$styles.messageAssistant]">
43+
44+ <div v-for="component in showComponents">
45+ <component :is="component" :auth="$ai.auth" @done="showMenu = false" />
4746 </div>
48- <button type="button"
49- @click="handleLogout"
50- class="w-full text-left px-4 py-2 text-sm flex items-center whitespace-nowrap hover:bg-[var(--background)]/50"
51- >
52- <svg class="w-4 h-4 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
53- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path>
54- </svg>
55- Sign Out
56- </button>
47+
5748 </div>
5849 </div>
5950 ` ,
@@ -79,20 +70,18 @@ const Avatar = {
7970 showMenu . value = ! showMenu . value
8071 }
8172
82- async function handleLogout ( ) {
83- showMenu . value = false
84- await ai . signOut ( )
85- // Reload the page to show sign-in screen
86- window . location . reload ( )
87- }
88-
8973 // Close menu when clicking outside
9074 const handleClickOutside = ( event ) => {
9175 if ( showMenu . value && avatarContainer . value && ! avatarContainer . value . contains ( event . target ) ) {
9276 showMenu . value = false
9377 }
9478 }
9579
80+ const showComponents = computed ( ( ) => {
81+ const args = { auth : ai . auth }
82+ return Object . values ( ctx . userMenuItemComponents ) . filter ( def => def . show ( args ) ) . map ( def => def . component )
83+ } )
84+
9685 onMounted ( ( ) => {
9786 document . addEventListener ( 'click' , handleClickOutside )
9887 } )
@@ -103,10 +92,10 @@ const Avatar = {
10392
10493 return {
10594 authTitle,
106- handleLogout,
10795 showMenu,
10896 toggleMenu,
10997 avatarContainer,
98+ showComponents,
11099 }
111100 }
112101}
0 commit comments