mirror of
https://gitee.com/dromara/go-view.git
synced 2025-05-21 10:34:04 +08:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { PickCreateComponentType } from '@/packages/index.d'
|
|
import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
|
|
|
type AttrType = PickCreateComponentType<'attr'>
|
|
type StylesType = PickCreateComponentType<'styles'>
|
|
|
|
export const useComponentAttrStyle = (attr: AttrType, index: number) => {
|
|
const componentStyle = {
|
|
zIndex: index + 1,
|
|
left: `${attr.x}px`,
|
|
top: `${attr.y}px`
|
|
}
|
|
return componentStyle
|
|
}
|
|
|
|
export const useSizeStyle = (attr: AttrType, scale?: number) => {
|
|
const sizeStyle = {
|
|
width: `${scale ? scale * attr.w : attr.w}px`,
|
|
height: `${scale ? scale * attr.h : attr.h}px`
|
|
}
|
|
return sizeStyle
|
|
}
|
|
|
|
export const useEditCanvasConfigStyle = (canvas: EditCanvasConfigType) => {
|
|
// 背景
|
|
const computedBackground = canvas.selectColor
|
|
? { background: canvas.background }
|
|
: {
|
|
background: `url(${canvas.backgroundImage}) no-repeat center/100% !important`
|
|
}
|
|
return {
|
|
position: 'relative',
|
|
width: canvas.width ? `${canvas.width || 100}px` : '100%',
|
|
height: canvas.height ? `${canvas.height}px` : '100%',
|
|
...computedBackground
|
|
}
|
|
}
|
|
|
|
// 动画
|
|
export const animationsClass = (animations: string[]) => {
|
|
if (animations.length) {
|
|
return `animate__animated animate__${animations[0]}`
|
|
}
|
|
return ''
|
|
}
|