mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 08:12:49 +08:00
feat: 新增动画功能
This commit is contained in:
parent
b96c2f0d3e
commit
a6e5dec2c0
@ -6,8 +6,6 @@ import { setupStore } from '@/store'
|
|||||||
import { setupNaive, setupDirectives, setupCustomComponents, setupPreviewPackages } from '@/plugins'
|
import { setupNaive, setupDirectives, setupCustomComponents, setupPreviewPackages } from '@/plugins'
|
||||||
import { AppProvider } from '@/components/AppProvider/index'
|
import { AppProvider } from '@/components/AppProvider/index'
|
||||||
import { setHtmlTheme } from '@/utils'
|
import { setHtmlTheme } from '@/utils'
|
||||||
|
|
||||||
// 引入动画
|
|
||||||
import 'animate.css/animate.min.css'
|
import 'animate.css/animate.min.css'
|
||||||
|
|
||||||
async function appInit() {
|
async function appInit() {
|
||||||
|
1
src/packages/index.d.ts
vendored
1
src/packages/index.d.ts
vendored
@ -19,6 +19,7 @@ export interface PublicConfigType {
|
|||||||
id: string
|
id: string
|
||||||
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: { opacity: number, animations: string[] }
|
||||||
setPosition: Function
|
setPosition: Function
|
||||||
}
|
}
|
||||||
export interface CreateComponentType extends PublicConfigType {
|
export interface CreateComponentType extends PublicConfigType {
|
||||||
|
@ -7,6 +7,11 @@ export class publicConfig implements PublicConfigType {
|
|||||||
public rename = undefined
|
public rename = undefined
|
||||||
// 基本信息
|
// 基本信息
|
||||||
public attr = { x: 0, y: 0, w: 500, h: 300, zIndex: -1 }
|
public attr = { x: 0, y: 0, w: 500, h: 300, zIndex: -1 }
|
||||||
|
// 基本样式(动画,透明)
|
||||||
|
public styles = {
|
||||||
|
opacity: 1,
|
||||||
|
animations: []
|
||||||
|
}
|
||||||
// 设置坐标
|
// 设置坐标
|
||||||
public setPosition(x: number, y: number): void {
|
public setPosition(x: number, y: number): void {
|
||||||
this.attr.x = x
|
this.attr.x = x
|
||||||
|
@ -46,6 +46,7 @@ DesktopOutline as DesktopOutlineIcon,
|
|||||||
Cut as CutIcon,
|
Cut as CutIcon,
|
||||||
Square as SquareIcon,
|
Square as SquareIcon,
|
||||||
ColorPalette as ColorPaletteIcon,
|
ColorPalette as ColorPaletteIcon,
|
||||||
|
Leaf as LeafIcon
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -158,7 +159,9 @@ const ionicons5 = {
|
|||||||
SquareIcon,
|
SquareIcon,
|
||||||
// 色彩选择
|
// 色彩选择
|
||||||
ColorPaletteIcon,
|
ColorPaletteIcon,
|
||||||
ZAxisIcon
|
ZAxisIcon,
|
||||||
|
// 气球
|
||||||
|
LeafIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
const carbon = {
|
const carbon = {
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
const animations = [
|
export const animations = [
|
||||||
{
|
{
|
||||||
label: '进入',
|
label: '强调动画',
|
||||||
|
children: [
|
||||||
|
{ label: '弹跳', value: 'bounce' },
|
||||||
|
{ label: '闪烁', value: 'flash' },
|
||||||
|
{ label: '放大缩小', value: 'pulse' },
|
||||||
|
{ label: '放大缩小弹簧', value: 'rubberBand' },
|
||||||
|
{ label: '左右晃动', value: 'headShake' },
|
||||||
|
{ label: '左右扇形摇摆', value: 'swing' },
|
||||||
|
{ label: '放大晃动缩小', value: 'tada' },
|
||||||
|
{ label: '扇形摇摆', value: 'wobble' },
|
||||||
|
{ label: '左右上下晃动', value: 'jello' },
|
||||||
|
{ label: 'Y轴旋转', value: 'flip' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '移入动画',
|
||||||
children: [
|
children: [
|
||||||
{ label: '渐显', value: 'fadeIn' },
|
{ label: '渐显', value: 'fadeIn' },
|
||||||
{ label: '向右进入', value: 'fadeInLeft' },
|
{ label: '向右进入', value: 'fadeInLeft' },
|
||||||
@ -39,58 +54,5 @@ const animations = [
|
|||||||
{ label: '向上滑动展开', value: 'slideInUp' },
|
{ label: '向上滑动展开', value: 'slideInUp' },
|
||||||
{ label: '向下滑动展开', value: 'slideInDown' }
|
{ label: '向下滑动展开', value: 'slideInDown' }
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '强调',
|
|
||||||
children: [
|
|
||||||
{ label: '弹跳', value: 'bounce' },
|
|
||||||
{ label: '闪烁', value: 'flash' },
|
|
||||||
{ label: '放大缩小', value: 'pulse' },
|
|
||||||
{ label: '放大缩小弹簧', value: 'rubberBand' },
|
|
||||||
{ label: '左右晃动', value: 'headShake' },
|
|
||||||
{ label: '左右扇形摇摆', value: 'swing' },
|
|
||||||
{ label: '放大晃动缩小', value: 'tada' },
|
|
||||||
{ label: '扇形摇摆', value: 'wobble' },
|
|
||||||
{ label: '左右上下晃动', value: 'jello' },
|
|
||||||
{ label: 'Y轴旋转', value: 'flip' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '退出',
|
|
||||||
children: [
|
|
||||||
{ label: '渐隐', value: 'fadeOut' },
|
|
||||||
{ label: '向左退出', value: 'fadeOutLeft' },
|
|
||||||
{ label: '向右退出', value: 'fadeOutRight' },
|
|
||||||
{ label: '向上退出', value: 'fadeOutUp' },
|
|
||||||
{ label: '向下退出', value: 'fadeOutDown' },
|
|
||||||
{ label: '向左长距退出', value: 'fadeOutLeftBig' },
|
|
||||||
{ label: '向右长距退出', value: 'fadeOutRightBig' },
|
|
||||||
{ label: '向上长距退出', value: 'fadeOutUpBig' },
|
|
||||||
{ label: '向下长距退出', value: 'fadeOutDownBig' },
|
|
||||||
{ label: '旋转退出', value: 'rotateOut' },
|
|
||||||
{ label: '左顺时针旋转', value: 'rotateOutDownLeft' },
|
|
||||||
{ label: '右逆时针旋转', value: 'rotateOutDownRight' },
|
|
||||||
{ label: '左逆时针旋转', value: 'rotateOutUpLeft' },
|
|
||||||
{ label: '右逆时针旋转', value: 'rotateOutUpRight' },
|
|
||||||
{ label: '弹出', value: 'bounceOut' },
|
|
||||||
{ label: '向左弹出', value: 'bounceOutLeft' },
|
|
||||||
{ label: '向右弹出', value: 'bounceOutRight' },
|
|
||||||
{ label: '向上弹出', value: 'bounceOutUp' },
|
|
||||||
{ label: '向下弹出', value: 'bounceOutDown' },
|
|
||||||
{ label: '中心X轴旋转', value: 'flipOutX' },
|
|
||||||
{ label: '中心Y轴旋转', value: 'flipOutY' },
|
|
||||||
{ label: '左长半径旋转', value: 'rollOut' },
|
|
||||||
{ label: '由小变大退出', value: 'zoomOut' },
|
|
||||||
{ label: '左变大退出', value: 'zoomOutLeft' },
|
|
||||||
{ label: '右变大退出', value: 'zoomOutRight' },
|
|
||||||
{ label: '向上变大退出', value: 'zoomOutUp' },
|
|
||||||
{ label: '向下变大退出', value: 'zoomOutDown' },
|
|
||||||
{ label: '向左滑动收起', value: 'slideOutLeft' },
|
|
||||||
{ label: '向右滑动收起', value: 'slideOutRight' },
|
|
||||||
{ label: '向上滑动收起', value: 'slideOutUp' },
|
|
||||||
{ label: '向下滑动收起', value: 'slideOutDown' }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
export { animations }
|
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
<template>
|
||||||
|
<div class="go-chart-configurations-animations" v-if="targetData">
|
||||||
|
<n-button
|
||||||
|
class="clear-btn"
|
||||||
|
:disabled="!targetData.styles.animations.length"
|
||||||
|
@click="clearAnimation"
|
||||||
|
>
|
||||||
|
清除动画
|
||||||
|
</n-button>
|
||||||
|
<CollapseItem
|
||||||
|
v-for="(item, index) in animations"
|
||||||
|
:key="index"
|
||||||
|
:name="item.label"
|
||||||
|
:expanded="true"
|
||||||
|
>
|
||||||
|
<n-grid :x-gap="6" :y-gap="10" :cols="3">
|
||||||
|
<n-grid-item
|
||||||
|
class="animation-item go-transition-quick"
|
||||||
|
:class="[
|
||||||
|
activeIndex(childrenItem.value) && 'active',
|
||||||
|
hoverPreviewAnimate === childrenItem.value &&
|
||||||
|
`animate__animated animate__${childrenItem.value}`
|
||||||
|
]"
|
||||||
|
v-for="(childrenItem, index) in item.children"
|
||||||
|
:key="index"
|
||||||
|
@mouseover="hoverPreviewAnimate = childrenItem.value"
|
||||||
|
@click="addAnimation(childrenItem)"
|
||||||
|
>
|
||||||
|
{{ childrenItem.label }}
|
||||||
|
</n-grid-item>
|
||||||
|
</n-grid>
|
||||||
|
</CollapseItem>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, Ref } from 'vue'
|
||||||
|
import { animations } from '@/settings/animations/index'
|
||||||
|
import { CollapseItem } from '@/components/ChartItemSetting/index'
|
||||||
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
|
|
||||||
|
// 全局颜色
|
||||||
|
const designStore = useDesignStore()
|
||||||
|
const themeColor = ref(designStore.getAppTheme)
|
||||||
|
|
||||||
|
const chartEditStore = useChartEditStore()
|
||||||
|
const hoverPreviewAnimate = ref('')
|
||||||
|
|
||||||
|
const targetData: Ref<CreateComponentType> = computed(() => {
|
||||||
|
const list = chartEditStore.getComponentList
|
||||||
|
const targetIndex = chartEditStore.fetchTargetIndex()
|
||||||
|
return list[targetIndex]
|
||||||
|
})
|
||||||
|
|
||||||
|
// * 选中样式
|
||||||
|
const activeIndex = (value: string) => {
|
||||||
|
const selectValue = targetData.value.styles.animations
|
||||||
|
if (!selectValue.length) return false
|
||||||
|
return selectValue[0] === value
|
||||||
|
}
|
||||||
|
|
||||||
|
// * 清除动画
|
||||||
|
const clearAnimation = () => {
|
||||||
|
targetData.value.styles.animations = []
|
||||||
|
}
|
||||||
|
|
||||||
|
// * 新增动画,现只支持一种
|
||||||
|
const addAnimation = (item: { label: string; value: string }) => {
|
||||||
|
targetData.value.styles.animations = [item.value]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@include go('chart-configurations-animations') {
|
||||||
|
padding: 20px 10px;
|
||||||
|
.clear-btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.animation-item {
|
||||||
|
height: 50px;
|
||||||
|
line-height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 5px;
|
||||||
|
@include hover-border-color('hover-border-color');
|
||||||
|
&:hover,
|
||||||
|
&.active {
|
||||||
|
color: v-bind('themeColor');
|
||||||
|
border: 1px solid v-bind('themeColor');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-chart-content-details" v-if="targetData">
|
<div class="go-chart-configurations-setting" v-if="targetData">
|
||||||
<!-- 名称 -->
|
<!-- 名称 -->
|
||||||
<SettingItemBox name="名称">
|
<SettingItemBox name="名称">
|
||||||
<n-input
|
<n-input
|
||||||
@ -39,6 +39,6 @@ const targetData: Ref<CreateComponentType> = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go('chart-content-details') {
|
@include go('chart-configurations-setting') {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -88,7 +88,12 @@ const { getDetails } = toRefs(useChartLayoutStore())
|
|||||||
const { setItem } = useChartLayoutStore()
|
const { setItem } = useChartLayoutStore()
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
const { ConstructIcon, FlashIcon, DesktopOutlineIcon, RocketIcon } = icon.ionicons5
|
const {
|
||||||
|
ConstructIcon,
|
||||||
|
FlashIcon,
|
||||||
|
DesktopOutlineIcon,
|
||||||
|
LeafIcon
|
||||||
|
} = icon.ionicons5
|
||||||
|
|
||||||
const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'))
|
const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'))
|
||||||
const CanvasPage = loadAsyncComponent(() =>
|
const CanvasPage = loadAsyncComponent(() =>
|
||||||
@ -100,8 +105,8 @@ const ChartSetting = loadAsyncComponent(() =>
|
|||||||
const ChartData = loadAsyncComponent(() =>
|
const ChartData = loadAsyncComponent(() =>
|
||||||
import('./components/ChartData/index.vue')
|
import('./components/ChartData/index.vue')
|
||||||
)
|
)
|
||||||
const ChartEvent = loadAsyncComponent(() =>
|
const ChartAnimation = loadAsyncComponent(() =>
|
||||||
import('./components/ChartEvent/index.vue')
|
import('./components/ChartAnimation/index.vue')
|
||||||
)
|
)
|
||||||
|
|
||||||
const collapsed = ref<boolean>(getDetails.value)
|
const collapsed = ref<boolean>(getDetails.value)
|
||||||
@ -119,9 +124,7 @@ const expandHindle = () => {
|
|||||||
const selectTarget = computed(() => {
|
const selectTarget = computed(() => {
|
||||||
const selectId = chartEditStore.getTargetChart.selectId
|
const selectId = chartEditStore.getTargetChart.selectId
|
||||||
if (!selectId) return undefined
|
if (!selectId) return undefined
|
||||||
return chartEditStore.componentList[
|
return chartEditStore.componentList[chartEditStore.fetchTargetIndex()]
|
||||||
chartEditStore.fetchTargetIndex()
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(getDetails, newData => {
|
watch(getDetails, newData => {
|
||||||
@ -149,18 +152,18 @@ const canvasTabList = [
|
|||||||
icon: ConstructIcon,
|
icon: ConstructIcon,
|
||||||
render: ChartSetting
|
render: ChartSetting
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'ChartAnimation',
|
||||||
|
title: '动画',
|
||||||
|
icon: LeafIcon,
|
||||||
|
render: ChartAnimation
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'ChartData',
|
key: 'ChartData',
|
||||||
title: '数据',
|
title: '数据',
|
||||||
icon: FlashIcon,
|
icon: FlashIcon,
|
||||||
render: ChartData
|
render: ChartData
|
||||||
},
|
}
|
||||||
{
|
|
||||||
key: 'ChartEvent',
|
|
||||||
title: '事件',
|
|
||||||
icon: RocketIcon,
|
|
||||||
render: ChartEvent
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="chart-item"
|
class="chart-item"
|
||||||
|
: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="{ ...useComponentStyle(item.attr, index), ...useSizeStyle(item.attr) }"
|
:style="{ ...useComponentAttrStyle(item.attr, index), ...useSizeStyle(item.attr) }"
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
:is="item.key"
|
:is="item.key"
|
||||||
@ -18,7 +19,7 @@
|
|||||||
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 { useSizeStyle, useComponentStyle } from '../../utils'
|
import { useSizeStyle, useComponentAttrStyle, animationsClass } from '../../utils'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
localStorageInfo: {
|
localStorageInfo: {
|
||||||
@ -27,7 +28,6 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// 主题色
|
// 主题色
|
||||||
const themeSetting = computed(() => {
|
const themeSetting = computed(() => {
|
||||||
const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
|
const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
|
||||||
|
@ -2,8 +2,9 @@ import { PickCreateComponentType } from '@/packages/index.d'
|
|||||||
import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { EditCanvasConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
|
||||||
type AttrType = PickCreateComponentType<'attr'>
|
type AttrType = PickCreateComponentType<'attr'>
|
||||||
|
type StylesType = PickCreateComponentType<'styles'>
|
||||||
|
|
||||||
export const useComponentStyle = (attr: AttrType, index: number) => {
|
export const useComponentAttrStyle = (attr: AttrType, index: number) => {
|
||||||
const componentStyle = {
|
const componentStyle = {
|
||||||
zIndex: index + 1,
|
zIndex: index + 1,
|
||||||
left: `${attr.x}px`,
|
left: `${attr.x}px`,
|
||||||
@ -15,7 +16,7 @@ export const useComponentStyle = (attr: AttrType, index: number) => {
|
|||||||
export const useSizeStyle = (attr: AttrType, scale?: number) => {
|
export const useSizeStyle = (attr: AttrType, scale?: number) => {
|
||||||
const sizeStyle = {
|
const sizeStyle = {
|
||||||
width: `${scale ? scale * attr.w : attr.w}px`,
|
width: `${scale ? scale * attr.w : attr.w}px`,
|
||||||
height: `${scale ? scale * attr.h : attr.h}px`,
|
height: `${scale ? scale * attr.h : attr.h}px`
|
||||||
}
|
}
|
||||||
return sizeStyle
|
return sizeStyle
|
||||||
}
|
}
|
||||||
@ -24,7 +25,9 @@ export const useEditCanvasConfigStyle = (canvas: EditCanvasConfigType) => {
|
|||||||
// 背景
|
// 背景
|
||||||
const computedBackground = canvas.selectColor
|
const computedBackground = canvas.selectColor
|
||||||
? { background: canvas.background }
|
? { background: canvas.background }
|
||||||
: { background: `url(${canvas.backgroundImage}) no-repeat center/100% !important` }
|
: {
|
||||||
|
background: `url(${canvas.backgroundImage}) no-repeat center/100% !important`
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
width: canvas.width ? `${canvas.width || 100}px` : '100%',
|
width: canvas.width ? `${canvas.width || 100}px` : '100%',
|
||||||
@ -32,3 +35,11 @@ export const useEditCanvasConfigStyle = (canvas: EditCanvasConfigType) => {
|
|||||||
...computedBackground
|
...computedBackground
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 动画
|
||||||
|
export const animationsClass = (animations: string[]) => {
|
||||||
|
if (animations.length) {
|
||||||
|
return `animate__animated animate__${animations[0]}`
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user