navbar-evo.vue 2.1 KB

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