index.vue 1.8 KB

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