back.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <script lang="ts" setup>
  2. import { defaultThemeVars } from '../core/themes/default'
  3. import { ref } from 'vue'
  4. const slots = useSlots()
  5. const childRef = ref()
  6. const reference = ref()
  7. const menuBtnClientRect = ref<UniNamespace.GetMenuButtonBoundingClientRectRes>({
  8. width: 0,
  9. height: 0,
  10. top: 0,
  11. right: 0,
  12. bottom: 0,
  13. left: 0,
  14. })
  15. const startMenuBtnStyle = ref({
  16. width: '0px',
  17. height: '0px',
  18. left: '0px',
  19. top: '0px',
  20. })
  21. const navHeight = ref('0px')
  22. onMounted(async () => {
  23. menuBtnClientRect.value = await uni.getMenuButtonBoundingClientRect()
  24. const { windowWidth } = await uni.getWindowInfo()
  25. startMenuBtnStyle.value = {
  26. width: menuBtnClientRect.value.width + 'px',
  27. height: menuBtnClientRect.value.height + 'px',
  28. top: `${menuBtnClientRect.value.top}px`,
  29. left: `${windowWidth - menuBtnClientRect.value.right}px`,
  30. }
  31. navHeight.value = `${menuBtnClientRect.value.top + menuBtnClientRect.value.height + 8}px`
  32. console.log(menuBtnClientRect.value)
  33. })
  34. const handleBack = () => {
  35. uni.navigateBack()
  36. }
  37. </script>
  38. <template>
  39. <wd-config-provider
  40. class="flex-grow flex flex-col"
  41. custom-class="flex-grow"
  42. :themeVars="defaultThemeVars"
  43. >
  44. <view class="bg-[#f6f6f6] flex-grow flex flex-col">
  45. <div v-if="childRef?.navBarFixed ?? false" class="" :style="{ height: navHeight }"></div>
  46. <div
  47. class="fixed rounded-full flex items-center justify-start px-3 box-border z-1"
  48. :style="startMenuBtnStyle"
  49. >
  50. <wd-button
  51. type="icon"
  52. size="small"
  53. icon="thin-arrow-left"
  54. custom-class="ml--3 text-white!"
  55. @click="handleBack"
  56. ></wd-button>
  57. </div>
  58. <!-- {{ slots }} -->
  59. <!-- <div ref="childRef"> -->
  60. {{ reference?.title }}
  61. <div ref="reference">
  62. <slot></slot>
  63. </div>
  64. <!-- </div> -->
  65. </view>
  66. <wd-toast />
  67. <wd-message-box />
  68. </wd-config-provider>
  69. </template>