editordiy.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div class="pcPages" :style="warpCss">
  3. <div :style="boxCss">
  4. <div class="pcPages-html" v-html="componentData.detail"></div>
  5. </div>
  6. </div>
  7. </template>
  8. <script setup lang="ts">
  9. interface Props {
  10. row?: any;
  11. }
  12. const props = defineProps<Props>();
  13. const componentData = props.row || {};
  14. const warpCss = computed(() => {
  15. let style = '';
  16. style += 'position:relative;';
  17. //背景颜色
  18. if (componentData.pageStartBgColor) {
  19. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  20. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  21. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  22. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  23. }
  24. //背景图片
  25. if (componentData.componentBgUrl) {
  26. style += `background-image:url('${componentData.componentBgUrl}');`;
  27. style += 'background-size: cover;background-repeat: no-repeat;';
  28. }
  29. //边距
  30. if (componentData.padding) {
  31. if (componentData.padding.top > 0) {
  32. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  33. }
  34. if (componentData.padding.bottom > 0) {
  35. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  36. }
  37. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  38. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  39. }
  40. //圆角
  41. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  42. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  43. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  44. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  45. //间距
  46. if (componentData.margin) {
  47. if (componentData.margin.top > 0) {
  48. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  49. }
  50. if (componentData.margin.bottom > 0) {
  51. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  52. }
  53. }
  54. return style;
  55. });
  56. //组件样式
  57. const boxCss = computed(() => {
  58. let style = '';
  59. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  60. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  61. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  62. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  63. if (componentData.number) style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * 10}px) / ${componentData.number})` + ';';
  64. return style;
  65. });
  66. </script>
  67. <style lang="scss" scoped>
  68. .pcPages {
  69. width: 1200px;
  70. margin: 0 auto;
  71. .pcPages-html {
  72. :deep(img) {
  73. max-width: 100%;
  74. display: inline-block;
  75. }
  76. }
  77. }
  78. </style>