forked from github/dataease
feat(数据大屏): 数据大屏支持不同伸缩方式设置
This commit is contained in:
parent
5275947fe9
commit
684c61536f
@ -8,16 +8,24 @@ const dvMainStore = dvMainStoreWithOut()
|
||||
const { componentData, curComponentIndex, canvasStyleData } = storeToRefs(dvMainStore)
|
||||
|
||||
const needToChangeAttrs = ['top', 'left', 'width', 'height', 'fontSize', 'letterSpacing']
|
||||
const needToChangeDirectionAttrs = {
|
||||
width: ['left', 'width', 'fontSize', 'letterSpacing'],
|
||||
height: ['top', 'height']
|
||||
}
|
||||
|
||||
export function changeSizeWithScale(scale) {
|
||||
return changeComponentsSizeWithScale(scale)
|
||||
}
|
||||
|
||||
export function changeComponentsSizeWithScale(scale) {
|
||||
export function changeSizeWithDirectionScale(scale, direction) {
|
||||
return changeComponentsSizeWithScale(scale, needToChangeDirectionAttrs[direction])
|
||||
}
|
||||
|
||||
export function changeComponentsSizeWithScale(scale, changeAttrs = needToChangeAttrs) {
|
||||
const componentDataCopy = deepCopy(componentData.value)
|
||||
componentDataCopy.forEach(component => {
|
||||
Object.keys(component.style).forEach(key => {
|
||||
if (needToChangeAttrs.includes(key)) {
|
||||
if (changeAttrs.includes(key)) {
|
||||
if (key === 'fontSize' && component.style[key] === '') return
|
||||
// 根据原来的比例获取样式原来的尺寸
|
||||
// 再用原来的尺寸 * 现在的比例得出新的尺寸
|
||||
@ -52,21 +60,35 @@ export function changeComponentsSizeWithScale(scale) {
|
||||
})
|
||||
}
|
||||
|
||||
export function changeRefComponentsSizeWithScale(componentDataRef, canvasStyleDataRef, scale) {
|
||||
export function changeRefComponentsSizeWithScale(
|
||||
componentDataRef,
|
||||
canvasStyleDataRef,
|
||||
scaleWidth,
|
||||
scaleHeight
|
||||
) {
|
||||
componentDataRef.forEach(component => {
|
||||
Object.keys(component.style).forEach(key => {
|
||||
if (needToChangeAttrs.includes(key)) {
|
||||
if (key === 'fontSize' && component.style[key] === '') return
|
||||
if (key === 'fontSize' && component.style[key] === '') return
|
||||
if (needToChangeDirectionAttrs.width.includes(key)) {
|
||||
// 根据原来的比例获取样式原来的尺寸
|
||||
// 再用原来的尺寸 * 现在的比例得出新的尺寸
|
||||
component.style[key] = format(
|
||||
getOriginStyle(component.style[key], canvasStyleDataRef.scale),
|
||||
scale
|
||||
scaleWidth
|
||||
)
|
||||
} else if (needToChangeDirectionAttrs.height.includes(key)) {
|
||||
// 根据原来的比例获取样式原来的尺寸
|
||||
// 再用原来的尺寸 * 现在的比例得出新的尺寸
|
||||
component.style[key] = format(
|
||||
getOriginStyle(component.style[key], canvasStyleDataRef.scale),
|
||||
scaleHeight
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
canvasStyleDataRef.scale = scale
|
||||
canvasStyleDataRef.scale = scaleWidth
|
||||
canvasStyleDataRef.scaleWidth = scaleWidth
|
||||
canvasStyleDataRef.scaleHeight = scaleHeight
|
||||
}
|
||||
|
||||
const needToChangeAttrs2 = ['width', 'height', 'fontSize']
|
||||
|
Loading…
Reference in New Issue
Block a user