index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <sketch-rule
  3. :thick="thick"
  4. :scale="scale"
  5. :width="width"
  6. :height="height"
  7. :startX="startX"
  8. :startY="startY"
  9. :lines="lines"
  10. ></sketch-rule>
  11. </template>
  12. <script setup lang="ts">
  13. import { toRefs, computed } from 'vue'
  14. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  15. import { useDesignStore } from '@/store/modules/designStore/designStore'
  16. const chartEditStore = useChartEditStore()
  17. const designStore = useDesignStore()
  18. const { width, height } = toRefs(chartEditStore.getEditCanvasConfig)
  19. // 初始化标尺的缩放
  20. const scale = 1
  21. // x轴标尺开始的坐标数值
  22. const startX = 20
  23. // y轴标尺开始的坐标数值
  24. const startY = 20
  25. // 标尺的厚度
  26. const thick = 20
  27. // 初始化水平标尺上的参考线
  28. const lines = {
  29. h: [],
  30. v: []
  31. }
  32. // 颜色
  33. const themeColor = computed(() => {
  34. return designStore.getAppTheme
  35. })
  36. </script>
  37. <style>
  38. /* 使用 SCSS 会报错,直接使用最基础的 CSS 进行修改,
  39. 此库有计划 Vue3 版本,但是开发的时候还没发布 */
  40. #mb-ruler {
  41. top: 0;
  42. left: 0;
  43. }
  44. /* 横线 */
  45. #mb-ruler .v-container .lines .line {
  46. /* 最大缩放 200% */
  47. width: 200vw!important;
  48. border-top: 1px dashed v-bind('themeColor') !important;
  49. }
  50. #mb-ruler .v-container .indicator {
  51. border-bottom: 1px dashed v-bind('themeColor') !important;
  52. }
  53. /* 竖线 */
  54. #mb-ruler .h-container .lines .line {
  55. /* 最大缩放 200% */
  56. height: 200vh!important;
  57. border-left: 1px dashed v-bind('themeColor') !important;
  58. }
  59. #mb-ruler .h-container .indicator {
  60. border-left: 1px dashed v-bind('themeColor') !important;
  61. }
  62. /* 坐标数值背景颜色 */
  63. #mb-ruler .indicator .value {
  64. background-color: rgba(0, 0, 0, 0);
  65. }
  66. /* 删除按钮 */
  67. #mb-ruler .line .del {
  68. padding: 0;
  69. color: v-bind('themeColor');
  70. font-size: 26px;
  71. font-weight: bolder;
  72. }
  73. #mb-ruler .corner{
  74. border-width: 0!important;
  75. }
  76. </style>