App.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 />
  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 goBack = () => {
  19. if (route.meta.navbar) {
  20. if (route.meta.to) {
  21. router.push({
  22. path: route.meta.to,
  23. });
  24. return
  25. }
  26. router.back();
  27. }
  28. };
  29. onBeforeMount(async () => {
  30. const getLoadingNode = document.getElementById('Loading')
  31. const { body } = document
  32. if (getLoadingNode) {
  33. body.removeChild(getLoadingNode)
  34. }
  35. const height = await getNotchHeight();
  36. notchStyle.value = {
  37. paddingTop: `${height}px`,
  38. };
  39. // appStart()
  40. });
  41. </script>
  42. <style lang="less">
  43. body {
  44. margin: 0;
  45. overflow: hidden;
  46. height: 100%;
  47. background-color: @bg-color2;
  48. }
  49. </style>
  50. <style scoped lang="less">
  51. .app-bar-header {
  52. :deep(.van-nav-bar__title){
  53. font-weight: 500;
  54. }
  55. :deep(.van-icon){
  56. color: @font-color3;
  57. }
  58. }
  59. </style>