feat: 动态阴影显示

This commit is contained in:
马军 2026-05-12 15:20:55 +08:00
parent 48bf4aa989
commit 1c7e2e04d3
2 changed files with 44 additions and 5 deletions

View File

@ -30,6 +30,7 @@ import type { CSSProperties } from 'vue'
import { listen } from 'dom-helpers'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { CreateComponentGroupType } from '@/packages/index.d'
import throttle from 'lodash/throttle'
const chartEditStore = useChartEditStore()
@ -71,7 +72,7 @@ const paletteStyle = computed(() => {
longfgColor: '#4d4d4d',
shortfgColor: '#4d4d4d',
fontColor: '#4d4d4d',
shadowColor: '#18181c',
shadowColor: '#232324',
borderColor: '#18181c',
cornerActiveColor: '#18181c'
}
@ -89,13 +90,50 @@ const canvasStyle = computed((): CSSProperties => {
height: `${height.value}px`
}
})
// id
const findComponentById = (id: string) => {
for (const item of chartEditStore.getComponentList) {
if (item.id === id) return item
if (item.isGroup) {
const child = (item as CreateComponentGroupType).groupList.find(c => c.id === id)
if (child) return child
}
}
return null
}
// thick
const shadow = computed(() => {
const selectIds = chartEditStore.getTargetChart.selectId
if (!selectIds.length) {
return { x: 0, y: 0, width: 0, height: 0 }
}
let minX = Infinity
let minY = Infinity
let maxX = -Infinity
let maxY = -Infinity
for (const id of selectIds) {
const comp = findComponentById(id)
if (comp) {
const { x, y, w, h } = comp.attr
minX = Math.min(minX, x)
minY = Math.min(minY, y)
maxX = Math.max(maxX, x + w)
maxY = Math.max(maxY, y + h)
}
}
if (minX === Infinity) {
return { x: 0, y: 0, width: 0, height: 0 }
}
return {
x: 0,
y: 0,
width: 200,
height: 200
x: minX,
y: minY,
width: maxX - minX,
height: maxY - minY
}
})

View File

@ -223,6 +223,7 @@ $asideBottom: 70px;
@include go('chart-edit-tools') {
@extend .go-background-filter;
z-index: 9;
position: absolute;
display: flex;
justify-content: space-around;