Browse Source

feat(vben5): User Description Displays the tenant name

pull/1159/head
colin 10 months ago
parent
commit
af44fbadb5
  1. 24
      apps/vben5/apps/app-antd/src/layouts/basic.vue

24
apps/vben5/apps/app-antd/src/layouts/basic.vue

@ -23,6 +23,8 @@ import { preferences } from '@vben/preferences';
import { useAccessStore, useUserStore } from '@vben/stores';
import { openWindow } from '@vben/utils';
import { useAbpStore } from '@abp/core';
import { useSessions } from '#/hooks/useSessions';
import { $t } from '#/locales';
import { useAuthStore } from '#/store';
@ -64,6 +66,7 @@ const notifications = ref<NotificationItem[]>([
useSessions();
const { replace } = useRouter();
const abpStore = useAbpStore();
const userStore = useUserStore();
const authStore = useAuthStore();
const accessStore = useAccessStore();
@ -109,8 +112,19 @@ const menus = computed(() => [
},
]);
const userInfo = computed(() => {
return userStore.userInfo;
});
const description = computed(() => {
if (abpStore.application?.currentTenant.name && userInfo.value?.username) {
return `${abpStore.application.currentTenant.name}/${userInfo.value.username}`;
}
return userInfo.value?.username;
});
const avatar = computed(() => {
return userStore.userInfo?.avatar ?? preferences.app.defaultAvatar;
return userInfo.value?.avatar ?? preferences.app.defaultAvatar;
});
async function handleLogout() {
@ -129,7 +143,7 @@ watch(
async (enable) => {
if (enable) {
await updateWatermark({
content: `${userStore.userInfo?.username}`,
content: `${userInfo.value?.username}`,
});
} else {
destroyWatermark();
@ -146,10 +160,10 @@ watch(
<template #user-dropdown>
<UserDropdown
:avatar
:description="userStore.userInfo?.email"
:description="description"
:menus
:tag-text="userStore.userInfo?.username"
:text="userStore.userInfo?.realName"
:tag-text="userInfo?.email"
:text="userInfo?.realName"
@logout="handleLogout"
/>
</template>

Loading…
Cancel
Save