index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="pt-3 d-flex parent">
  3. <v-card class="left">
  4. <v-list color="primary">
  5. <v-list-subheader class="title mb-3">个人中心</v-list-subheader>
  6. <v-divider></v-divider>
  7. <template v-for="(item, index) in list">
  8. <template v-if="!item.children.length">
  9. <v-list-item
  10. :key="`${item.name}_${index}`"
  11. active-class="active"
  12. color="primary"
  13. :href="item.path"
  14. :to="item.path"
  15. :prepend-icon="item.icon"
  16. :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"
  17. >
  18. </v-list-item>
  19. </template>
  20. <v-list-group
  21. v-else
  22. color="primary"
  23. :key="`${item.path}_${item.title}`"
  24. :prepend-icon="item.icon"
  25. >
  26. <template v-slot:activator="{ props }">
  27. <v-list-item v-bind="props" :title="getCurrentLocaleLang() === 'zh_CN' ? item.title : item.enName"></v-list-item>
  28. </template>
  29. <v-list-item
  30. v-for="(val, i) in item.children"
  31. :key="i"
  32. color="primary"
  33. :href="val.path"
  34. style="padding-left: 40px;"
  35. :to="val.path"
  36. :title="getCurrentLocaleLang() === 'zh_CN' ? val.title : val.enName"
  37. ></v-list-item>
  38. </v-list-group>
  39. </template>
  40. </v-list>
  41. </v-card>
  42. <v-card class="ml-3 pa-3 page">
  43. <router-view></router-view>
  44. </v-card>
  45. </div>
  46. </template>
  47. <script setup>
  48. defineOptions({ name: 'person-center'})
  49. import { computed } from 'vue'
  50. import { getCurrentLocaleLang } from '@/utils/lang.js'
  51. import personCenterRoute from '@/router/modules/components/recruit/personCenter'
  52. import { useUserStore } from '@/store/user'
  53. // 左侧菜单列表
  54. const list = computed(() => {
  55. return getList(personCenterRoute[0].children[0].children)
  56. })
  57. console.log(import.meta.env.VITE_NODE_ENV, '当前环境变量===========')
  58. const getList = (arr, obj = []) => {
  59. arr.forEach(element => {
  60. if (element.show) return
  61. let data = {}
  62. data = {
  63. title: element?.meta?.title,
  64. enName: element?.meta?.enName,
  65. icon: element?.meta?.icon,
  66. name: element?.name,
  67. path: element?.path,
  68. children: []
  69. }
  70. if (element?.children) {
  71. getList(element.children, data.children)
  72. }
  73. obj.push(data)
  74. })
  75. // 生产环境暂时不展示收货地址
  76. if (import.meta.env.VITE_NODE_ENV === 'production') obj = obj.filter(e => e.path !== '/recruit/personal/personalCenter/shippingAddress')
  77. return obj
  78. }
  79. const userStore = useUserStore()
  80. // 更新账户信息
  81. const updateAccountInfo = async () => {
  82. await userStore.getUserAccountInfo()
  83. }
  84. updateAccountInfo()
  85. </script>
  86. <style scoped lang="scss">
  87. .parent {
  88. width: 1300px;
  89. max-width: 1300px;
  90. min-width: 1300px;
  91. margin: 0 auto;
  92. height: calc(100vh - 100px);
  93. overflow-y: auto;
  94. }
  95. .page {
  96. flex: 1;
  97. width: 100%;
  98. overflow-y: auto;
  99. overflow-x: hidden;
  100. }
  101. .left {
  102. position: sticky;
  103. width: 220px;
  104. height: calc(100vh - 113px);
  105. overflow-y: auto;
  106. }
  107. .title {
  108. color: var(--color-333);
  109. font-weight: 600;
  110. font-size: 20px;
  111. }
  112. ::-webkit-scrollbar {
  113. width: 6px;
  114. height: 10px;
  115. }
  116. ::-webkit-scrollbar-thumb, .temporaryAdd ::-webkit-scrollbar-thumb, .details_edit ::-webkit-scrollbar-thumb {
  117. // 滚动条-颜色
  118. background: #c3c3c379;
  119. }
  120. ::-webkit-scrollbar-track, .temporaryAdd ::-webkit-scrollbar-track, .details_edit ::-webkit-scrollbar-track {
  121. // 滚动条-底色
  122. background: #e5e5e58f;
  123. }
  124. </style>