index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="parent" @click="layoutClick">
  3. <NavBar class="headers"></NavBar>
  4. <div class="content">
  5. <router-view :key="router.currentRoute.value.path + Math.random()"></router-view>
  6. <!-- <router-view v-slot="{ Component }">
  7. <keep-alive>
  8. <component :is="Component" :key="router.currentRoute.value.path" v-if="router.currentRoute.value.meta?.keepAlive"/>
  9. </keep-alive>
  10. <component :is="Component" :key="router.currentRoute.value.path" v-if="!router.currentRoute.value.meta?.keepAlive"/>
  11. </router-view> -->
  12. </div>
  13. <Footers v-if="footerWhiteList.indexOf(router.currentRoute.value.path) === -1" :class="{'mt-10': !router.currentRoute.value.path.includes('/mall')}"></Footers>
  14. <Slider v-if="whiteList.indexOf(router.currentRoute.value.path) === -1" class="slider"></Slider>
  15. </div>
  16. </template>
  17. <script setup>
  18. defineOptions({ name: 'personal-layout-index' })
  19. import { onMounted, watch } from 'vue'
  20. import NavBar from './personal/navBar.vue'
  21. import Footers from './personal/footer.vue'
  22. import Slider from './personal/slider.vue'
  23. import { useSharedState } from '@/store/sharedState'
  24. import { useRouter, useRoute } from 'vue-router'
  25. import { useMallStore } from '@/store/mall'
  26. import { useUserStore } from '@/store/user'
  27. // 不展示侧边栏名单
  28. const whiteList = ['/login', '/privacyPolicy', '/userAgreement', '/register', '/recruit/personal/advertisement/introduce']
  29. // 不展示页脚白名单
  30. const footerWhiteList = [
  31. '/recruit/personal/message',
  32. '/recruit/personal/advertisement/introduce',
  33. '/about',
  34. '/headhunting',
  35. '/headhunting/service',
  36. '/headhunting/service/details',
  37. '/recruit/personal/resume/analysis',
  38. '/mall/pointExchange/records'
  39. ]
  40. const route = useRoute()
  41. const router = useRouter()
  42. const user = useUserStore()
  43. const sharedState = useSharedState()
  44. const layoutClick = () => {
  45. sharedState.increment()
  46. }
  47. onMounted(async () => {
  48. await useMallStore().getMallDiyTemplate()
  49. })
  50. watch(
  51. () => route.matched,
  52. async () => {
  53. await user.getUserAccountInfo()
  54. },
  55. { immediate: true },
  56. { deep: true }
  57. )
  58. </script>
  59. <style lang="scss" scoped>
  60. .parent {
  61. background-color: var(--default-bgc);
  62. position: relative;
  63. }
  64. .headers {
  65. position: fixed;
  66. right: 0;
  67. left: 0;
  68. top: 0;
  69. z-index: 999;
  70. }
  71. .slider {
  72. position: fixed;
  73. bottom: 50%;
  74. right: 24px;
  75. translate: 0 50%;
  76. z-index: 999;
  77. }
  78. .content {
  79. min-height: calc(100vh - (48px + 225px));
  80. margin-top: 50px;
  81. }
  82. </style>