mirror of
https://gitee.com/dromara/go-view.git
synced 2024-12-02 11:48:36 +08:00
fix: 提取滤镜,变换,动画方法到全局
This commit is contained in:
parent
ef9e4c8ea4
commit
cf50e77daf
@ -1,5 +1,36 @@
|
|||||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
|
||||||
import Color from 'color'
|
import Color from 'color'
|
||||||
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
|
import { PickCreateComponentType } from '@/packages/index.d'
|
||||||
|
import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
|
||||||
|
type AttrType = PickCreateComponentType<'attr'>
|
||||||
|
type StylesType = PickCreateComponentType<'styles'>
|
||||||
|
|
||||||
|
// 动画
|
||||||
|
export const animationsClass = (animations: string[]) => {
|
||||||
|
if (animations.length) {
|
||||||
|
return `animate__animated animate__${animations[0]}`
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滤镜
|
||||||
|
export const getFilterStyle = (styles: StylesType | EditCanvasConfigType) => {
|
||||||
|
const { opacity, saturate, contrast, hueRotate, brightness } = styles
|
||||||
|
return {
|
||||||
|
// 透明度
|
||||||
|
opacity: opacity,
|
||||||
|
filter: `saturate(${saturate}) contrast(${contrast}) hue-rotate(${hueRotate}deg) brightness(${brightness})`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 变换
|
||||||
|
export const getTranstormStyle = (styles: StylesType) => {
|
||||||
|
const { rotateZ, rotateX, rotateY, skewX, skewY } = styles
|
||||||
|
return {
|
||||||
|
transform: `rotateZ(${rotateZ || 0}deg) rotateX(${rotateX || 0}deg) rotateY(${rotateY || 0}deg) skewX(${skewX || 0}deg) skewY(${skewY || 0}deg)`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * hsla 转换
|
* * hsla 转换
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
import { PropType, computed } from 'vue'
|
import { PropType, computed } from 'vue'
|
||||||
import { ChartEditStorageType } from '../../index.d'
|
import { ChartEditStorageType } from '../../index.d'
|
||||||
import { chartColors } from '@/settings/chartThemes/index'
|
import { chartColors } from '@/settings/chartThemes/index'
|
||||||
import { getSizeStyle, getFilterStyle, getTranstormStyle, getComponentAttrStyle, animationsClass } from '../../utils'
|
import { animationsClass, getFilterStyle, getTranstormStyle } from '@/utils'
|
||||||
|
import { getSizeStyle, getComponentAttrStyle } from '../../utils'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
localStorageInfo: {
|
localStorageInfo: {
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { PreviewRenderList } from './components/PreviewRenderList'
|
import { PreviewRenderList } from './components/PreviewRenderList'
|
||||||
import { getEditCanvasConfigStyle, getFilterStyle, getSessionStorageInfo } from './utils'
|
import { getFilterStyle } from '@/utils'
|
||||||
|
import { getEditCanvasConfigStyle, getSessionStorageInfo } from './utils'
|
||||||
import { useComInstall } from './hooks/useComInstall.hook'
|
import { useComInstall } from './hooks/useComInstall.hook'
|
||||||
import { useScale } from './hooks/useScale.hook'
|
import { useScale } from './hooks/useScale.hook'
|
||||||
import { useStore } from './hooks/useStore.hook'
|
import { useStore } from './hooks/useStore.hook'
|
||||||
|
@ -37,29 +37,3 @@ export const getEditCanvasConfigStyle = (canvas: EditCanvasConfigType) => {
|
|||||||
...computedBackground
|
...computedBackground
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动画
|
|
||||||
export const animationsClass = (animations: string[]) => {
|
|
||||||
if (animations.length) {
|
|
||||||
return `animate__animated animate__${animations[0]}`
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// 滤镜
|
|
||||||
export const getFilterStyle = (styles: StylesType | EditCanvasConfigType) => {
|
|
||||||
const { opacity, saturate, contrast, hueRotate, brightness } = styles
|
|
||||||
return {
|
|
||||||
// 透明度
|
|
||||||
opacity: opacity,
|
|
||||||
filter: `saturate(${saturate}) contrast(${contrast}) hue-rotate(${hueRotate}deg) brightness(${brightness})`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 变换
|
|
||||||
export const getTranstormStyle = (styles: StylesType) => {
|
|
||||||
const { rotateZ, rotateX, rotateY, skewX, skewY } = styles
|
|
||||||
return {
|
|
||||||
transform: `rotateZ(${rotateZ || 0}deg) rotateX(${rotateX || 0}deg) rotateY(${rotateY || 0}deg) skewX(${skewX || 0}deg) skewY(${skewY || 0}deg)`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user