SubTitle.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. import { useTheme, type ThemePaddingMargin, type ThemePaddingMarginProp } from '@/components/theme/ThemeDefine';
  3. import Icon from '@/components/basic/Icon.vue';
  4. import Text, { type TextProps } from '@/components/basic/Text.vue';
  5. import Touchable from '@/components/feedback/Touchable.vue';
  6. import FlexRow from '@/components/layout/FlexRow.vue';
  7. import Width from '@/components/layout/space/Width.vue';
  8. defineEmits([ 'moreClicked' ])
  9. const props = withDefaults(defineProps<{
  10. title?: string,
  11. moreText?: string,
  12. showMore?: boolean,
  13. badgeColor?: string,
  14. backgroundColor?: string,
  15. padding?: ThemePaddingMarginProp,
  16. titleProps?: TextProps,
  17. badgeStyle?: object,
  18. }>(), {
  19. title: '',
  20. moreText: '更多',
  21. showMore: false,
  22. badgeColor: 'primary',
  23. padding: () => [ 0, 0, 30, 0 ],
  24. })
  25. const theme = useTheme();
  26. const finalBadgeStyle = theme.useThemeStyle({
  27. width: '10rpx',
  28. height: '32rpx',
  29. borderRadius: '5rpx',
  30. marginRight: '14rpx',
  31. ...props.badgeStyle,
  32. })
  33. </script>
  34. <template>
  35. <FlexRow
  36. justify="space-between"
  37. align="center"
  38. :padding="padding"
  39. :backgroundColor="backgroundColor"
  40. >
  41. <FlexRow align="center">
  42. <slot name="icon">
  43. <view :style="{
  44. ...finalBadgeStyle,
  45. backgroundColor: theme.resolveThemeColor(badgeColor),
  46. }"></view>
  47. </slot>
  48. <slot name="titlePrefix" />
  49. <slot name="title">
  50. <Text fontConfig="h4" :text="title" v-bind="titleProps" />
  51. </slot>
  52. <slot name="titleSuffix" />
  53. </FlexRow>
  54. <FlexRow align="center">
  55. <slot name="right" />
  56. <Touchable v-if="showMore" align="center" touchable @click="$emit('moreClicked')">
  57. <Text fontConfig="subText" :text="moreText" />
  58. <Width :size="10" />
  59. <Icon icon="arrow-right" :size="26" />
  60. </Touchable>
  61. </FlexRow>
  62. </FlexRow>
  63. </template>