index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="vab-nav">
  3. <div class="left-panel">
  4. <vab-fold fold="contract-left-line" unfold="contract-right-line" />
  5. <el-tabs
  6. v-if="layout === 'comprehensive'"
  7. v-model="tab.data"
  8. class="comprehensive-tabs"
  9. tab-position="top"
  10. @tab-click="handleTabClick"
  11. >
  12. <template v-for="item in routes" :key="item.name">
  13. <el-tab-pane :name="item.name">
  14. <template #label>
  15. <vab-icon v-if="item.meta.icon" :icon="item.meta.icon" :is-custom-svg="item.meta.isCustomSvg" />
  16. {{ translate(item.meta.title) }}
  17. </template>
  18. </el-tab-pane>
  19. </template>
  20. </el-tabs>
  21. <vab-breadcrumb v-else class="hidden-xs-only hidden-md-and-down" />
  22. </div>
  23. <div class="right-panel">
  24. <vab-right-tools />
  25. </div>
  26. </div>
  27. </template>
  28. <script lang="ts" setup>
  29. import { openFirstMenu } from '/@/config'
  30. import { translate } from '/@/i18n'
  31. import { useRoutesStore } from '/@/store/modules/routes'
  32. import { isExternal } from '/@/utils/validate'
  33. defineOptions({
  34. name: 'VabNav',
  35. })
  36. defineProps({
  37. layout: {
  38. type: String,
  39. default: '',
  40. },
  41. })
  42. const router = useRouter()
  43. const routesStore = useRoutesStore()
  44. const { getTab: tab, getTabMenu: tabMenu, getRoutes: routes } = storeToRefs(routesStore)
  45. const handleTabClick = () => {
  46. nextTick(() => {
  47. if (isExternal(tabMenu.value.path)) {
  48. window.open(tabMenu.value.path)
  49. router.push('/redirect')
  50. } else if (openFirstMenu) router.push(tabMenu.value.redirect || tabMenu.value)
  51. })
  52. }
  53. </script>
  54. <style lang="scss">
  55. .vab-layout-comprehensive {
  56. .comprehensive-tabs {
  57. width: calc(100vw - var(--el-left-menu-width) - 675px) !important;
  58. }
  59. }
  60. </style>
  61. <style lang="scss" scoped>
  62. .vab-nav {
  63. position: relative;
  64. display: flex;
  65. justify-content: space-between;
  66. height: var(--el-nav-height);
  67. padding-right: var(--el-padding);
  68. padding-left: var(--el-padding);
  69. overflow: hidden;
  70. user-select: none;
  71. background: var(--el-color-white);
  72. border-bottom: 1px solid var(--el-border-color);
  73. .left-panel {
  74. display: flex;
  75. align-items: center;
  76. justify-items: center;
  77. height: var(--el-nav-height);
  78. :deep() {
  79. .fold-unfold {
  80. margin-right: var(--el-margin);
  81. }
  82. .el-tabs {
  83. width: 100%;
  84. margin-left: 0;
  85. .el-tabs__header {
  86. margin: 0;
  87. > .el-tabs__nav-wrap {
  88. display: flex;
  89. align-items: center;
  90. .el-icon-arrow-left,
  91. .el-icon-arrow-right {
  92. font-weight: 600;
  93. color: var(--el-color-grey);
  94. }
  95. }
  96. }
  97. .el-tabs__item {
  98. > div {
  99. display: flex;
  100. align-items: center;
  101. i {
  102. margin-right: 3px;
  103. }
  104. }
  105. }
  106. }
  107. .el-tabs__nav-wrap::after {
  108. display: none;
  109. }
  110. }
  111. }
  112. .right-panel {
  113. display: flex;
  114. align-content: center;
  115. align-items: center;
  116. justify-content: flex-end;
  117. height: var(--el-nav-height);
  118. transition: var(--el-transition);
  119. :deep() {
  120. [class*='ri-'] {
  121. margin-left: var(--el-margin);
  122. color: var(--el-color-grey);
  123. cursor: pointer;
  124. }
  125. button {
  126. [class*='ri-'] {
  127. margin-left: 0;
  128. color: var(--el-color-white);
  129. cursor: pointer;
  130. }
  131. }
  132. }
  133. }
  134. @media (max-width: 480px) {
  135. .right-panel {
  136. :deep() {
  137. .el-badge,
  138. .ri-refresh-line {
  139. display: none;
  140. }
  141. }
  142. }
  143. }
  144. }
  145. </style>