66 lines
1.9 KiB
Vue
Raw Normal View History

2022-01-20 21:25:35 +08:00
<template>
2022-01-29 23:58:56 +08:00
<div
2022-03-10 20:54:02 +08:00
class="go-edit-range go-transition"
:style="rangeStyle"
2022-01-30 14:20:28 +08:00
@mousedown="mousedownHandleUnStop($event, undefined)"
2022-01-29 23:58:56 +08:00
>
<edit-rule></edit-rule>
2022-01-20 21:25:35 +08:00
<slot></slot>
2022-03-11 08:45:04 +08:00
<!-- 拖拽时的辅助线 -->
2022-03-14 19:52:01 +08:00
<edit-align-line></edit-align-line>
2022-01-20 21:25:35 +08:00
</div>
</template>
2022-01-27 23:16:51 +08:00
<script setup lang="ts">
2022-02-06 21:35:38 +08:00
import { toRefs, computed } from 'vue'
2022-01-27 23:16:51 +08:00
import { useSizeStyle } from '../../hooks/useStyle.hook'
import { mousedownHandleUnStop } from '../../hooks/useDrag.hook'
2022-03-04 20:57:36 +08:00
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditAlignLine } from '../EditAlignLine'
import { EditRule } from '../EditRule'
2022-01-29 23:58:56 +08:00
2022-03-04 20:57:36 +08:00
const chartEditStore = useChartEditStore()
2022-02-06 01:04:05 +08:00
2022-03-04 20:57:36 +08:00
const { getEditCanvasConfig, getEditCanvas } = toRefs(chartEditStore)
2022-02-06 01:04:05 +08:00
const size = computed(() => {
return {
2022-02-06 21:35:38 +08:00
w: getEditCanvasConfig.value.width,
h: getEditCanvasConfig.value.height
2022-02-06 01:04:05 +08:00
}
})
const rangeStyle = computed(() => {
2022-03-11 08:45:04 +08:00
// 缩放
2022-03-10 20:54:02 +08:00
const scale = {
transform: `scale(${getEditCanvas.value.scale})`
}
// 设置背景色和图片背景
2022-02-06 21:35:38 +08:00
const background = getEditCanvasConfig.value.background
const backgroundImage = getEditCanvasConfig.value.backgroundImage
const selectColor = getEditCanvasConfig.value.selectColor
const backgroundColor = background ? background : undefined
2022-03-10 20:54:02 +08:00
const computedBackground = selectColor
2022-02-06 21:35:38 +08:00
? { background: backgroundColor }
: { background: `url(${backgroundImage}) no-repeat center/100% !important` }
2022-03-10 20:54:02 +08:00
2022-02-06 01:04:05 +08:00
// @ts-ignore
2022-03-10 20:54:02 +08:00
return { ...useSizeStyle(size.value), ...computedBackground, ...scale }
})
2022-01-27 23:16:51 +08:00
</script>
2022-01-20 21:25:35 +08:00
<style lang="scss" scoped>
@include go(edit-range) {
position: relative;
border: 1px solid;
border-radius: 15px;
2022-03-10 20:54:02 +08:00
transform-origin: left top;
2022-01-20 21:25:35 +08:00
@include fetch-theme('box-shadow');
@include filter-border-color('hover-border-color');
@include fetch-theme-custom('border-color', 'background-color4');
2022-03-11 08:45:04 +08:00
@include filter-bg-color('background-color2');
2022-01-20 21:25:35 +08:00
}
</style>