HomeTitle.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <SubTitle
  3. :title="title"
  4. :moreText="moreText"
  5. :showMore="showMore"
  6. :padding="[showTopMargin ? 25 : 5, 0, 5, 0]"
  7. @moreClicked="emit('moreClicked')"
  8. >
  9. <template #icon>
  10. <FlexRow align="center">
  11. <Image :src="icon" :width="66" :height="42" mode="widthFix" />
  12. <Width :width="15" />
  13. </FlexRow>
  14. </template>
  15. <template #title>
  16. <FlexRow align="center">
  17. <Text :text="titleBegin2" fontConfig="primaryTitle" color="#55989a" />
  18. <Text v-if="titleEnd" :text="titleEnd" fontConfig="primaryTitle" color="#5f3f2c" />
  19. </FlexRow>
  20. </template>
  21. <template #right>
  22. <slot name="right" />
  23. </template>
  24. </SubTitle>
  25. </template>
  26. <script setup lang="ts">
  27. import Image from '@/components/basic/Image.vue';
  28. import Text from '@/components/basic/Text.vue';
  29. import SubTitle from '@/components/display/title/SubTitle.vue';
  30. import FlexRow from '@/components/layout/FlexRow.vue';
  31. import Width from '@/components/layout/space/Width.vue';
  32. import { computed } from 'vue';
  33. const props = defineProps({
  34. title: {
  35. type: String,
  36. default: '',
  37. },
  38. icon: {
  39. type: String,
  40. default: 'https://xy.wenlvti.net/app_static/images/home/HomeTitleIcon.png',
  41. },
  42. showMore: {
  43. type: Boolean,
  44. default: false,
  45. },
  46. showTopMargin: {
  47. type: Boolean,
  48. default: true,
  49. },
  50. moreText: {
  51. type: String,
  52. default: '更多',
  53. },
  54. lightCount: {
  55. type: Number,
  56. default: 2,
  57. },
  58. });
  59. const emit = defineEmits(['moreClicked'])
  60. const titleBegin2 = computed(() => {
  61. if (props.title.length > props.lightCount) {
  62. return props.title.slice(0, props.lightCount);
  63. }
  64. return props.title;
  65. });
  66. const titleEnd = computed(() => {
  67. if (props.title.length > props.lightCount) {
  68. return props.title.slice(props.lightCount);
  69. }
  70. return '';
  71. });
  72. </script>