App.vue 994 B

123456789101112131415161718192021222324252627282930313233343536
  1. <script setup>
  2. import TabBar from './components/TabBar.vue'
  3. import { useRoute } from 'vue-router'
  4. import { computed, onMounted } from 'vue'
  5. import { useStore } from 'vuex'
  6. const route = useRoute()
  7. const store = useStore()
  8. // 计算是否显示TabBar
  9. const showTabBar = computed(() => {
  10. // 在加载页面不显示TabBar
  11. const paths = ['/loading', '/', '/exhibition', '/collection', '/user', '/indexPage']
  12. return paths.includes(route.path)
  13. })
  14. // 从store获取isFrom值
  15. const isFrom = computed(() => store.getters.getIsFrom)
  16. // 组件挂载时从URL参数获取isFrom并存储到store
  17. onMounted(() => {
  18. const queryString = window.location.search
  19. const urlParams = new URLSearchParams(queryString)
  20. const isFromParam = urlParams.get('isFrom')
  21. store.dispatch('setIsFrom', isFromParam)
  22. })
  23. </script>
  24. <template>
  25. <RouterView :key="$route.fullPath" />
  26. <TabBar v-if="showTabBar && isFrom != 'weixin'" />
  27. </template>
  28. <style scoped>
  29. /* 全局样式可以在这里添加 */
  30. </style>