2024-05-19 21:20:42 +08:00
|
|
|
<script lang="ts" setup>
|
2024-08-07 08:57:56 +08:00
|
|
|
import { computed, onMounted } from 'vue';
|
2024-09-02 15:13:17 +08:00
|
|
|
import { useRouter } from 'vue-router';
|
2024-06-01 23:15:29 +08:00
|
|
|
|
2024-07-13 17:25:15 +08:00
|
|
|
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
|
2024-08-07 08:57:56 +08:00
|
|
|
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
|
2024-09-02 15:13:17 +08:00
|
|
|
import { BookOpenText, CircleHelp, MdiGithub, ProfileIcon } from '@vben/icons';
|
2024-07-11 11:05:01 +08:00
|
|
|
import {
|
|
|
|
BasicLayout,
|
2024-07-12 12:14:09 +08:00
|
|
|
LockScreen,
|
2024-07-11 11:05:01 +08:00
|
|
|
Notification,
|
|
|
|
UserDropdown,
|
|
|
|
} from '@vben/layouts';
|
2024-07-23 00:03:59 +08:00
|
|
|
import { preferences } from '@vben/preferences';
|
2024-09-10 21:48:51 +08:00
|
|
|
import { useAccessStore, useUserStore } from '@vben/stores';
|
2024-05-21 21:45:48 +08:00
|
|
|
import { openWindow } from '@vben/utils';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-08-07 08:57:56 +08:00
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
2024-09-05 08:07:34 +08:00
|
|
|
import { TenantToggle } from '#/components/tenant-toggle';
|
2024-07-07 00:17:44 +08:00
|
|
|
import { $t } from '#/locales';
|
2024-07-05 23:15:46 +08:00
|
|
|
import { resetRoutes } from '#/router';
|
2024-08-07 08:57:56 +08:00
|
|
|
import { useAuthStore, useNotifyStore } from '#/store';
|
2024-09-02 15:37:32 +08:00
|
|
|
import { useTenantStore } from '#/store/tenant';
|
2024-09-10 21:48:51 +08:00
|
|
|
import LoginForm from '#/views/_core/authentication/login.vue';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-07-30 21:10:28 +08:00
|
|
|
const userStore = useUserStore();
|
|
|
|
const authStore = useAuthStore();
|
|
|
|
const accessStore = useAccessStore();
|
2024-09-02 15:13:17 +08:00
|
|
|
const router = useRouter();
|
2024-07-07 16:19:17 +08:00
|
|
|
|
2024-09-02 15:37:32 +08:00
|
|
|
const tenantStore = useTenantStore();
|
|
|
|
const menus = computed(() => {
|
|
|
|
const defaultMenus = [
|
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
openWindow(VBEN_DOC_URL, {
|
|
|
|
target: '_blank',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: BookOpenText,
|
|
|
|
text: $t('widgets.document'),
|
2024-05-19 21:20:42 +08:00
|
|
|
},
|
2024-09-02 15:37:32 +08:00
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
router.push('/profile');
|
|
|
|
},
|
|
|
|
icon: ProfileIcon,
|
|
|
|
text: $t('widgets.profile'),
|
2024-09-02 15:13:17 +08:00
|
|
|
},
|
2024-09-02 15:37:32 +08:00
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
openWindow(VBEN_GITHUB_URL, {
|
|
|
|
target: '_blank',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: MdiGithub,
|
|
|
|
text: 'GitHub',
|
2024-05-19 21:20:42 +08:00
|
|
|
},
|
2024-09-02 15:37:32 +08:00
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
openWindow(`${VBEN_GITHUB_URL}/issues`, {
|
|
|
|
target: '_blank',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: CircleHelp,
|
|
|
|
text: $t('widgets.qa'),
|
2024-05-19 21:20:42 +08:00
|
|
|
},
|
2024-09-02 15:37:32 +08:00
|
|
|
];
|
|
|
|
/**
|
|
|
|
* 租户选中状态 不显示个人中心
|
|
|
|
*/
|
|
|
|
if (tenantStore.checked) {
|
|
|
|
defaultMenus.splice(1, 1);
|
|
|
|
}
|
|
|
|
return defaultMenus;
|
|
|
|
});
|
2024-05-19 21:20:42 +08:00
|
|
|
|
2024-07-12 12:14:09 +08:00
|
|
|
const avatar = computed(() => {
|
2024-07-30 21:10:28 +08:00
|
|
|
return userStore.userInfo?.avatar ?? preferences.app.defaultAvatar;
|
2024-07-12 12:14:09 +08:00
|
|
|
});
|
|
|
|
|
2024-07-05 23:15:46 +08:00
|
|
|
async function handleLogout() {
|
2024-08-07 08:57:56 +08:00
|
|
|
// resetAllStores();
|
2024-07-05 23:15:46 +08:00
|
|
|
resetRoutes();
|
2024-08-07 08:57:56 +08:00
|
|
|
// await router.replace(LOGIN_PATH);
|
|
|
|
authStore.logout();
|
2024-05-19 21:20:42 +08:00
|
|
|
}
|
|
|
|
|
2024-08-07 08:57:56 +08:00
|
|
|
const notifyStore = useNotifyStore();
|
|
|
|
onMounted(() => notifyStore.startListeningMessage());
|
2024-07-07 16:19:17 +08:00
|
|
|
|
2024-08-07 08:57:56 +08:00
|
|
|
function handleViewAll() {
|
|
|
|
message.warning('暂未开放');
|
2024-07-07 16:19:17 +08:00
|
|
|
}
|
2024-05-19 21:20:42 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-07-06 14:41:18 +08:00
|
|
|
<BasicLayout @clear-preferences-and-logout="handleLogout">
|
2024-08-07 11:55:13 +08:00
|
|
|
<template #header-right-1>
|
|
|
|
<TenantToggle />
|
|
|
|
</template>
|
2024-05-19 21:20:42 +08:00
|
|
|
<template #user-dropdown>
|
|
|
|
<UserDropdown
|
2024-07-12 12:14:09 +08:00
|
|
|
:avatar
|
|
|
|
:menus
|
2024-07-30 21:10:28 +08:00
|
|
|
:text="userStore.userInfo?.realName"
|
2024-05-19 21:20:42 +08:00
|
|
|
description="ann.vben@gmail.com"
|
|
|
|
tag-text="Pro"
|
|
|
|
@logout="handleLogout"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template #notification>
|
|
|
|
<Notification
|
2024-08-07 08:57:56 +08:00
|
|
|
:dot="notifyStore.showDot"
|
2024-08-07 16:17:32 +08:00
|
|
|
:notifications="notifyStore.notifications"
|
2024-08-07 08:57:56 +08:00
|
|
|
@clear="notifyStore.clearAllMessage"
|
|
|
|
@make-all="notifyStore.setAllRead"
|
|
|
|
@read="notifyStore.setRead"
|
|
|
|
@view-all="handleViewAll"
|
2024-05-19 21:20:42 +08:00
|
|
|
/>
|
|
|
|
</template>
|
2024-07-12 12:14:09 +08:00
|
|
|
<template #extra>
|
2024-07-11 20:11:11 +08:00
|
|
|
<AuthenticationLoginExpiredModal
|
2024-07-30 21:10:28 +08:00
|
|
|
v-model:open="accessStore.loginExpired"
|
2024-07-18 21:31:34 +08:00
|
|
|
:avatar
|
2024-09-10 21:48:51 +08:00
|
|
|
>
|
|
|
|
<LoginForm />
|
|
|
|
</AuthenticationLoginExpiredModal>
|
2024-07-11 11:05:01 +08:00
|
|
|
</template>
|
2024-07-12 12:14:09 +08:00
|
|
|
<template #lock-screen>
|
2024-07-23 00:03:59 +08:00
|
|
|
<LockScreen :avatar @to-login="handleLogout" />
|
2024-07-12 12:14:09 +08:00
|
|
|
</template>
|
2024-05-19 21:20:42 +08:00
|
|
|
</BasicLayout>
|
|
|
|
</template>
|