index.vue 3.8 KB

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