Infotip.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <script setup lang="ts">
  2. import { PropType } from 'vue'
  3. import { Highlight } from '@/components/Highlight'
  4. import { useDesign } from '@/hooks/web/useDesign'
  5. import { propTypes } from '@/utils/propTypes'
  6. import { TipSchema } from '@/types/infoTip'
  7. const { getPrefixCls } = useDesign()
  8. const prefixCls = getPrefixCls('infotip')
  9. defineProps({
  10. title: propTypes.string.def(''),
  11. schema: {
  12. type: Array as PropType<Array<string | TipSchema>>,
  13. required: true,
  14. default: () => []
  15. },
  16. showIndex: propTypes.bool.def(true),
  17. highlightColor: propTypes.string.def('var(--el-color-primary)')
  18. })
  19. const emit = defineEmits(['click'])
  20. const keyClick = (key: string) => {
  21. emit('click', key)
  22. }
  23. </script>
  24. <template>
  25. <div
  26. :class="[
  27. prefixCls,
  28. 'p-20px mb-20px border-1px border-solid border-[var(--el-color-primary)] bg-[var(--el-color-primary-light-9)]'
  29. ]"
  30. >
  31. <div v-if="title" :class="[`${prefixCls}__header`, 'flex items-center']">
  32. <Icon icon="bi:exclamation-circle-fill" :size="22" color="var(--el-color-primary)" />
  33. <span :class="[`${prefixCls}__title`, 'pl-5px text-16px font-bold']">{{ title }}</span>
  34. </div>
  35. <div :class="`${prefixCls}__content`">
  36. <p v-for="(item, $index) in schema" :key="$index" class="text-14px mt-15px">
  37. <Highlight
  38. :keys="typeof item === 'string' ? [] : item.keys"
  39. :color="highlightColor"
  40. @click="keyClick"
  41. >
  42. {{ showIndex ? `${$index + 1}、` : '' }}{{ typeof item === 'string' ? item : item.label }}
  43. </Highlight>
  44. </p>
  45. </div>
  46. </div>
  47. </template>