UserMenu.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 style="margin-left: 8px;" v-if="$auth('degree-manage')" @click="handleScreen(0)">电量管理</a>
  30. <!-- <a style="margin-left: 8px;" @click="handleScreen(1)">设备大屏</a>
  31. <a style="margin-left: 8px;" @click="handleScreen(2)">详情大屏</a>
  32. <a style="margin-left: 8px;" @click="handleScreen(3)">维保大屏</a>
  33. <a style="margin-left: 8px;" @click="handleScreen(4)">仓库大屏</a>-->
  34. <a-dropdown>
  35. <span class="action ant-dropdown-link user-dropdown-menu">
  36. <a-avatar class="avatar" size="small" :src="avatar"/>
  37. <span>{{ nickname }}</span>
  38. </span>
  39. <a-menu slot="overlay" class="user-dropdown-menu-wrapper">
  40. <!-- <a-menu-item key="0">-->
  41. <!-- <router-link :to="{ name: 'center' }">-->
  42. <!-- <a-icon type="user"/>-->
  43. <!-- <span>个人中心</span>-->
  44. <!-- </router-link>-->
  45. <!-- </a-menu-item>-->
  46. <a-menu-item key="1" v-show="!BaseTool.Util._isMobile()">
  47. <router-link :to="{ name: 'settings' }">
  48. <a-icon type="setting"/>
  49. <span>账户设置</span>
  50. </router-link>
  51. </a-menu-item>
  52. <!-- <a-menu-item key="2" disabled>-->
  53. <!-- <a-icon type="setting"/>-->
  54. <!-- <span>测试</span>-->
  55. <!-- </a-menu-item>-->
  56. <a-menu-divider v-show="!BaseTool.Util._isMobile()" />
  57. <a-menu-item key="3">
  58. <a href="javascript:;" @click="handleLogout">
  59. <a-icon type="logout"/>
  60. <span>退出登录</span>
  61. </a>
  62. </a-menu-item>
  63. </a-menu>
  64. </a-dropdown>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import NoticeIcon from '@/components/NoticeIcon'
  70. import { mapActions, mapGetters } from 'vuex'
  71. export default {
  72. name: 'UserMenu',
  73. components: {
  74. NoticeIcon
  75. },
  76. computed: {
  77. ...mapGetters(['nickname', 'avatar'])
  78. },
  79. methods: {
  80. ...mapActions(['Logout']),
  81. changeLangEvent (type) {
  82. // localStorage.setItem('locale', type)
  83. localStorage.setItem('locale', 'zh-CN')
  84. this.$i18n.locale = type
  85. this.$router.go(0)
  86. },
  87. handleScreen (type) {
  88. const a = document.createElement('a')
  89. a.target = '_blank'
  90. if (type === 0) {
  91. a.href = '/SwitchingRoomBigScreen'
  92. } else if (type === 1) {
  93. a.href = '/InfoBigScreen'
  94. } else if (type === 2) {
  95. a.href = '/InfoDetailBigScreen'
  96. } else if (type === 3) {
  97. a.href = '/RepairBigScreen'
  98. } else {
  99. a.href = '/StoreBigScreen'
  100. }
  101. a.click()
  102. },
  103. handleLogout () {
  104. this.$confirm({
  105. title: '提示',
  106. content: '真的要注销登录吗 ?',
  107. okText: '确定',
  108. cancelText: '取消',
  109. onOk: () => {
  110. return this.Logout({}).then(() => {
  111. setTimeout(() => {
  112. window.location.reload()
  113. }, 16)
  114. }).catch(err => {
  115. this.$message.error({
  116. title: '错误',
  117. description: err.message
  118. })
  119. })
  120. },
  121. onCancel () {
  122. }
  123. })
  124. }
  125. }
  126. }
  127. </script>