1
0

index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div
  3. @click="(e) => $emit('click', e)"
  4. class="border-panel"
  5. :style="borderPanelStyle"
  6. >
  7. <div
  8. class="border-panel_header"
  9. :style="{
  10. backgroundImage: `url(${headerImageBgUrl})`,
  11. cursor: headerCursor
  12. }"
  13. >
  14. <linear-text
  15. :text="title"
  16. startColor="#95CCFF"
  17. endColor="#fff" @click="(e) => $emit('click-header', e)"
  18. :extClass="{
  19. top: '11px',
  20. left: '35px',
  21. textShadow: '0 1px 1px #0057FF',
  22. }"
  23. />
  24. <div class="ext-header"><slot name="ext-header"></slot></div>
  25. </div>
  26. <div class="border-panel_content">
  27. <slot></slot>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { headerTitleBgs } from "./data";
  33. import LinearText from "../LinearText";
  34. /**
  35. * 边框面板
  36. */
  37. export default {
  38. name: "BorderPanel",
  39. components: {
  40. LinearText,
  41. },
  42. props: {
  43. title: {
  44. type: String,
  45. default: "标题",
  46. },
  47. width: {
  48. type: String,
  49. default: "443px",
  50. },
  51. height: {
  52. type: String,
  53. default: "200px",
  54. },
  55. headerType: {
  56. type: Number,
  57. default: 0,
  58. },
  59. headerCursor: {
  60. type: String,
  61. default: 'default'
  62. }
  63. },
  64. computed: {
  65. borderPanelStyle: function () {
  66. return {
  67. "--height": this.$props.height,
  68. "--width": this.$props.width,
  69. "--header-ops": ["-4px", "0px", "0px"][this.$props.headerType],
  70. };
  71. },
  72. headerImageBgUrl: function () {
  73. console.log(this.headerType);
  74. return headerTitleBgs[this.$props.headerType];
  75. },
  76. },
  77. };
  78. </script>
  79. <style scoped lang="less">
  80. .border-panel {
  81. position: relative;
  82. height: var(--height);
  83. width: var(--width);
  84. box-sizing: border-box;
  85. overflow: hidden;
  86. background: linear-gradient(
  87. 360deg,
  88. rgba(0, 133, 255, 0.25) 0%,
  89. rgba(0, 163, 255, 0) 100%
  90. );
  91. }
  92. .border-panel_header {
  93. height: 50px;
  94. width: var(--width);
  95. background-image: url("../assets/border-panel_header_1.svg");
  96. background-repeat: no-repeat;
  97. background-position: var(--header-ops) 0px;
  98. display: flex;
  99. justify-content: space-between;
  100. .ext-header {
  101. margin-right: 15px;
  102. margin-top: 12px;
  103. }
  104. }
  105. .border-panel::after {
  106. content: "";
  107. position: absolute;
  108. top: 0px;
  109. left: 0px;
  110. padding: 1px;
  111. box-sizing: border-box;
  112. width: var(--width);
  113. height: var(--height);
  114. background: linear-gradient(360deg, #0c5a87 0%, rgba(0, 163, 255, 0) 100%);
  115. /* 随便定义颜色 */
  116. --mask-bg: linear-gradient(red, red);
  117. --m-o: content-box, padding-box;
  118. /* mask允许使用者通过遮罩或者裁切特定区域的图片的方式来隐藏一个元素的部分或者全部可见区域 */
  119. /* 设置了用作元素蒙版层的图像,默认值为none,值为透明图片,或透明渐变 */
  120. -webkit-mask-image: var(--mask-bg), var(--mask-bg);
  121. /* 默认值为border-box,可选值与background-origin相同 */
  122. -webkit-mask-origin: var(--m-o);
  123. /* 默认值为border-box,可选值与background-clip相同 */
  124. -webkit-mask-clip: var(--m-o);
  125. /* exclude排除,只显示不重合的地方,Firefox支持4个属性 */
  126. mask-composite: exclude;
  127. /*只显示下方遮罩,重合的地方不显示*/
  128. -webkit-mask-composite: destination-out;
  129. pointer-events: none;
  130. }
  131. .border-panel_content {
  132. padding: 0px 1px 0px 1px;
  133. }
  134. </style>