@quazardous/qdadm 2.34.0 → 2.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/layout/AppLayout.vue +88 -32
- package/src/components/layout/defaults/DefaultUserInfo.vue +45 -37
- package/src/composables/index.ts +1 -0
- package/src/composables/useUserBox.ts +119 -0
- package/src/i18n/defaults/core.en.generated.ts +2 -0
- package/src/i18n/defaults/core.en.yml +2 -0
- package/src/i18n/defaults/core.fr.generated.ts +2 -0
- package/src/i18n/defaults/core.fr.yml +2 -0
- package/src/index.ts +1 -0
- package/src/kernel/Kernel.types.ts +6 -1
- package/src/plugin.ts +6 -1
package/package.json
CHANGED
|
@@ -16,9 +16,10 @@ import { ref, watch, onMounted, onUnmounted, computed, inject, provide, useSlots
|
|
|
16
16
|
import { SIDEBAR_COLLAPSED_KEY } from '../../composables/useSidebarState'
|
|
17
17
|
import { RouterLink, RouterView, useRouter, useRoute } from 'vue-router'
|
|
18
18
|
import { useNavigation, type NavSection } from '../../composables/useNavigation'
|
|
19
|
-
import { prettifyRole } from '../../utils/formatters'
|
|
20
19
|
import { useApp } from '../../composables/useApp'
|
|
21
20
|
import { useAuth } from '../../composables/useAuth'
|
|
21
|
+
import { useUserBox } from '../../composables/useUserBox'
|
|
22
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
22
23
|
import { useGuardDialog, GUARD_DIALOG_HOST } from '../../composables/useGuardStore'
|
|
23
24
|
import { useNavContext, type BreadcrumbItem, type NavLinkItem } from '../../composables/useNavContext'
|
|
24
25
|
import QdButton from '../base/QdButton.vue'
|
|
@@ -45,14 +46,6 @@ interface SignalBus {
|
|
|
45
46
|
[key: string]: unknown
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
interface UserData {
|
|
49
|
-
username?: string
|
|
50
|
-
name?: string
|
|
51
|
-
email?: string
|
|
52
|
-
role?: string
|
|
53
|
-
[key: string]: unknown
|
|
54
|
-
}
|
|
55
|
-
|
|
56
49
|
const features = inject<FeaturesConfig>('qdadmFeatures', { poweredBy: true, breadcrumb: true })
|
|
57
50
|
const homeRoute = inject<string>('qdadmHomeRoute', 'home')
|
|
58
51
|
|
|
@@ -68,7 +61,9 @@ const app = useApp()
|
|
|
68
61
|
// nested in a plain object stays a ref object (always truthy) in v-if (#1382)
|
|
69
62
|
const appVersion = app.version
|
|
70
63
|
const { navSections, isNavActive, sectionHasActiveItem, handleNavClick } = useNavigation()
|
|
71
|
-
const {
|
|
64
|
+
const { logout, authEnabled } = useAuth()
|
|
65
|
+
const { displayName: userDisplayName, subtitle: userSubtitle, initials: userInitials, avatarUrl, avatarFailed, userRoute, userLink } = useUserBox()
|
|
66
|
+
const { tOr } = useI18n()
|
|
72
67
|
const signals = inject<SignalBus | null>('qdadmSignals', null)
|
|
73
68
|
|
|
74
69
|
// LocalStorage key for collapsed sections state (namespaced by app)
|
|
@@ -201,25 +196,6 @@ watch(() => route.path, () => {
|
|
|
201
196
|
}
|
|
202
197
|
})
|
|
203
198
|
|
|
204
|
-
const userInitials = computed<string>(() => {
|
|
205
|
-
const userData = user.value as UserData | null
|
|
206
|
-
const username = userData?.username
|
|
207
|
-
if (!username) return '?'
|
|
208
|
-
return username.substring(0, 2).toUpperCase()
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
const userDisplayName = computed<string>(() => {
|
|
212
|
-
const userData = user.value as UserData | null
|
|
213
|
-
return userData?.username || userData?.name || 'User'
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
const userSubtitle = computed<string>(() => {
|
|
217
|
-
const userData = user.value as UserData | null
|
|
218
|
-
if (userData?.email) return userData.email
|
|
219
|
-
// raw ROLE_* constants are ugly by default — prettify (#1388)
|
|
220
|
-
return userData?.role ? prettifyRole(userData.role) : ''
|
|
221
|
-
})
|
|
222
|
-
|
|
223
199
|
async function handleLogout(): Promise<void> {
|
|
224
200
|
logout()
|
|
225
201
|
await router.push({ name: 'login' })
|
|
@@ -350,16 +326,47 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
350
326
|
<!-- Running tasks (#4114): shown while there is one -->
|
|
351
327
|
<TaskTray />
|
|
352
328
|
|
|
329
|
+
<!-- With app.userRoute (#4157): name and avatar open the profile, only the glyph logs out -->
|
|
330
|
+
<SidebarBox
|
|
331
|
+
v-if="authEnabled && userRoute"
|
|
332
|
+
id="user-zone"
|
|
333
|
+
class="user-zone--linked"
|
|
334
|
+
:title="userDisplayName"
|
|
335
|
+
:subtitle="userSubtitle"
|
|
336
|
+
>
|
|
337
|
+
<template #icon>
|
|
338
|
+
<button
|
|
339
|
+
type="button"
|
|
340
|
+
class="user-zone-logout"
|
|
341
|
+
:aria-label="tOr('core.actions.logout', 'Logout')"
|
|
342
|
+
v-tooltip.top="tOr('core.actions.logout', 'Logout')"
|
|
343
|
+
@click="handleLogout"
|
|
344
|
+
>
|
|
345
|
+
<i class="pi pi-sign-out"></i>
|
|
346
|
+
</button>
|
|
347
|
+
</template>
|
|
348
|
+
<component
|
|
349
|
+
:is="userLink!.is === 'a' ? 'a' : RouterLink"
|
|
350
|
+
v-bind="userLink!.attrs"
|
|
351
|
+
class="user-zone-link"
|
|
352
|
+
:aria-label="`${userDisplayName} — ${tOr('core.actions.profile', 'My profile')}`"
|
|
353
|
+
v-tooltip.top="tOr('core.actions.profile', 'My profile')"
|
|
354
|
+
>
|
|
355
|
+
<img v-if="avatarUrl" class="user-avatar user-avatar--image" :src="avatarUrl" alt="" referrerpolicy="no-referrer" @error="avatarFailed" />
|
|
356
|
+
<span v-else class="user-avatar">{{ userInitials }}</span>
|
|
357
|
+
</component>
|
|
358
|
+
</SidebarBox>
|
|
353
359
|
<SidebarBox
|
|
354
|
-
v-if="authEnabled"
|
|
360
|
+
v-else-if="authEnabled"
|
|
355
361
|
id="user-zone"
|
|
356
362
|
icon="pi-sign-out"
|
|
357
363
|
:title="userDisplayName"
|
|
358
364
|
:subtitle="userSubtitle"
|
|
359
365
|
@click="handleLogout"
|
|
360
|
-
v-tooltip.top="'Logout'"
|
|
366
|
+
v-tooltip.top="tOr('core.actions.logout', 'Logout')"
|
|
361
367
|
>
|
|
362
|
-
<
|
|
368
|
+
<img v-if="avatarUrl" class="user-avatar user-avatar--image" :src="avatarUrl" alt="" referrerpolicy="no-referrer" @error="avatarFailed" />
|
|
369
|
+
<div v-else class="user-avatar">{{ userInitials }}</div>
|
|
363
370
|
</SidebarBox>
|
|
364
371
|
|
|
365
372
|
<SidebarBox v-if="features.poweredBy" id="powered-by">
|
|
@@ -665,7 +672,55 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
665
672
|
transition: opacity 0.1s ease 0.2s;
|
|
666
673
|
}
|
|
667
674
|
|
|
675
|
+
#user-zone .user-avatar--image {
|
|
676
|
+
object-fit: cover;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/* With app.userRoute (#4157): the link covers the text and the avatar,
|
|
680
|
+
the glyph on the left stays the logout button */
|
|
681
|
+
#user-zone.user-zone--linked {
|
|
682
|
+
cursor: default;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
#user-zone .user-zone-link {
|
|
686
|
+
position: absolute;
|
|
687
|
+
inset: 0 0 0 2.25rem;
|
|
688
|
+
color: inherit;
|
|
689
|
+
border-radius: var(--fad-radius-sm, 4px);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
#user-zone .user-zone-link:focus-visible {
|
|
693
|
+
outline: 2px solid var(--p-primary-color, #3b82f6);
|
|
694
|
+
outline-offset: -2px;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
#user-zone.user-zone--linked:has(.user-zone-link.router-link-active) {
|
|
698
|
+
background: var(--p-surface-700, #334155);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
#user-zone .user-zone-logout {
|
|
702
|
+
width: 100%;
|
|
703
|
+
height: 100%;
|
|
704
|
+
padding: 0;
|
|
705
|
+
border: none;
|
|
706
|
+
border-radius: 50%;
|
|
707
|
+
background: transparent;
|
|
708
|
+
color: inherit;
|
|
709
|
+
font: inherit;
|
|
710
|
+
cursor: pointer;
|
|
711
|
+
display: flex;
|
|
712
|
+
align-items: center;
|
|
713
|
+
justify-content: center;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
#user-zone .user-zone-logout:hover,
|
|
717
|
+
#user-zone .user-zone-logout:focus-visible {
|
|
718
|
+
color: var(--p-surface-0, #fff);
|
|
719
|
+
background: var(--p-surface-600, #475569);
|
|
720
|
+
}
|
|
721
|
+
|
|
668
722
|
/* Avatar: disappear IMMEDIATELY when closing */
|
|
723
|
+
.sidebar--collapsed #user-zone .user-zone-link,
|
|
669
724
|
.sidebar--collapsed #user-zone .user-avatar {
|
|
670
725
|
opacity: 0;
|
|
671
726
|
visibility: hidden;
|
|
@@ -974,6 +1029,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
974
1029
|
}
|
|
975
1030
|
|
|
976
1031
|
.sidebar.sidebar--collapsed #user-zone .user-avatar,
|
|
1032
|
+
.sidebar.sidebar--collapsed #user-zone .user-zone-link,
|
|
977
1033
|
.sidebar.sidebar--collapsed .sidebar-box-content {
|
|
978
1034
|
opacity: 1;
|
|
979
1035
|
width: auto;
|
|
@@ -7,41 +7,16 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This component is used when auth is enabled.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import { useRouter } from 'vue-router'
|
|
12
|
-
import { prettifyRole } from '../../../utils/formatters'
|
|
10
|
+
import { useRouter, RouterLink } from 'vue-router'
|
|
13
11
|
import { useAuth } from '../../../composables/useAuth'
|
|
12
|
+
import { useUserBox } from '../../../composables/useUserBox'
|
|
13
|
+
import { useI18n } from '../../../i18n/useI18n'
|
|
14
14
|
import QdButton from '../../base/QdButton.vue'
|
|
15
15
|
|
|
16
|
-
interface UserData {
|
|
17
|
-
username?: string
|
|
18
|
-
name?: string
|
|
19
|
-
email?: string
|
|
20
|
-
role?: string
|
|
21
|
-
[key: string]: unknown
|
|
22
|
-
}
|
|
23
|
-
|
|
24
16
|
const router = useRouter()
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const userData = computed<UserData | null>(() => user.value as UserData | null)
|
|
29
|
-
|
|
30
|
-
const userInitials: ComputedRef<string> = computed(() => {
|
|
31
|
-
const username = userData.value?.username
|
|
32
|
-
if (!username) return '?'
|
|
33
|
-
return username.substring(0, 2).toUpperCase()
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const userDisplayName: ComputedRef<string> = computed(() => {
|
|
37
|
-
return userData.value?.username || userData.value?.name || 'User'
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const userSubtitle: ComputedRef<string> = computed(() => {
|
|
41
|
-
if (userData.value?.email) return userData.value.email
|
|
42
|
-
// raw ROLE_* constants are ugly by default — prettify (#1388)
|
|
43
|
-
return userData.value?.role ? prettifyRole(userData.value.role) : ''
|
|
44
|
-
})
|
|
17
|
+
const { logout, authEnabled } = useAuth()
|
|
18
|
+
const { displayName: userDisplayName, subtitle: userSubtitle, initials: userInitials, avatarUrl, avatarFailed, userLink } = useUserBox()
|
|
19
|
+
const { tOr } = useI18n()
|
|
45
20
|
|
|
46
21
|
function handleLogout(): void {
|
|
47
22
|
logout()
|
|
@@ -51,18 +26,28 @@ function handleLogout(): void {
|
|
|
51
26
|
|
|
52
27
|
<template>
|
|
53
28
|
<div v-if="authEnabled" class="default-user-info">
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
29
|
+
<!-- With app.userRoute (#4157): avatar and name open the profile -->
|
|
30
|
+
<component
|
|
31
|
+
:is="!userLink ? 'div' : userLink.is === 'a' ? 'a' : RouterLink"
|
|
32
|
+
v-bind="userLink ? { ...userLink.attrs, title: tOr('core.actions.profile', 'My profile') } : {}"
|
|
33
|
+
class="user-identity"
|
|
34
|
+
:class="{ 'user-identity--link': userLink }"
|
|
35
|
+
>
|
|
36
|
+
<img v-if="avatarUrl" class="user-avatar user-avatar--image" :src="avatarUrl" alt="" referrerpolicy="no-referrer" @error="avatarFailed" />
|
|
37
|
+
<div v-else class="user-avatar">{{ userInitials }}</div>
|
|
38
|
+
<div class="user-details">
|
|
39
|
+
<div class="user-name">{{ userDisplayName }}</div>
|
|
40
|
+
<div class="user-role">{{ userSubtitle }}</div>
|
|
41
|
+
</div>
|
|
42
|
+
</component>
|
|
59
43
|
<QdButton
|
|
60
44
|
icon="pi pi-sign-out"
|
|
61
45
|
severity="secondary"
|
|
62
46
|
text
|
|
63
47
|
rounded
|
|
48
|
+
:aria-label="tOr('core.actions.logout', 'Logout')"
|
|
64
49
|
@click="handleLogout"
|
|
65
|
-
v-tooltip.top="'Logout'"
|
|
50
|
+
v-tooltip.top="tOr('core.actions.logout', 'Logout')"
|
|
66
51
|
/>
|
|
67
52
|
</div>
|
|
68
53
|
</template>
|
|
@@ -80,7 +65,26 @@ function handleLogout(): void {
|
|
|
80
65
|
border-top: 1px solid var(--p-surface-700, #334155);
|
|
81
66
|
}
|
|
82
67
|
|
|
68
|
+
.user-identity {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 0.75rem;
|
|
72
|
+
flex: 1;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
color: inherit;
|
|
75
|
+
text-decoration: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.user-identity--link {
|
|
79
|
+
border-radius: 6px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.user-identity--link:hover .user-name {
|
|
83
|
+
text-decoration: underline;
|
|
84
|
+
}
|
|
85
|
+
|
|
83
86
|
.user-avatar {
|
|
87
|
+
flex-shrink: 0;
|
|
84
88
|
width: 36px;
|
|
85
89
|
height: 36px;
|
|
86
90
|
border-radius: 50%;
|
|
@@ -93,6 +97,10 @@ function handleLogout(): void {
|
|
|
93
97
|
color: var(--p-surface-0, white);
|
|
94
98
|
}
|
|
95
99
|
|
|
100
|
+
.user-avatar--image {
|
|
101
|
+
object-fit: cover;
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
.user-details {
|
|
97
105
|
flex: 1;
|
|
98
106
|
min-width: 0;
|
package/src/composables/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ export {
|
|
|
50
50
|
export { usePageTitle, type UsePageTitleReturn, type TitleParts, type TitleInput } from './usePageTitle'
|
|
51
51
|
export { useApp, type UseAppReturn } from './useApp'
|
|
52
52
|
export { useAuth, type UseAuthReturn } from './useAuth'
|
|
53
|
+
export { useUserBox, resolveUserAvatar, isExternalUserLink, type UseUserBoxReturn, type UserAvatarResolver, type UserBoxUser } from './useUserBox'
|
|
53
54
|
export { useSecurity, type UseSecurityReturn } from './useSecurity'
|
|
54
55
|
export {
|
|
55
56
|
useEntityItemPage,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useUserBox - what the sidebar user box shows (#4157)
|
|
3
|
+
*
|
|
4
|
+
* Shared by AppLayout and DefaultUserInfo: the signed-in user's name,
|
|
5
|
+
* subtitle, initials, avatar picture and profile link, all read from the
|
|
6
|
+
* auth user and the `app` config (`app.userRoute`, `app.userAvatar`).
|
|
7
|
+
* `app.userRoute` is an app route, or an absolute URL opened in a new tab.
|
|
8
|
+
*/
|
|
9
|
+
import { computed, inject, ref, watch, type ComputedRef, type Ref } from 'vue'
|
|
10
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
11
|
+
import { useAuth } from './useAuth'
|
|
12
|
+
import { prettifyRole } from '../utils/formatters'
|
|
13
|
+
|
|
14
|
+
export interface UserBoxUser {
|
|
15
|
+
username?: string
|
|
16
|
+
name?: string
|
|
17
|
+
email?: string
|
|
18
|
+
role?: string
|
|
19
|
+
avatar?: string | null
|
|
20
|
+
avatarUrl?: string | null
|
|
21
|
+
[key: string]: unknown
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Where the avatar picture is, for a user; null or '' shows the initials. */
|
|
25
|
+
export type UserAvatarResolver = (user: UserBoxUser) => string | null | undefined
|
|
26
|
+
|
|
27
|
+
interface UserBoxAppConfig {
|
|
28
|
+
userRoute?: RouteLocationRaw | null
|
|
29
|
+
userAvatar?: UserAvatarResolver | null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An absolute URL (`https://…`, `http://…`, `//host/…`, `mailto:…`) rather
|
|
34
|
+
* than an app route. Only these schemes: a route name may hold a colon.
|
|
35
|
+
*/
|
|
36
|
+
export function isExternalUserLink(link: unknown): boolean {
|
|
37
|
+
return typeof link === 'string' && /^(https?:|mailto:|\/\/)/i.test(link.trim())
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The avatar URL of a user: the app's resolver when it has one, else
|
|
42
|
+
* `user.avatar` or `user.avatarUrl`.
|
|
43
|
+
*/
|
|
44
|
+
export function resolveUserAvatar(user: UserBoxUser | null | undefined, resolver?: UserAvatarResolver | null): string | null {
|
|
45
|
+
if (!user) return null
|
|
46
|
+
let url: unknown
|
|
47
|
+
if (resolver) {
|
|
48
|
+
try {
|
|
49
|
+
url = resolver(user)
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.warn('[qdadm] app.userAvatar threw, showing initials:', err)
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
url = user.avatar || user.avatarUrl
|
|
56
|
+
}
|
|
57
|
+
return typeof url === 'string' && url.trim() ? url : null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface UseUserBoxReturn {
|
|
61
|
+
user: ComputedRef<UserBoxUser | null>
|
|
62
|
+
displayName: ComputedRef<string>
|
|
63
|
+
subtitle: ComputedRef<string>
|
|
64
|
+
initials: ComputedRef<string>
|
|
65
|
+
/** The picture to show, or null for the initials (none, or it failed). */
|
|
66
|
+
avatarUrl: ComputedRef<string | null>
|
|
67
|
+
/** Call from the img's `error` event: the initials come back. */
|
|
68
|
+
avatarFailed: () => void
|
|
69
|
+
/** The profile page, when the app declares one: an app route or an external URL. */
|
|
70
|
+
userRoute: RouteLocationRaw | null
|
|
71
|
+
/** Bind on the profile link: `{ to }` for a route, `{ href, target, rel }` for an external URL. */
|
|
72
|
+
userLink: { is: 'a' | 'RouterLink'; attrs: Record<string, unknown> } | null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function useUserBox(): UseUserBoxReturn {
|
|
76
|
+
const { user: authUser } = useAuth()
|
|
77
|
+
const app = inject<UserBoxAppConfig | null>('qdadmApp', null)
|
|
78
|
+
|
|
79
|
+
const user = computed(() => (authUser.value as UserBoxUser | null) ?? null)
|
|
80
|
+
|
|
81
|
+
const displayName = computed(() => user.value?.username || user.value?.name || 'User')
|
|
82
|
+
|
|
83
|
+
const subtitle = computed(() => {
|
|
84
|
+
if (user.value?.email) return user.value.email
|
|
85
|
+
// raw ROLE_* constants are ugly by default — prettify (#1388)
|
|
86
|
+
return user.value?.role ? prettifyRole(user.value.role) : ''
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const initials = computed(() => {
|
|
90
|
+
const username = user.value?.username
|
|
91
|
+
if (!username) return '?'
|
|
92
|
+
return username.substring(0, 2).toUpperCase()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const resolved = computed(() => resolveUserAvatar(user.value, app?.userAvatar))
|
|
96
|
+
const failed: Ref<string | null> = ref(null)
|
|
97
|
+
// A new URL gets its own chance to load
|
|
98
|
+
watch(resolved, () => (failed.value = null))
|
|
99
|
+
const avatarUrl = computed(() => (resolved.value && resolved.value !== failed.value ? resolved.value : null))
|
|
100
|
+
|
|
101
|
+
const userRoute = app?.userRoute ?? null
|
|
102
|
+
const userLink = !userRoute
|
|
103
|
+
? null
|
|
104
|
+
: isExternalUserLink(userRoute)
|
|
105
|
+
? { is: 'a' as const, attrs: { href: userRoute as string, target: '_blank', rel: 'noopener noreferrer' } }
|
|
106
|
+
: // A bare string is a route name, as for homeRoute; '/…' is a path
|
|
107
|
+
{ is: 'RouterLink' as const, attrs: { to: typeof userRoute === 'string' && !userRoute.startsWith('/') ? { name: userRoute } : userRoute } }
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
user,
|
|
111
|
+
displayName,
|
|
112
|
+
subtitle,
|
|
113
|
+
initials,
|
|
114
|
+
avatarUrl,
|
|
115
|
+
avatarFailed: () => (failed.value = resolved.value),
|
|
116
|
+
userRoute,
|
|
117
|
+
userLink,
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -263,6 +263,7 @@ export {
|
|
|
263
263
|
} from './composables/usePageTitle'
|
|
264
264
|
export { useApp, type UseAppReturn } from './composables/useApp'
|
|
265
265
|
export { useAuth, type UseAuthReturn } from './composables/useAuth'
|
|
266
|
+
export { useUserBox, resolveUserAvatar, isExternalUserLink, type UseUserBoxReturn, type UserAvatarResolver, type UserBoxUser } from './composables/useUserBox'
|
|
266
267
|
export { useSecurity, type UseSecurityReturn } from './composables/useSecurity'
|
|
267
268
|
export {
|
|
268
269
|
useEntityItemPage,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Extracted from Kernel.ts for maintainability.
|
|
5
5
|
*/
|
|
6
6
|
import type { Component } from 'vue'
|
|
7
|
-
import type { RouteRecordRaw } from 'vue-router'
|
|
7
|
+
import type { RouteLocationRaw, RouteRecordRaw } from 'vue-router'
|
|
8
8
|
import type { SignalBus } from './SignalBus'
|
|
9
9
|
import type { RoutesConfig } from './EventRouter'
|
|
10
10
|
import type { EntityManager } from '../entity/EntityManager'
|
|
@@ -14,6 +14,7 @@ import type { GrantJudge } from '../entity/auth/SecurityChecker'
|
|
|
14
14
|
import type { I18nOptions } from '../i18n/types'
|
|
15
15
|
import type { ApiClientSource } from '../api/apiClient'
|
|
16
16
|
import type { RouteStatePersister } from '../routeState'
|
|
17
|
+
import type { UserAvatarResolver } from '../composables/useUserBox'
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Auth adapter interface (app-level authentication)
|
|
@@ -45,6 +46,10 @@ export interface AppConfig {
|
|
|
45
46
|
version?: string
|
|
46
47
|
logo?: string
|
|
47
48
|
theme?: string
|
|
49
|
+
/** The signed-in user's profile page, an app route or an absolute URL: the sidebar name and avatar link to it, the glyph logs out (#4157). */
|
|
50
|
+
userRoute?: RouteLocationRaw | string
|
|
51
|
+
/** The sidebar avatar picture; default `user.avatar` or `user.avatarUrl`, initials when none (#4157). */
|
|
52
|
+
userAvatar?: UserAvatarResolver
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/**
|
package/src/plugin.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { App } from 'vue'
|
|
8
|
-
import type { Router, RouteLocationNormalized, NavigationGuardNext } from 'vue-router'
|
|
8
|
+
import type { Router, RouteLocationNormalized, RouteLocationRaw, NavigationGuardNext } from 'vue-router'
|
|
9
|
+
import type { UserAvatarResolver } from './composables/useUserBox'
|
|
9
10
|
import { Orchestrator } from './orchestrator/Orchestrator'
|
|
10
11
|
import { EntityManager } from './entity/EntityManager'
|
|
11
12
|
import qdadmLogo from './assets/logo.svg'
|
|
@@ -53,6 +54,10 @@ export interface AppConfig {
|
|
|
53
54
|
favicon?: string | null
|
|
54
55
|
version?: string | null
|
|
55
56
|
theme?: AppTheme
|
|
57
|
+
/** The signed-in user's profile page (#4157). */
|
|
58
|
+
userRoute?: RouteLocationRaw | null
|
|
59
|
+
/** The sidebar avatar picture (#4157). */
|
|
60
|
+
userAvatar?: UserAvatarResolver | null
|
|
56
61
|
[key: string]: unknown
|
|
57
62
|
}
|
|
58
63
|
|