basic.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <script lang="ts" setup>
  2. import type { NotificationItem } from '@vben/common-ui';
  3. import { computed, ref } from 'vue';
  4. import { useRouter } from 'vue-router';
  5. import { Notification, UserDropdown } from '@vben/common-ui';
  6. import { IcRoundCreditScore, MdiDriveDocument, MdiGithub } from '@vben/icons';
  7. import { BasicLayout } from '@vben/layouts';
  8. import { $t } from '@vben/locales';
  9. import { openWindow } from '@vben/utils';
  10. import { preferences } from '@vben-core/preferences';
  11. import { useAccessStore } from '@vben-core/stores';
  12. // https://avatar.vercel.sh/vercel.svg?text=Vaa
  13. // https://avatar.vercel.sh/1
  14. // https://avatar.vercel.sh/nextjs
  15. // https://avatar.vercel.sh/satori
  16. const notifications = ref<NotificationItem[]>([
  17. {
  18. avatar: 'https://avatar.vercel.sh/vercel.svg?text=VB',
  19. date: '3小时前',
  20. isRead: true,
  21. message: '描述信息描述信息描述信息',
  22. title: '收到了 14 份新周报',
  23. },
  24. {
  25. avatar: 'https://avatar.vercel.sh/1',
  26. date: '刚刚',
  27. isRead: false,
  28. message: '描述信息描述信息描述信息',
  29. title: '朱偏右 回复了你',
  30. },
  31. {
  32. avatar: 'https://avatar.vercel.sh/1',
  33. date: '2024-01-01',
  34. isRead: false,
  35. message: '描述信息描述信息描述信息',
  36. title: '曲丽丽 评论了你',
  37. },
  38. {
  39. avatar: 'https://avatar.vercel.sh/satori',
  40. date: '1天前',
  41. isRead: false,
  42. message: '描述信息描述信息描述信息',
  43. title: '代办提醒',
  44. },
  45. ]);
  46. const menus = computed(() => [
  47. {
  48. handler: () => {
  49. openWindow('https://github.com/vbenjs/vue-vben-admin', {
  50. target: '_blank',
  51. });
  52. },
  53. icon: MdiDriveDocument,
  54. text: $t('widgets.document'),
  55. },
  56. {
  57. handler: () => {
  58. openWindow('https://github.com/vbenjs/vue-vben-admin', {
  59. target: '_blank',
  60. });
  61. },
  62. icon: MdiGithub,
  63. text: 'GitHub',
  64. },
  65. {
  66. handler: () => {
  67. openWindow('https://github.com/vbenjs/vue-vben-admin/issues', {
  68. target: '_blank',
  69. });
  70. },
  71. icon: IcRoundCreditScore,
  72. text: $t('widgets.qa'),
  73. },
  74. ]);
  75. const accessStore = useAccessStore();
  76. const router = useRouter();
  77. function handleLogout() {
  78. accessStore.$reset();
  79. router.replace('/auth/login');
  80. }
  81. function handleNoticeClear() {
  82. notifications.value = [];
  83. }
  84. </script>
  85. <template>
  86. <BasicLayout>
  87. <template #user-dropdown>
  88. <UserDropdown
  89. :avatar="preferences.app.defaultAvatar"
  90. :menus="menus"
  91. text="Vben Admin"
  92. description="ann.vben@gmail.com"
  93. tag-text="Pro"
  94. @logout="handleLogout"
  95. />
  96. </template>
  97. <template #notification>
  98. <Notification
  99. dot
  100. :notifications="notifications"
  101. @clear="handleNoticeClear"
  102. />
  103. </template>
  104. </BasicLayout>
  105. </template>