partition.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="partition-block" :class="`partition-block_${type}`">
  4. <slot name="icon">
  5. <div class="partition-block__icon" :class="`partition-block__icon_${type}`" :style="{ backgroundImage: iconUrl ? `url(${icon})` : '' }"> </div>
  6. </slot>
  7. <slot name="label">
  8. <div class="partition-block__label" :class="`partition-block__label_${type}`">
  9. {{ label }}
  10. </div>
  11. </slot>
  12. </div>
  13. </template>
  14. <script lang="ts" setup>
  15. import { computed, defineEmits, defineProps, withDefaults } from 'vue';
  16. const props = withDefaults(
  17. defineProps<{
  18. // 分隔条类型,类型为:'A' | 'B'
  19. type?: string;
  20. // 分隔条内容
  21. label: string;
  22. // 分隔条图标
  23. icon: string;
  24. }>(),
  25. {
  26. type: 'A',
  27. label: '分隔条',
  28. icon: '',
  29. }
  30. );
  31. // 处理 icon 路径,兼容静态资源
  32. const iconUrl = computed(() => {
  33. if (!props.icon) return '';
  34. if (props.icon.startsWith('/')) {
  35. return props.icon;
  36. }
  37. return '/' + props.icon;
  38. });
  39. defineEmits(['click']);
  40. </script>
  41. <style lang="less" scoped>
  42. @import '/@/design/theme.less';
  43. @import '/@/design/theme.less';
  44. @{theme-green} {
  45. .partition-block {
  46. --image-partition-bg: url('/@/assets/images/themify/green/home-container/configurable/partition-bg-a.png');
  47. }
  48. }
  49. @{theme-deepblue} {
  50. .partition-block {
  51. --image-partition-bg: url('/@/assets/images/home-container/configurable/tashanhome/partition-bg-a.png');
  52. }
  53. }
  54. .partition-block {
  55. --image-partition-bg: url('/@/assets/images/home-container/configurable/tashanhome/partition-bg-a.png');
  56. display: flex;
  57. background: var(--image-partition-bg);
  58. background-size: 100% 100%;
  59. position: relative;
  60. .partition-block__icon {
  61. width: 14px;
  62. height: 14px;
  63. background-size: 100% 100%;
  64. background-repeat: no-repeat;
  65. margin: 3px 5px;
  66. }
  67. }
  68. .partition-block_A {
  69. height: 30px !important;
  70. width: calc(100% - 30px) !important;
  71. margin: 5px 0 10px 20px;
  72. }
  73. </style>