DividerPreview.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div v-if="'wavy' === data.property.line_type" class="wavy" :style="settingWavyStyle"></div>
  3. <hr v-else :style="settingStyle" />
  4. </template>
  5. <script>
  6. import { getDividerData } from '@/views/book/courseware/data/divider';
  7. import PreviewMixin from '../common/PreviewMixin';
  8. import { getRandomNumber } from '@/utils';
  9. export default {
  10. name: 'DividerPreview',
  11. mixins: [PreviewMixin],
  12. data() {
  13. return {
  14. data: getDividerData(),
  15. };
  16. },
  17. computed: {
  18. settingStyle() {
  19. return {
  20. margin: `${this.data.property.height / 2}px auto`,
  21. border: 'none',
  22. borderTop: `1px ${this.data.property.line_type} ${this.data.property.color}`,
  23. width: `${this.data.property.line_type === 'none' ? 'auto' : `${this.data.property.width}px`}`,
  24. };
  25. },
  26. settingWavyStyle() {
  27. return {
  28. margin: `${this.data.property.height / 2}px auto`,
  29. width: `${this.data.property.width}px`,
  30. color: `${this.data.property.color}`,
  31. letterSpacing: `${this.data.property.width}px`,
  32. };
  33. },
  34. },
  35. methods: {
  36. /**
  37. * 获取无文本内容的数据结构,用于保存为个人模板时的样式模板
  38. */
  39. getNoTextContentData() {
  40. let noTextContentData = JSON.parse(JSON.stringify(this.data));
  41. const resetFieldMap = {
  42. analysis_list: [],
  43. answer_list: [],
  44. };
  45. Object.assign(noTextContentData, resetFieldMap);
  46. if (noTextContentData.answer) {
  47. noTextContentData.answer.answer_list = [];
  48. noTextContentData.answer.reference_answer = '';
  49. }
  50. return noTextContentData;
  51. },
  52. },
  53. };
  54. </script>
  55. <style lang="scss" scoped>
  56. hr {
  57. border: none;
  58. border-top-color: #ebebeb;
  59. border-top-width: 1px;
  60. }
  61. .wavy {
  62. display: block;
  63. height: 11px !important;
  64. padding-top: 0.5em;
  65. overflow: hidden;
  66. white-space: nowrap;
  67. }
  68. .wavy::before {
  69. /* IE浏览器实线代替 */
  70. text-decoration: overline;
  71. /* 现代浏览器 */
  72. text-decoration: overline wavy;
  73. content: '\2000';
  74. }
  75. </style>