UserMenu.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-icon type="setting"/>
  13. <span>{{$t('m.common.language')}}</span>
  14. </span>
  15. <a-menu slot="overlay" class="user-dropdown-menu-wrapper">
  16. <a-menu-item key="0" v-show="!BaseTool.Util._isMobile()">
  17. <a href="javascript:;" @click="changeLangEvent('zh-CN')">
  18. <span>Chinese</span>
  19. </a>
  20. </a-menu-item>
  21. <a-menu-divider v-show="!BaseTool.Util._isMobile()" />
  22. <a-menu-item key="1">
  23. <a href="javascript:;" @click="changeLangEvent('en-US')">
  24. <span>English</span>
  25. </a>
  26. </a-menu-item>
  27. </a-menu>
  28. </a-dropdown>-->
  29. <a-dropdown>
  30. <span class="action ant-dropdown-link user-dropdown-menu">
  31. <a-avatar class="avatar" size="small" :src="avatar"/>
  32. <span>{{ nickname }}</span>
  33. </span>
  34. <a-menu slot="overlay" class="user-dropdown-menu-wrapper">
  35. <!-- <a-menu-item key="0">-->
  36. <!-- <router-link :to="{ name: 'center' }">-->
  37. <!-- <a-icon type="user"/>-->
  38. <!-- <span>个人中心</span>-->
  39. <!-- </router-link>-->
  40. <!-- </a-menu-item>-->
  41. <a-menu-item key="1" v-show="!BaseTool.Util._isMobile()">
  42. <router-link :to="{ name: 'settings' }">
  43. <a-icon type="setting"/>
  44. <span>账户设置</span>
  45. </router-link>
  46. </a-menu-item>
  47. <!-- <a-menu-item key="2" disabled>-->
  48. <!-- <a-icon type="setting"/>-->
  49. <!-- <span>测试</span>-->
  50. <!-- </a-menu-item>-->
  51. <a-menu-divider v-show="!BaseTool.Util._isMobile()" />
  52. <a-menu-item key="3">
  53. <a href="javascript:;" @click="handleLogout">
  54. <a-icon type="logout"/>
  55. <span>退出登录</span>
  56. </a>
  57. </a-menu-item>
  58. </a-menu>
  59. </a-dropdown>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import NoticeIcon from '@/components/NoticeIcon'
  65. import { mapActions, mapGetters } from 'vuex'
  66. export default {
  67. name: 'UserMenu',
  68. components: {
  69. NoticeIcon
  70. },
  71. computed: {
  72. ...mapGetters(['nickname', 'avatar'])
  73. },
  74. methods: {
  75. ...mapActions(['Logout']),
  76. changeLangEvent (type) {
  77. localStorage.setItem('locale', type)
  78. this.$i18n.locale = type
  79. this.$router.go(0)
  80. },
  81. handleLogout () {
  82. this.$confirm({
  83. title: '提示',
  84. content: '真的要注销登录吗 ?',
  85. onOk: () => {
  86. return this.Logout({}).then(() => {
  87. setTimeout(() => {
  88. window.location.reload()
  89. }, 16)
  90. }).catch(err => {
  91. this.$message.error({
  92. title: '错误',
  93. description: err.message
  94. })
  95. })
  96. },
  97. onCancel () {
  98. }
  99. })
  100. }
  101. }
  102. }
  103. </script>