|
@@ -1,35 +1,101 @@
|
|
<template>
|
|
<template>
|
|
- <div class="animates">
|
|
|
|
- <template v-if="pen.animates.length">
|
|
|
|
|
|
+ <div class="animations">
|
|
|
|
+ <template v-if="pen.animations.length">
|
|
<t-collapse
|
|
<t-collapse
|
|
v-model="openedCollapses"
|
|
v-model="openedCollapses"
|
|
:borderless="true"
|
|
:borderless="true"
|
|
:expand-on-row-click="false"
|
|
:expand-on-row-click="false"
|
|
>
|
|
>
|
|
- <t-collapse-panel v-for="(item, i) in pen.animates" :value="i">
|
|
|
|
|
|
+ <t-collapse-panel v-for="(item, i) in pen.animations" :value="i">
|
|
<template #header>
|
|
<template #header>
|
|
- <input v-model="item.name" />
|
|
|
|
|
|
+ <t-input v-model="item.name" autoWidth class="mr-8" />
|
|
|
|
+ <t-icon
|
|
|
|
+ v-if="isPlaying === i"
|
|
|
|
+ name="stop-circle-1"
|
|
|
|
+ class="hover primary"
|
|
|
|
+ style="font-size: 16px"
|
|
|
|
+ @click="stop"
|
|
|
|
+ />
|
|
|
|
+ <t-icon
|
|
|
|
+ v-else
|
|
|
|
+ name="play-circle"
|
|
|
|
+ class="hover"
|
|
|
|
+ style="font-size: 16px"
|
|
|
|
+ @click="play(i)"
|
|
|
|
+ />
|
|
</template>
|
|
</template>
|
|
<template #headerRightContent>
|
|
<template #headerRightContent>
|
|
- <t-popconfirm
|
|
|
|
- content="确认删除该动画吗"
|
|
|
|
- @confirm="pen.animates.splice(i, 1)"
|
|
|
|
- >
|
|
|
|
- <t-space size="small">
|
|
|
|
|
|
+ <t-space size="small">
|
|
|
|
+ <t-icon v-if="!pen.type" name="edit" class="hover mr-4" />
|
|
|
|
+
|
|
|
|
+ <t-popconfirm
|
|
|
|
+ content="确认删除该动画吗"
|
|
|
|
+ placement="left"
|
|
|
|
+ @confirm="pen.animations.splice(i, 1)"
|
|
|
|
+ >
|
|
<t-icon name="delete" class="hover" />
|
|
<t-icon name="delete" class="hover" />
|
|
- </t-space>
|
|
|
|
- </t-popconfirm>
|
|
|
|
|
|
+ </t-popconfirm>
|
|
|
|
+ </t-space>
|
|
|
|
+ </template>
|
|
|
|
+ <template v-if="pen.type"></template>
|
|
|
|
+ <template v-else>
|
|
|
|
+ <div class="form-item">
|
|
|
|
+ <label>动画类型</label>
|
|
|
|
+ <t-select
|
|
|
|
+ v-model="item.animate"
|
|
|
|
+ clearable
|
|
|
|
+ placeholder="动画"
|
|
|
|
+ :options="animateList"
|
|
|
|
+ @change="changeAnimate(item)"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-8">
|
|
|
|
+ <label>播放次数</label>
|
|
|
|
+ <t-input-number
|
|
|
|
+ v-model="item.animateCycle"
|
|
|
|
+ theme="column"
|
|
|
|
+ :min="1"
|
|
|
|
+ placeholder="无限"
|
|
|
|
+ title="缺省无限循环播放"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-8">
|
|
|
|
+ <label>结束状态</label>
|
|
|
|
+ <t-select
|
|
|
|
+ v-model="item.keepanimationstate"
|
|
|
|
+ placeholder="初始状态"
|
|
|
|
+ >
|
|
|
|
+ <t-option :key="false" :value="false" label="初始状态" />
|
|
|
|
+ <t-option :key="true" :value="true" label="当前状态" />
|
|
|
|
+ </t-select>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-8">
|
|
|
|
+ <label>线性播放</label>
|
|
|
|
+ <t-tooltip content="仅支持数字属性匀速线性播放" placement="top">
|
|
|
|
+ <t-select v-model="item.linear" placeholder="是">
|
|
|
|
+ <t-option :key="true" :value="true" label="是" />
|
|
|
|
+ <t-option :key="false" :value="false" label="否" />
|
|
|
|
+ </t-select>
|
|
|
|
+ </t-tooltip>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-8">
|
|
|
|
+ <label>下个动画</label>
|
|
|
|
+ <t-tree-select
|
|
|
|
+ v-model="item.nextAnimate"
|
|
|
|
+ :data="penTree"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="下个动画对象"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <div class="form-item mt-8">
|
|
|
|
+ <label>自动播放</label>
|
|
|
|
+ <t-switch
|
|
|
|
+ class="ml-8 mt-8"
|
|
|
|
+ size="small"
|
|
|
|
+ v-model="item.autoPlay"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
- <div class="form-item">
|
|
|
|
- <label>动画类型</label>
|
|
|
|
- <t-select
|
|
|
|
- v-model="item.animate"
|
|
|
|
- clearable
|
|
|
|
- placeholder="动画"
|
|
|
|
- :options="animateList"
|
|
|
|
- @change="changeAnimate(item)"
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
</t-collapse-panel>
|
|
</t-collapse-panel>
|
|
</t-collapse>
|
|
</t-collapse>
|
|
<div class="mt-8 px-16">
|
|
<div class="mt-8 px-16">
|
|
@@ -49,59 +115,127 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
-import { onBeforeMount, onUnmounted, reactive, ref } from 'vue';
|
|
|
|
|
|
+import { onBeforeMount, ref, toRaw } from 'vue';
|
|
|
|
+
|
|
|
|
+import { getPenTree } from '@/services/common';
|
|
|
|
+import { deepClone } from '@meta2d/core';
|
|
|
|
|
|
const { pen } = defineProps<{
|
|
const { pen } = defineProps<{
|
|
pen: any;
|
|
pen: any;
|
|
}>();
|
|
}>();
|
|
|
|
|
|
|
|
+const penTree: any = ref([]);
|
|
|
|
+
|
|
const openedCollapses = ref([0]);
|
|
const openedCollapses = ref([0]);
|
|
|
|
|
|
const animateList = [
|
|
const animateList = [
|
|
{
|
|
{
|
|
label: '闪烁',
|
|
label: '闪烁',
|
|
value: '闪烁',
|
|
value: '闪烁',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ visible: true,
|
|
|
|
+ duration: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ visible: false,
|
|
|
|
+ duration: 100,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '缩放',
|
|
label: '缩放',
|
|
value: '缩放',
|
|
value: '缩放',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ scale: 1.1,
|
|
|
|
+ duration: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ scale: 1,
|
|
|
|
+ duration: 400,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '旋转',
|
|
label: '旋转',
|
|
value: '旋转',
|
|
value: '旋转',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ rotate: 360,
|
|
|
|
+ duration: 1000,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '上下跳动',
|
|
label: '上下跳动',
|
|
value: '上下跳动',
|
|
value: '上下跳动',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ y: -10,
|
|
|
|
+ duration: 100,
|
|
|
|
+ },
|
|
|
|
+ { y: 0, duration: 100 },
|
|
|
|
+ { y: -10, duration: 200 },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '左右跳动',
|
|
label: '左右跳动',
|
|
value: '左右跳动',
|
|
value: '左右跳动',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ {
|
|
|
|
+ x: -10,
|
|
|
|
+ duration: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ x: 10,
|
|
|
|
+ duration: 80,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ x: -10,
|
|
|
|
+ duration: 50,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ x: 10,
|
|
|
|
+ duration: 30,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ x: 0,
|
|
|
|
+ duration: 300,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '颜色变化',
|
|
label: '颜色变化',
|
|
value: '颜色变化',
|
|
value: '颜色变化',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ { color: '#4583ff', duration: 200 },
|
|
|
|
+ { color: '#ff4000', duration: 200 },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '文字变化',
|
|
label: '文字变化',
|
|
value: '文字变化',
|
|
value: '文字变化',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ { text: '乐吾乐', duration: 200 },
|
|
|
|
+ { text: 'le5le', duration: 200 },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '状态变化',
|
|
label: '状态变化',
|
|
value: '状态变化',
|
|
value: '状态变化',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ { showChild: 0, duration: 200 },
|
|
|
|
+ { showChild: 1, duration: 200 },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '翻转',
|
|
label: '翻转',
|
|
value: '翻转',
|
|
value: '翻转',
|
|
- data: [],
|
|
|
|
|
|
+ data: [
|
|
|
|
+ { flipX: true, flipY: true, duration: 200 },
|
|
|
|
+ { flipX: false, flipY: false, duration: 200 },
|
|
|
|
+ ],
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '自定义',
|
|
label: '自定义',
|
|
@@ -110,23 +244,53 @@ const animateList = [
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+const isPlaying = ref(-1);
|
|
|
|
+
|
|
onBeforeMount(() => {
|
|
onBeforeMount(() => {
|
|
- if (!pen.animates) {
|
|
|
|
- pen.animates = [];
|
|
|
|
|
|
+ if (!pen.animations) {
|
|
|
|
+ pen.animations = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const p = meta2d.findOne(pen.id);
|
|
|
|
+ if (p?.calculative?.start) {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ isPlaying.value = p?.calculative?.playAnimate;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ penTree.value = getPenTree();
|
|
});
|
|
});
|
|
|
|
|
|
const addAnimate = () => {
|
|
const addAnimate = () => {
|
|
- openedCollapses.value.push(pen.animates.length);
|
|
|
|
- pen.animates.push({
|
|
|
|
- name: '动画' + (pen.animates.length + 1),
|
|
|
|
|
|
+ openedCollapses.value.push(pen.animations.length);
|
|
|
|
+ pen.animations.push({
|
|
|
|
+ name: '动画' + (pen.animations.length + 1),
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const changeAnimate = (item: any) => {
|
|
|
|
+ const animate: any = animateList.find((elem: any) => {
|
|
|
|
+ return elem.label === item.animate;
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ if (!animate) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ item.frames = deepClone(animate.data);
|
|
};
|
|
};
|
|
|
|
|
|
-const changeAnimate = (item: any) => {};
|
|
|
|
|
|
+const play = (i: number) => {
|
|
|
|
+ meta2d.startAnimate(pen.id, i);
|
|
|
|
+ isPlaying.value = i;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const stop = () => {
|
|
|
|
+ meta2d.stopAnimate(pen.id);
|
|
|
|
+ isPlaying.value = -1;
|
|
|
|
+};
|
|
</script>
|
|
</script>
|
|
<style lang="postcss" scoped>
|
|
<style lang="postcss" scoped>
|
|
-.animates {
|
|
|
|
|
|
+.animations {
|
|
height: 100%;
|
|
height: 100%;
|
|
|
|
|
|
.blank {
|
|
.blank {
|
|
@@ -139,11 +303,11 @@ const changeAnimate = (item: any) => {};
|
|
|
|
|
|
:deep(.t-collapse) {
|
|
:deep(.t-collapse) {
|
|
.t-collapse-panel__header {
|
|
.t-collapse-panel__header {
|
|
- input {
|
|
|
|
- outline: none;
|
|
|
|
- border: none;
|
|
|
|
- background: none;
|
|
|
|
- color: var(--color);
|
|
|
|
|
|
+ .t-input {
|
|
|
|
+ border-color: transparent;
|
|
|
|
+ &:hover {
|
|
|
|
+ border-color: var(--color-border-input);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|