UserMenu.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div class="user-wrapper">
  3. <div class="content-box">
  4. <a href="https://pro.loacg.com/docs/getting-started" target="_blank">
  5. <span class="action">
  6. <a-icon type="question-circle-o"></a-icon>
  7. </span>
  8. </a>
  9. <notice-icon class="action"/>
  10. <a-dropdown>
  11. <span class="action ant-dropdown-link user-dropdown-menu">
  12. <a-avatar class="avatar" size="small" :src="avatar"/>
  13. <span>{{ nickname }}</span>
  14. </span>
  15. <a-menu slot="overlay" class="user-dropdown-menu-wrapper">
  16. <a-menu-item key="0">
  17. <router-link :to="{ name: 'center' }">
  18. <a-icon type="user"/>
  19. <span>个人中心</span>
  20. </router-link>
  21. </a-menu-item>
  22. <a-menu-item key="1">
  23. <router-link :to="{ name: 'settings' }">
  24. <a-icon type="setting"/>
  25. <span>账户设置</span>
  26. </router-link>
  27. </a-menu-item>
  28. <a-menu-item key="2" disabled>
  29. <a-icon type="setting"/>
  30. <span>测试</span>
  31. </a-menu-item>
  32. <a-menu-divider/>
  33. <a-menu-item key="3">
  34. <a href="javascript:;" @click="handleLogout">
  35. <a-icon type="logout"/>
  36. <span>退出登录</span>
  37. </a>
  38. </a-menu-item>
  39. </a-menu>
  40. </a-dropdown>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import NoticeIcon from '@/components/NoticeIcon'
  46. import { mapActions, mapGetters } from 'vuex'
  47. export default {
  48. name: 'UserMenu',
  49. components: {
  50. NoticeIcon
  51. },
  52. computed: {
  53. ...mapGetters(['nickname', 'avatar'])
  54. },
  55. methods: {
  56. ...mapActions(['Logout']),
  57. handleLogout () {
  58. this.$confirm({
  59. title: '提示',
  60. content: '真的要注销登录吗 ?',
  61. onOk: () => {
  62. return this.Logout({}).then(() => {
  63. setTimeout(() => {
  64. window.location.reload()
  65. }, 16)
  66. }).catch(err => {
  67. this.$message.error({
  68. title: '错误',
  69. description: err.message
  70. })
  71. })
  72. },
  73. onCancel () {
  74. }
  75. })
  76. }
  77. }
  78. }
  79. </script>