App.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <van-nav-bar
  3. v-if="route.meta.navbar"
  4. :left-arrow="route.meta.leftArrow"
  5. @click-left="goBack()"
  6. :title="$t(route.meta.title)"
  7. class="app-bar-header"
  8. :style="notchStyle"
  9. />
  10. <RouterView :style="mainStyle" />
  11. </template>
  12. <script setup>
  13. import { appStart } from "@/hooks/updataApp";
  14. import { getNotchHeight } from "@/utils/statusBar";
  15. const route = useRoute();
  16. const router = useRouter();
  17. const notchStyle = ref({});
  18. const mainStyle = ref({});
  19. const goBack = () => {
  20. if (route.meta.navbar) {
  21. router.back();
  22. }
  23. };
  24. onBeforeMount(async () => {
  25. const height = await getNotchHeight();
  26. notchStyle.value = {
  27. paddingTop: `${height}px`,
  28. };
  29. if (route.meta.navbar) {
  30. mainStyle.value.marginTop = `0 px`;
  31. } else {
  32. mainStyle.value = {
  33. marginTop: `${height}px`,
  34. };
  35. }
  36. appStart()
  37. });
  38. </script>
  39. <style lang="less">
  40. body {
  41. margin: 0;
  42. overflow: hidden;
  43. height: 100%;
  44. background-color: @bg-color2;
  45. }
  46. </style>
  47. <style scoped lang="less">
  48. .app-bar-header {
  49. :deep(.van-nav-bar__title){
  50. font-weight: 500;
  51. }
  52. :deep(.van-icon){
  53. color: @font-color3;
  54. }
  55. }
  56. </style>