main-navbar.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <nav class="aui-navbar" :class="`aui-navbar--${$store.state.navbarLayoutType}`">
  3. <div class="aui-navbar__hd">
  4. <h1 class="aui-navbar__brand" @click="$router.push({ name: 'home' })">
  5. <a class="aui-navbar__brand-lg" href="javascript:;"><img src="" /></a>
  6. </h1>
  7. </div>
  8. <div class="aui-navbar__bd">
  9. <navbar-menu></navbar-menu>
  10. <navbar-news></navbar-news>
  11. <navbar-user></navbar-user>
  12. </div>
  13. </nav>
  14. </template>
  15. <script>
  16. import { messages } from '@/i18n'
  17. import screenfull from 'screenfull'
  18. import { clearLoginInfo } from '@/utils'
  19. import NavbarMenu from './main-navbar-menu'
  20. import NavbarNews from './main-navbar-news'
  21. import NavbarUser from './main-navbar-user'
  22. export default {
  23. inject: ['refresh'],
  24. data () {
  25. return {
  26. i18nMessages: messages,
  27. updatePassowrdVisible: false
  28. }
  29. },
  30. components: {
  31. NavbarMenu,
  32. NavbarNews,
  33. NavbarUser
  34. },
  35. methods: {
  36. // 全屏
  37. fullscreenHandle () {
  38. if (!screenfull.enabled) {
  39. return this.$message({
  40. message: this.$t('fullscreen.prompt'),
  41. type: 'warning',
  42. duration: 500
  43. })
  44. }
  45. screenfull.toggle()
  46. },
  47. // 修改密码
  48. updatePasswordHandle () {
  49. this.updatePassowrdVisible = true
  50. this.$nextTick(() => {
  51. this.$refs.updatePassowrd.init()
  52. })
  53. },
  54. // 退出
  55. logoutHandle () {
  56. this.$confirm(this.$t('prompt.info', { 'handle': this.$t('logout') }), this.$t('prompt.title'), {
  57. confirmButtonText: this.$t('confirm'),
  58. cancelButtonText: this.$t('cancel'),
  59. type: 'warning'
  60. }).then(() => {
  61. this.$http.post('/logout').then(({ data: res }) => {
  62. if (res.code !== 0) {
  63. return this.$message.error(res.msg)
  64. }
  65. clearLoginInfo()
  66. this.$router.push({ name: 'login' })
  67. }).catch(() => {})
  68. }).catch(() => {})
  69. }
  70. }
  71. }
  72. </script>