2024-05-19 21:20:42 +08:00
|
|
|
<script lang="ts" setup>
|
2024-07-12 12:14:09 +08:00
|
|
|
import { computed, ref } from 'vue';
|
2024-06-08 19:49:06 +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-07-05 23:15:46 +08:00
|
|
|
import { LOGIN_PATH } from '@vben/constants';
|
2024-07-17 22:25:27 +08:00
|
|
|
import { BookOpenText, CircleHelp, MdiGithub } 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,
|
|
|
|
NotificationItem,
|
|
|
|
UserDropdown,
|
|
|
|
} from '@vben/layouts';
|
2024-07-23 00:03:59 +08:00
|
|
|
import { preferences } from '@vben/preferences';
|
2024-05-21 21:45:48 +08:00
|
|
|
import { openWindow } from '@vben/utils';
|
2024-05-19 21:20:42 +08:00
|
|
|
|
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-07-23 00:03:59 +08:00
|
|
|
import { resetAllStores, storeToRefs, useAccessStore } from '#/store';
|
2024-06-30 15:03:37 +08:00
|
|
|
|
2024-05-19 21:20:42 +08:00
|
|
|
const notifications = ref<NotificationItem[]>([
|
|
|
|
{
|
|
|
|
avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB',
|
|
|
|
date: '3小时前',
|
|
|
|
isRead: true,
|
|
|
|
message: '描述信息描述信息描述信息',
|
|
|
|
title: '收到了 14 份新周报',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
avatar: 'https://avatar.vercel.sh/1',
|
|
|
|
date: '刚刚',
|
|
|
|
isRead: false,
|
|
|
|
message: '描述信息描述信息描述信息',
|
|
|
|
title: '朱偏右 回复了你',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
avatar: 'https://avatar.vercel.sh/1',
|
|
|
|
date: '2024-01-01',
|
|
|
|
isRead: false,
|
|
|
|
message: '描述信息描述信息描述信息',
|
|
|
|
title: '曲丽丽 评论了你',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
avatar: 'https://avatar.vercel.sh/satori',
|
|
|
|
date: '1天前',
|
|
|
|
isRead: false,
|
|
|
|
message: '描述信息描述信息描述信息',
|
|
|
|
title: '代办提醒',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
2024-07-07 16:19:17 +08:00
|
|
|
const showDot = computed(() =>
|
|
|
|
notifications.value.some((item) => !item.isRead),
|
|
|
|
);
|
|
|
|
|
2024-05-19 21:20:42 +08:00
|
|
|
const menus = computed(() => [
|
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
openWindow('https://github.com/vbenjs/vue-vben-admin', {
|
|
|
|
target: '_blank',
|
|
|
|
});
|
|
|
|
},
|
2024-07-17 22:25:27 +08:00
|
|
|
icon: BookOpenText,
|
2024-05-19 21:20:42 +08:00
|
|
|
text: $t('widgets.document'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
openWindow('https://github.com/vbenjs/vue-vben-admin', {
|
|
|
|
target: '_blank',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: MdiGithub,
|
|
|
|
text: 'GitHub',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
handler: () => {
|
|
|
|
openWindow('https://github.com/vbenjs/vue-vben-admin/issues', {
|
|
|
|
target: '_blank',
|
|
|
|
});
|
|
|
|
},
|
2024-07-17 22:25:27 +08:00
|
|
|
icon: CircleHelp,
|
2024-05-19 21:20:42 +08:00
|
|
|
text: $t('widgets.qa'),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
2024-07-11 11:05:01 +08:00
|
|
|
const accessStore = useAccessStore();
|
2024-07-12 12:14:09 +08:00
|
|
|
|
2024-07-11 21:48:56 +08:00
|
|
|
const {
|
|
|
|
loading: loginLoading,
|
|
|
|
openLoginExpiredModal,
|
|
|
|
userInfo,
|
2024-07-12 12:14:09 +08:00
|
|
|
} = storeToRefs(accessStore);
|
|
|
|
|
|
|
|
const avatar = computed(() => {
|
|
|
|
return userInfo.value?.avatar ?? preferences.app.defaultAvatar;
|
|
|
|
});
|
|
|
|
|
2024-05-19 21:20:42 +08:00
|
|
|
const router = useRouter();
|
2024-06-30 15:03:37 +08:00
|
|
|
|
2024-07-05 23:15:46 +08:00
|
|
|
async function handleLogout() {
|
2024-07-23 00:03:59 +08:00
|
|
|
resetAllStores();
|
2024-07-05 23:15:46 +08:00
|
|
|
resetRoutes();
|
2024-07-12 22:22:36 +08:00
|
|
|
await router.replace(LOGIN_PATH);
|
2024-05-19 21:20:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleNoticeClear() {
|
|
|
|
notifications.value = [];
|
|
|
|
}
|
2024-07-07 16:19:17 +08:00
|
|
|
|
|
|
|
function handleMakeAll() {
|
|
|
|
notifications.value.forEach((item) => (item.isRead = true));
|
|
|
|
}
|
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-05-19 21:20:42 +08:00
|
|
|
<template #user-dropdown>
|
|
|
|
<UserDropdown
|
2024-07-12 12:14:09 +08:00
|
|
|
:avatar
|
|
|
|
:menus
|
2024-07-07 23:52:19 +08:00
|
|
|
:text="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-07-07 16:19:17 +08:00
|
|
|
:dot="showDot"
|
2024-05-19 21:20:42 +08:00
|
|
|
:notifications="notifications"
|
|
|
|
@clear="handleNoticeClear"
|
2024-07-07 16:19:17 +08:00
|
|
|
@make-all="handleMakeAll"
|
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
|
|
|
|
v-model:open="openLoginExpiredModal"
|
2024-07-18 21:31:34 +08:00
|
|
|
:avatar
|
2024-07-11 21:48:56 +08:00
|
|
|
:loading="loginLoading"
|
2024-07-11 11:05:01 +08:00
|
|
|
password-placeholder="123456"
|
|
|
|
username-placeholder="vben"
|
2024-07-11 20:11:11 +08:00
|
|
|
@submit="accessStore.authLogin"
|
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>
|