Browse Source

fix:缺陷#28 动画名不指定的场合,能够成功添加动画,不提示错误信息

Wind-Breaker1 1 year ago
parent
commit
0d8213dd69
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/views/components/PenAnimates.vue

+ 12 - 1
src/views/components/PenAnimates.vue

@@ -16,6 +16,8 @@
                 class="mr-8"
                 style="max-width: 60px"
                 @change="changeAnimateName($event, item)"
+                @blur="checkAnimateName(item)"
+                @focus="bakAnimateName(item.name)"
               />
               <t-icon
                 v-if="isPlaying === i"
@@ -233,6 +235,7 @@ import { MessagePlugin } from 'tdesign-vue-next';
 const props = defineProps<{
   pen: any;
 }>();
+let animateNameBak = '';
 function changeAnimateAutoPlay(value, item) {
   if (value) {
     props.pen.autoPlay = true;
@@ -254,7 +257,15 @@ function changeAnimateAutoPlay(value, item) {
     }
   }
 }
-
+const checkAnimateName = (item:any) => {
+  if(!item.name) {
+    MessagePlugin.warning('动画名不能为空!');
+    item.name = animateNameBak;
+  }
+}
+const bakAnimateName = (name:string) => {
+  animateNameBak = name;
+}
 const changeAnimateName = (event, item) => {
   let result = props.pen.animations.filter(
     (animation) => animation.name === event