mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
feat:新增旋转功能
This commit is contained in:
parent
ab96d0919f
commit
ef9e4c8ea4
@ -20,7 +20,7 @@
|
|||||||
placeholder="px"
|
placeholder="px"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<n-text depth="3">上边</n-text>
|
<n-text depth="3">上</n-text>
|
||||||
</template>
|
</template>
|
||||||
</n-input-number>
|
</n-input-number>
|
||||||
<n-input-number
|
<n-input-number
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<collapse-item name="滤镜">
|
<collapse-item :name="isCanvas ? '滤镜' : '滤镜 / 变换'">
|
||||||
<setting-item-box name="色相" :alone="true">
|
<setting-item-box name="色相" :alone="true">
|
||||||
<setting-item :name="`值:${chartStyles.hueRotate}deg`">
|
<setting-item :name="`值:${chartStyles.hueRotate}deg`">
|
||||||
<!-- 透明度 -->
|
<!-- 透明度 -->
|
||||||
@ -68,6 +68,62 @@
|
|||||||
></n-slider>
|
></n-slider>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
|
<!-- 变换 -->
|
||||||
|
<setting-item-box v-if="!isCanvas" name="旋转°">
|
||||||
|
<setting-item name="Z轴(平面) - 旋转">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="chartStyles.rotateZ"
|
||||||
|
:min="0"
|
||||||
|
:max="360"
|
||||||
|
size="small"
|
||||||
|
placeholder="角度"
|
||||||
|
></n-input-number>
|
||||||
|
</setting-item>
|
||||||
|
<setting-item name="X轴 - 旋转">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="chartStyles.rotateX"
|
||||||
|
:min="0"
|
||||||
|
:max="360"
|
||||||
|
size="small"
|
||||||
|
placeholder="角度"
|
||||||
|
></n-input-number>
|
||||||
|
</setting-item>
|
||||||
|
<setting-item name="Y轴 - 旋转">
|
||||||
|
<!-- 透明度 -->
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="chartStyles.rotateY"
|
||||||
|
:min="0"
|
||||||
|
:max="360"
|
||||||
|
size="small"
|
||||||
|
placeholder="角度"
|
||||||
|
></n-input-number>
|
||||||
|
</setting-item>
|
||||||
|
</setting-item-box>
|
||||||
|
|
||||||
|
<!-- 倾斜 -->
|
||||||
|
<setting-item-box v-if="!isCanvas" name="倾斜°">
|
||||||
|
<setting-item name="X轴 - 倾斜">
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="chartStyles.skewX"
|
||||||
|
:min="0"
|
||||||
|
:max="360"
|
||||||
|
size="small"
|
||||||
|
placeholder="角度"
|
||||||
|
></n-input-number>
|
||||||
|
</setting-item>
|
||||||
|
<setting-item name="Y轴 - 倾斜">
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="chartStyles.skewY"
|
||||||
|
:min="0"
|
||||||
|
:max="360"
|
||||||
|
size="small"
|
||||||
|
placeholder="角度"
|
||||||
|
></n-input-number>
|
||||||
|
</setting-item>
|
||||||
|
</setting-item-box>
|
||||||
</collapse-item>
|
</collapse-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -81,6 +137,10 @@ import {
|
|||||||
} from '@/components/Pages/ChartItemSetting'
|
} from '@/components/Pages/ChartItemSetting'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
isCanvas: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
chartStyles: {
|
chartStyles: {
|
||||||
type: Object as PropType<Omit<PickCreateComponentType<'styles'>, 'animations'>>,
|
type: Object as PropType<Omit<PickCreateComponentType<'styles'>, 'animations'>>,
|
||||||
required: true,
|
required: true,
|
||||||
|
36
src/packages/index.d.ts
vendored
36
src/packages/index.d.ts
vendored
@ -26,13 +26,27 @@ interface EchartsDataType {
|
|||||||
source: any[]
|
source: any[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 滤镜枚举
|
// 滤镜/变换枚举
|
||||||
export enum FilterEnum {
|
export enum FilterEnum {
|
||||||
HUE_ROTATE = 'hueRotate',
|
// 透明度
|
||||||
SATURATE = 'saturate',
|
|
||||||
BRIGHTNESS = 'brightness',
|
|
||||||
CONTRAST = 'contrast',
|
|
||||||
OPACITY = 'opacity',
|
OPACITY = 'opacity',
|
||||||
|
// 饱和度
|
||||||
|
SATURATE = 'saturate',
|
||||||
|
// 对比度
|
||||||
|
CONTRAST = 'contrast',
|
||||||
|
// 色相
|
||||||
|
HUE_ROTATE = 'hueRotate',
|
||||||
|
// 亮度
|
||||||
|
BRIGHTNESS = 'brightness',
|
||||||
|
|
||||||
|
// 旋转
|
||||||
|
ROTATE_Z = 'rotateZ',
|
||||||
|
ROTATE_X = 'rotateX',
|
||||||
|
ROTATE_Y = 'rotateY',
|
||||||
|
|
||||||
|
// 倾斜
|
||||||
|
SKEW_X = 'skewX',
|
||||||
|
SKEW_Y = 'skewY',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组件实例类
|
// 组件实例类
|
||||||
@ -41,16 +55,18 @@ export interface PublicConfigType extends requestConfig {
|
|||||||
rename?: string
|
rename?: string
|
||||||
attr: { x: number; y: number; w: number; h: number; zIndex: number }
|
attr: { x: number; y: number; w: number; h: number; zIndex: number }
|
||||||
styles: {
|
styles: {
|
||||||
// 透明度
|
|
||||||
[FilterEnum.OPACITY]: number;
|
[FilterEnum.OPACITY]: number;
|
||||||
// 饱和度
|
|
||||||
[FilterEnum.SATURATE]: number;
|
[FilterEnum.SATURATE]: number;
|
||||||
// 对比度
|
|
||||||
[FilterEnum.CONTRAST]: number;
|
[FilterEnum.CONTRAST]: number;
|
||||||
// 色相
|
|
||||||
[FilterEnum.HUE_ROTATE]: number;
|
[FilterEnum.HUE_ROTATE]: number;
|
||||||
// 亮度
|
|
||||||
[FilterEnum.BRIGHTNESS]: number;
|
[FilterEnum.BRIGHTNESS]: number;
|
||||||
|
|
||||||
|
[FilterEnum.ROTATE_Z]: number;
|
||||||
|
[FilterEnum.ROTATE_X]: number;
|
||||||
|
[FilterEnum.ROTATE_Y]: number;
|
||||||
|
|
||||||
|
[FilterEnum.SKEW_X]: number;
|
||||||
|
[FilterEnum.SKEW_Y]: number;
|
||||||
// 动画
|
// 动画
|
||||||
animations: string[]
|
animations: string[]
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,16 @@ export class publicConfig implements PublicConfigType {
|
|||||||
brightness: 1,
|
brightness: 1,
|
||||||
// 透明
|
// 透明
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
|
|
||||||
|
// 旋转
|
||||||
|
rotateZ: 0,
|
||||||
|
rotateX: 0,
|
||||||
|
rotateY: 0,
|
||||||
|
|
||||||
|
// 倾斜
|
||||||
|
skewX: 0,
|
||||||
|
skewY: 0,
|
||||||
|
|
||||||
// 动画
|
// 动画
|
||||||
animations: []
|
animations: []
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
</n-space>
|
</n-space>
|
||||||
|
|
||||||
<!-- 滤镜 -->
|
<!-- 滤镜 -->
|
||||||
<styles-setting :chartStyles="canvasConfig"></styles-setting>
|
<styles-setting :is-canvas="true" :chartStyles="canvasConfig"></styles-setting>
|
||||||
<n-divider style="margin: 10px 0;"></n-divider>
|
<n-divider style="margin: 10px 0;"></n-divider>
|
||||||
|
|
||||||
<!-- 主题选择和全局配置 -->
|
<!-- 主题选择和全局配置 -->
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
:class="animationsClass(item.styles.animations)"
|
:class="animationsClass(item.styles.animations)"
|
||||||
v-for="(item, index) in localStorageInfo.componentList"
|
v-for="(item, index) in localStorageInfo.componentList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:style="{ ...getComponentAttrStyle(item.attr, index), ...getStyle(item.styles)}"
|
:style="{
|
||||||
|
...getComponentAttrStyle(item.attr, index),
|
||||||
|
...getFilterStyle(item.styles),
|
||||||
|
...getTranstormStyle(item.styles)
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
:is="item.chartConfig.chartKey"
|
:is="item.chartConfig.chartKey"
|
||||||
@ -20,7 +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, getStyle, getComponentAttrStyle, animationsClass } from '../../utils'
|
import { getSizeStyle, getFilterStyle, getTranstormStyle, getComponentAttrStyle, animationsClass } from '../../utils'
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
localStorageInfo: {
|
localStorageInfo: {
|
||||||
@ -29,6 +34,8 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(getTranstormStyle(props.localStorageInfo.componentList[0].styles))
|
||||||
|
|
||||||
// 主题色
|
// 主题色
|
||||||
const themeSetting = computed(() => {
|
const themeSetting = computed(() => {
|
||||||
const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
|
const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<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, getStyle, getSessionStorageInfo } from './utils'
|
import { getEditCanvasConfigStyle, getFilterStyle, 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'
|
||||||
@ -25,7 +25,7 @@ import type { ChartEditStorageType } from './index.d'
|
|||||||
const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
|
const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
|
||||||
|
|
||||||
const previewRefStyle = computed(() => {
|
const previewRefStyle = computed(() => {
|
||||||
return { ...getEditCanvasConfigStyle(localStorageInfo.editCanvasConfig), ...getStyle(localStorageInfo.editCanvasConfig) }
|
return { ...getEditCanvasConfigStyle(localStorageInfo.editCanvasConfig), ...getFilterStyle(localStorageInfo.editCanvasConfig) }
|
||||||
})
|
})
|
||||||
|
|
||||||
useStore(localStorageInfo)
|
useStore(localStorageInfo)
|
||||||
|
@ -47,11 +47,19 @@ export const animationsClass = (animations: string[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 滤镜
|
// 滤镜
|
||||||
export const getStyle = (styles: StylesType | EditCanvasConfigType) => {
|
export const getFilterStyle = (styles: StylesType | EditCanvasConfigType) => {
|
||||||
const { opacity, saturate, contrast, hueRotate, brightness } = styles
|
const { opacity, saturate, contrast, hueRotate, brightness } = styles
|
||||||
return {
|
return {
|
||||||
// 透明度
|
// 透明度
|
||||||
opacity: opacity,
|
opacity: opacity,
|
||||||
filter: `saturate(${saturate}) contrast(${contrast}) hue-rotate(${hueRotate}deg) brightness(${brightness})`
|
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