FrameButton.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <BackgroundImageButton
  3. :backgroundImage="image"
  4. :backgroundCutBorder="backgroundCutBorderSize"
  5. :backgroundCutBorderSize="backgroundCutBorderSize"
  6. :padding="padding"
  7. :width="width"
  8. :touchable="!loading && touchable"
  9. center
  10. gap="gap.md"
  11. @click="emit('click')"
  12. >
  13. <ActivityIndicator v-if="loading" :size="iconSize" :color="primary ? 'white' : 'text.content'" />
  14. <Icon v-if="icon" :icon="icon" :size="iconSize" :color="primary ? 'white' : 'text.content'" />
  15. <Text :text="text" :wrap="false" fontConfig="lightTitle" :fontSize="fontSize" :color="primary ? 'white' : 'text.content'" />
  16. </BackgroundImageButton>
  17. </template>
  18. <script setup lang="ts">
  19. import ActivityIndicator from '@/components/basic/ActivityIndicator.vue';
  20. import BackgroundImageButton from '@/components/basic/BackgroundImageButton.vue';
  21. import Icon from '@/components/basic/Icon.vue';
  22. import Text from '@/components/basic/Text.vue';
  23. import { computed } from 'vue';
  24. const props = withDefaults(defineProps<{
  25. text: string;
  26. primary?: boolean;
  27. size?: 'large' | 'midium' | 'small';
  28. width?: string|number;
  29. innerStyle?: object;
  30. loading?: boolean;
  31. touchable?: boolean;
  32. icon?: string;
  33. }>(), {
  34. text: '去发布',
  35. primary: false,
  36. touchable: true,
  37. size: 'large',
  38. });
  39. const padding = computed(() => {
  40. switch (props.size) {
  41. case 'large': return [20, 36];
  42. case 'midium': return [18, 20];
  43. case 'small': return [15, 18];
  44. }
  45. });
  46. const backgroundCutBorderSize = computed(() => {
  47. switch (props.size) {
  48. case 'large': return 32;
  49. case 'midium': return 28;
  50. case 'small': return 18;
  51. }
  52. });
  53. const fontSize = computed(() => {
  54. switch (props.size) {
  55. case 'large': return 36;
  56. case 'midium': return 28;
  57. case 'small': return 26;
  58. }
  59. });
  60. const iconSize = computed(() => {
  61. switch (props.size) {
  62. case 'large': return 32;
  63. case 'midium': return 26;
  64. case 'small': return 26;
  65. }
  66. });
  67. const image = computed(() => {
  68. if (props.size === 'large' || props.size === 'midium') {
  69. return props.primary ?
  70. 'https://xy.wenlvti.net/app_static/images/FrameButtonPrimary.png' :
  71. 'https://xy.wenlvti.net/app_static/images/FrameButton.png';
  72. } else {
  73. return props.primary ?
  74. 'https://xy.wenlvti.net/app_static/images/FrameButtonPrimarySmall.png' :
  75. 'https://xy.wenlvti.net/app_static/images/FrameButtonSmall.png';
  76. }
  77. });
  78. const emit = defineEmits(['click']);
  79. defineOptions({
  80. options: {
  81. virtualHost: true,
  82. },
  83. })
  84. </script>