index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="app-header">
  3. <div class="app-header__left">
  4. <slot name="left"></slot>
  5. <el-breadcrumb :separator-icon="ArrowRight" v-show="!globalStore.isMobile">
  6. <template v-for="(item, index) in $route.matched" :key="index">
  7. <el-breadcrumb-item>
  8. <!--<i :class="item.meta.icon" v-if="item.meta.icon"></i>-->
  9. <span>{{ item.meta.title ?? 'item.name' }}</span>
  10. </el-breadcrumb-item>
  11. </template>
  12. </el-breadcrumb>
  13. </div>
  14. <div class="app-header__right">
  15. <slot name="right"></slot>
  16. <div class="iconbar">
  17. <el-badge type="danger" is-dot>
  18. <span class="g-icon--notice"></span>
  19. </el-badge>
  20. <span class="g-icon--minimize" @click="exitFullSreen" v-if="fullScreen"></span>
  21. <span class="g-icon--maximize" @click="setFullSreen" v-else></span>
  22. </div>
  23. <el-dropdown class="user-dropdown" trigger="click">
  24. <span class="g-icon--language"></span>
  25. <template #dropdown>
  26. <el-dropdown-menu>
  27. <template v-for="item in getLanguageList()" :key="item.value">
  28. <el-dropdown-item @click="switchLanguage(item.value)">{{ item.label }}</el-dropdown-item>
  29. </template>
  30. </el-dropdown-menu>
  31. </template>
  32. </el-dropdown>
  33. <el-dropdown class="user-dropdown" trigger="click">
  34. <span class="user-dropdown__link">
  35. <span>{{ userStore.userInfo.username }}</span>
  36. <span>({{ userStore.userInfo.logincode }})</span>
  37. <el-icon class="el-icon--right">
  38. <arrow-down />
  39. </el-icon>
  40. </span>
  41. <template #dropdown>
  42. <el-dropdown-menu>
  43. <el-dropdown-item :icon="Key">{{ t('operation.modifypwd') }}</el-dropdown-item>
  44. <el-dropdown-item :icon="SwitchButton" @click="eventBus.$emit('Logout')">{{ t('operation.loginout') }}</el-dropdown-item>
  45. </el-dropdown-menu>
  46. </template>
  47. </el-dropdown>
  48. </div>
  49. </div>
  50. </template>
  51. <script lang="ts" setup>
  52. import { ref, onMounted } from 'vue'
  53. import { ArrowRight, Key, SwitchButton, ArrowDown } from '@element-plus/icons-vue'
  54. import { getLanguageList, Language } from '@/constants/language'
  55. import { useGlobalStore, useUserStore, i18n } from '@/stores'
  56. import { localData } from '@/stores/storage'
  57. import eventBus from '@/services/bus'
  58. const globalStore = useGlobalStore()
  59. const userStore = useUserStore()
  60. const fullScreen = ref(false)
  61. const { global: { t } } = i18n
  62. // 全屏
  63. const setFullSreen = () => {
  64. document.documentElement.requestFullscreen();
  65. }
  66. // 退出全屏
  67. const exitFullSreen = () => {
  68. document.exitFullscreen();
  69. }
  70. // 切换语言
  71. const switchLanguage = (lange: Language) => {
  72. i18n.global.locale = lange
  73. localData.setValue('appLanguage', lange)
  74. }
  75. onMounted(() => {
  76. // 监听全屏变化
  77. window.addEventListener('fullscreenchange', () => {
  78. if (document.fullscreenElement) {
  79. fullScreen.value = true;
  80. } else {
  81. fullScreen.value = false;
  82. }
  83. })
  84. })
  85. </script>
  86. <style lang="less" scoped>
  87. @import './index.less';
  88. </style>