navbar-evo.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <script lang="ts" setup>
  2. import { ConfigProviderThemeVars } from 'wot-design-uni'
  3. import {
  4. type CSSProperties,
  5. computed,
  6. getCurrentInstance,
  7. nextTick,
  8. onMounted,
  9. ref,
  10. watch,
  11. } from 'vue'
  12. const props = withDefaults(
  13. defineProps<{
  14. transparent?: boolean
  15. title?: string
  16. dark?: boolean
  17. placeholder?: boolean
  18. isShowBack?: boolean
  19. }>(),
  20. { isShowBack: true },
  21. )
  22. const slots = defineSlots<{
  23. prepend(): any
  24. }>()
  25. const aa = computed(() => (slots.prepend ? 'left' : 'capsule'))
  26. const pages = computed(() => getCurrentPages())
  27. const themeVars = computed<ConfigProviderThemeVars>(() => ({
  28. navbarColor: props.dark ? 'white' : 'black',
  29. // buttonIconSize: '100rpx',
  30. }))
  31. const handleToHome = () => {
  32. uni.reLaunch({ url: '/pages/home/index' })
  33. }
  34. const handleBack = () => {
  35. uni.navigateBack()
  36. }
  37. onMounted(() => {})
  38. </script>
  39. <template>
  40. <div>
  41. <wd-config-provider :themeVars="themeVars">
  42. <wd-navbar
  43. fixed
  44. left-arrow
  45. safe-area-inset-top
  46. :bordered="false"
  47. :custom-class="`${transparent ? 'bg-transparent!' : ''} `"
  48. v-bind="{ title }"
  49. >
  50. <template v-slot:[aa]>
  51. <div class="flex items-center gap-4.5 w-full h-full">
  52. <div class="flex items-center justify-center overflow-hidden" v-if="isShowBack">
  53. <wd-icon
  54. v-if="pages.length === 1"
  55. name="home"
  56. size="50rpx"
  57. :color="dark ? 'white' : 'blacak'"
  58. @click="handleToHome"
  59. ></wd-icon>
  60. <wd-icon
  61. v-else
  62. name="arrow-left"
  63. size="48rpx"
  64. :color="dark ? 'white' : 'blacak'"
  65. @click="handleBack"
  66. ></wd-icon>
  67. </div>
  68. <slot name="prepend"></slot>
  69. </div>
  70. </template>
  71. </wd-navbar>
  72. <template v-if="props.placeholder">
  73. <wd-navbar
  74. safe-area-inset-top
  75. :bordered="false"
  76. :custom-class="`${transparent ? 'bg-transparent!' : ''} `"
  77. ></wd-navbar>
  78. </template>
  79. </wd-config-provider>
  80. </div>
  81. </template>