index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <Navbar class="mb-3" />
  3. <div class="d-flex parent default-width mb-5">
  4. <v-card class="left">
  5. <v-list color="primary">
  6. <div class="text-center my-3">
  7. <v-avatar :image="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" size="100"></v-avatar>
  8. <p class="mt-2 color-primary font-weight-bold">{{ baseInfo?.name }}</p>
  9. </div>
  10. <v-divider></v-divider>
  11. <template v-for="(item, index) in list">
  12. <template v-if="!item.children.length">
  13. <v-list-item
  14. :key="`${item.name}_${index}`"
  15. active-class="active"
  16. color="primary"
  17. :href="item.path"
  18. :to="item.path"
  19. :prepend-icon="item.icon"
  20. :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"
  21. >
  22. </v-list-item>
  23. </template>
  24. <v-list-group
  25. v-else
  26. color="primary"
  27. :key="`${item.path}_${item.title}`"
  28. :prepend-icon="item.icon"
  29. >
  30. <template v-slot:activator="{ props }">
  31. <v-list-item v-bind="props" :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"></v-list-item>
  32. </template>
  33. <v-list-item
  34. v-for="(val, i) in item.children"
  35. :key="i"
  36. color="primary"
  37. :href="val.path"
  38. style="padding-left: 40px;"
  39. :to="val.path"
  40. :title="getCurrentLocaleLang() === 'zh_CN' ? val.title : val.enName"
  41. ></v-list-item>
  42. </v-list-group>
  43. </template>
  44. </v-list>
  45. </v-card>
  46. <v-card class="ml-3 pa-3 page">
  47. <router-view></router-view>
  48. </v-card>
  49. </div>
  50. </template>
  51. <script setup>
  52. defineOptions({ name: 'mall-user-index'})
  53. import { computed, ref } from 'vue'
  54. import { getCurrentLocaleLang } from '@/utils/lang.js'
  55. import { useRoute } from 'vue-router'
  56. import { useUserStore } from '@/store/user'
  57. import { getUserAvatar } from '@/utils/avatar'
  58. import Navbar from '../components/navbar.vue'
  59. let baseInfo = ref(JSON.parse(localStorage.getItem('baseInfo')) || {}) // 人才信息
  60. useUserStore().$subscribe((mutation, state) => {
  61. if (Object.keys(state.baseInfo).length) baseInfo.value = state.baseInfo
  62. })
  63. const route = useRoute()
  64. const mallUserRoute = route.matched.find(item => item.path === '/mall/user')
  65. // 左侧菜单列表
  66. const list = computed(() => {
  67. return getList(mallUserRoute.children)
  68. })
  69. const getList = (arr, obj = []) => {
  70. arr.forEach(element => {
  71. if (element.show) return
  72. let data = {}
  73. data = {
  74. title: element?.meta?.title,
  75. enName: element?.meta?.enName,
  76. icon: element?.meta?.icon,
  77. name: element?.name,
  78. path: element?.path,
  79. children: []
  80. }
  81. if (element?.children) {
  82. getList(element.children, data.children)
  83. }
  84. obj.push(data)
  85. })
  86. return obj
  87. }
  88. </script>
  89. <style scoped lang="scss">
  90. .parent {
  91. height: calc(100vh - 190px);
  92. overflow-y: auto;
  93. }
  94. .page {
  95. flex: 1;
  96. width: 100%;
  97. overflow-y: auto;
  98. overflow-x: hidden;
  99. }
  100. .left {
  101. position: sticky;
  102. width: 220px;
  103. height: calc(100vh - 193px);
  104. overflow-y: auto;
  105. }
  106. .title {
  107. color: var(--color-333);
  108. font-weight: 600;
  109. font-size: 20px;
  110. }
  111. ::-webkit-scrollbar {
  112. width: 6px;
  113. height: 10px;
  114. }
  115. ::-webkit-scrollbar-thumb, .temporaryAdd ::-webkit-scrollbar-thumb, .details_edit ::-webkit-scrollbar-thumb {
  116. // 滚动条-颜色
  117. background: #c3c3c379;
  118. }
  119. ::-webkit-scrollbar-track, .temporaryAdd ::-webkit-scrollbar-track, .details_edit ::-webkit-scrollbar-track {
  120. // 滚动条-底色
  121. background: #e5e5e58f;
  122. }
  123. </style>