layout.vue 3.0 KB

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