|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <div class="wrapper whitewrapper" :style="rectStyle"> |
| 4 | + <sketch-rule ref="sketchruleRef" v-bind="post"> |
| 5 | + <template #default> |
| 6 | + <div data-type="page" :style="canvasStyle"> |
| 7 | + <el-input v-model="inputValue" type="text" /> |
| 8 | + </div> |
| 9 | + </template> |
| 10 | + <template #btn="{ reset, zoomIn, zoomOut }"> |
| 11 | + <div class="btns"> |
| 12 | + <button @click.stop="reset">还原</button> |
| 13 | + <button @click.stop="zoomIn">放大</button> |
| 14 | + <button @click.stop="zoomOut">缩小</button> |
| 15 | + </div> |
| 16 | + </template> |
| 17 | + </sketch-rule> |
| 18 | + </div> |
| 19 | + </div> |
| 20 | +</template> |
| 21 | +<script setup lang="ts"> |
| 22 | +import bgImg from '../assets/bg.png' |
| 23 | +import { computed, ref, reactive } from 'vue' |
| 24 | +import SketchRule from 'vue3-sketch-ruler' |
| 25 | +import 'vue3-sketch-ruler/lib/style.css' |
| 26 | +const sketchruleRef = ref() |
| 27 | +const post = reactive({ |
| 28 | + thick: 20, |
| 29 | + width: 1470, |
| 30 | + height: 700, |
| 31 | + showShadowText: false, |
| 32 | + canvasWidth: 1000, |
| 33 | + canvasHeight: 500, |
| 34 | + showRuler: true, |
| 35 | + palette: { bgColor: 'transparent', lineType: 'dashed' }, |
| 36 | + isShowReferLine: true, |
| 37 | + shadow: { |
| 38 | + x: 0, |
| 39 | + y: 0, |
| 40 | + width: 300, |
| 41 | + height: 300 |
| 42 | + }, |
| 43 | + lines: { |
| 44 | + h: [0, 250], |
| 45 | + v: [0, 500] |
| 46 | + } |
| 47 | +}) |
| 48 | +
|
| 49 | +const rectStyle = computed(() => { |
| 50 | + return { |
| 51 | + width: `${post.width}px`, |
| 52 | + height: `${post.height}px` |
| 53 | + } |
| 54 | +}) |
| 55 | +
|
| 56 | +const inputValue = ref('') |
| 57 | +
|
| 58 | +const canvasStyle = computed(() => { |
| 59 | + return { |
| 60 | + width: `${post.canvasWidth}px`, |
| 61 | + height: `${post.canvasHeight}px` |
| 62 | + } |
| 63 | +}) |
| 64 | +</script> |
| 65 | + |
| 66 | +<style lang="scss"> |
| 67 | +.wrapper { |
| 68 | + margin: 0 auto; |
| 69 | + background-size: |
| 70 | + 21px 21px, |
| 71 | + 21px 21px; |
| 72 | + border: 1px solid #dadadc; |
| 73 | +} |
| 74 | +.whitewrapper { |
| 75 | + background-color: #fafafc; |
| 76 | + background-image: linear-gradient(#fafafc 20px, transparent 0), |
| 77 | + linear-gradient(90deg, transparent 20px, #373739 0); |
| 78 | +} |
| 79 | +.img-style { |
| 80 | + width: 100%; |
| 81 | + height: 100%; |
| 82 | +} |
| 83 | +.btns { |
| 84 | + position: absolute; |
| 85 | + display: flex; |
| 86 | + bottom: 20px; |
| 87 | + right: 40px; |
| 88 | + z-index: 999; |
| 89 | +} |
| 90 | +
|
| 91 | +</style> |
0 commit comments