main-navbar.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType">
  3. <div class="site-navbar__header">
  4. <h1 class="site-navbar__brand" @click="$router.push({ name: 'home' })">
  5. <a class="site-navbar__brand-lg" href="javascript:;">智慧机场平台</a>
  6. <a class="site-navbar__brand-mini" href="javascript:;">机场</a>
  7. </h1>
  8. </div>
  9. <div class="site-navbar__body clearfix">
  10. <el-menu
  11. class="site-navbar__menu"
  12. mode="horizontal">
  13. <el-menu-item class="site-navbar__switch" index="0" @click="sidebarFold = !sidebarFold">
  14. <icon-svg name="zhedie"></icon-svg>
  15. </el-menu-item>
  16. </el-menu>
  17. <el-menu
  18. class="site-navbar__menu site-navbar__menu--right"
  19. mode="horizontal">
  20. <el-menu-item index="0" @click="$router.push({ name: 'msgCenter' })">
  21. <template slot="title">
  22. <el-badge value="1">
  23. <icon-svg name="lingdang" class="el-icon-lingdang"></icon-svg>
  24. </el-badge>
  25. </template>
  26. </el-menu-item>
  27. <el-menu-item index="1" @click="$router.push({ name: 'theme' })">
  28. <template slot="title">
  29. <el-badge value="">
  30. <icon-svg name="shezhi" class="el-icon-setting"></icon-svg>
  31. </el-badge>
  32. </template>
  33. </el-menu-item>
  34. <el-menu-item class="site-navbar__avatar" index="3">
  35. <el-dropdown :show-timeout="0" placement="bottom">
  36. <span class="el-dropdown-link">
  37. <img src="~@/assets/img/avatar.png" :alt="userName">{{ userName }}
  38. </span>
  39. <el-dropdown-menu slot="dropdown">
  40. <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>
  41. <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item>
  42. </el-dropdown-menu>
  43. </el-dropdown>
  44. </el-menu-item>
  45. </el-menu>
  46. </div>
  47. <!-- 弹窗, 修改密码 -->
  48. <update-password v-if="updatePasswordVisible" ref="updatePassowrd"></update-password>
  49. <Msg ref="msgDialog"/>
  50. </nav>
  51. </template>
  52. <script>
  53. import UpdatePassword from './main-navbar-update-password'
  54. import Msg from './common/msg'
  55. import { clearLoginInfo } from '@/utils'
  56. export default {
  57. data () {
  58. return {
  59. updatePasswordVisible: false
  60. }
  61. },
  62. components: {
  63. UpdatePassword,
  64. Msg
  65. },
  66. computed: {
  67. navbarLayoutType: {
  68. get () { return this.$store.state.common.navbarLayoutType }
  69. },
  70. sidebarFold: {
  71. get () { return this.$store.state.common.sidebarFold },
  72. set (val) { this.$store.commit('common/updateSidebarFold', val) }
  73. },
  74. mainTabs: {
  75. get () { return this.$store.state.common.mainTabs },
  76. set (val) { this.$store.commit('common/updateMainTabs', val) }
  77. },
  78. userName: {
  79. get () { return this.$store.state.user.name }
  80. }
  81. },
  82. methods: {
  83. // 修改密码
  84. updatePasswordHandle () {
  85. this.updatePasswordVisible = true
  86. this.$nextTick(() => {
  87. this.$refs.updatePassowrd.init()
  88. })
  89. },
  90. // 退出
  91. logoutHandle () {
  92. this.$confirm(`确定进行[退出]操作?`, '提示', {
  93. confirmButtonText: '确定',
  94. cancelButtonText: '取消',
  95. type: 'warning'
  96. }).then(() => {
  97. clearLoginInfo()
  98. this.$router.push({ name: 'login' })
  99. // this.$http({
  100. // url: this.$http.adornUrl('/sys/logout'),
  101. // method: 'post',
  102. // data: this.$http.adornData()
  103. // }).then(({data}) => {
  104. // if (data && data.code === 0) {
  105. // clearLoginInfo()
  106. // this.$router.push({ name: 'login' })
  107. // }
  108. // })
  109. }).catch(() => {})
  110. }
  111. }
  112. }
  113. </script>