index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <RightFillPano class="animation-right" v-if="activeAttrib?.key !== 'frames'">
  3. <AM
  4. v-if="!activeAttrib || !~activeAttrib.ndx"
  5. :am="am"
  6. @add-frame="emit('addFrame')"
  7. @add-path="emit('addPath')"
  8. @add-subtitle="emit('addSubtitle')"
  9. @apply-global="(k) => emit('applyGlobal', k)"
  10. />
  11. <template v-else>
  12. <ui-icon
  13. style="font-size: 16px"
  14. type="close"
  15. class="close"
  16. ctrl
  17. @click="emit('update:activeAttrib', undefined)"
  18. />
  19. <component
  20. @updateDuration="setDuration"
  21. :is="(comps[activeAttrib.key] as any)"
  22. :data="am[activeAttrib.key][activeAttrib.ndx]"
  23. />
  24. </template>
  25. </RightFillPano>
  26. <Frame
  27. :data="am[activeAttrib.key][activeAttrib.ndx]"
  28. :frame-action="frameAction"
  29. @change-frame-action="(d) => emit('changeFrameAction', d)"
  30. v-else
  31. />
  32. </template>
  33. <script lang="ts" setup>
  34. import { RightFillPano } from "@/layout";
  35. import { Active } from "../type";
  36. import AM from "./am.vue";
  37. import Action from "./action.vue";
  38. import Frame from "./frame.vue";
  39. import Path from "./path.vue";
  40. import Subtitle from "./subtitle.vue";
  41. import { checkTLItem } from "@/components/drawing-time-line/check";
  42. import { Message } from "bill/expose-common";
  43. import { AnimationModel, AnimationModelFrame } from "@/store/animation";
  44. const props = defineProps<{
  45. am: AnimationModel;
  46. activeAttrib?: Active;
  47. frameAction?: string;
  48. }>();
  49. const emit = defineEmits<{
  50. (e: "update:activeAttrib", d: undefined): void;
  51. (e: "addFrame" | "addPath" | "addSubtitle"): void;
  52. (e: "applyGlobal", d: keyof AnimationModel): void;
  53. (e: "changeFrameAction", d: { action?: string; frame: AnimationModelFrame }): void;
  54. }>();
  55. const comps = {
  56. actions: Action,
  57. paths: Path,
  58. subtitles: Subtitle,
  59. };
  60. const title = {
  61. actions: "动作",
  62. paths: "路径",
  63. subtitles: "字幕",
  64. frames: "",
  65. };
  66. const setDuration = (dur: number) => {
  67. const ndx = props.activeAttrib!.ndx;
  68. const items = props.am[props.activeAttrib!.key];
  69. const cur = items[ndx];
  70. if (!checkTLItem(items, { ...cur, duration: dur }, ndx)) {
  71. Message.error("当前时间已存在其他" + title[props.activeAttrib!.key]);
  72. } else {
  73. cur.duration = dur;
  74. }
  75. };
  76. </script>
  77. <style lang="scss">
  78. .close {
  79. position: absolute;
  80. right: 21px;
  81. top: 26px;
  82. z-index: 9;
  83. }
  84. .animation-right .ui-editor-toolbox {
  85. padding-top: 0;
  86. .ant-tabs-tab {
  87. font-size: 16px;
  88. padding: 16px 10px;
  89. }
  90. }
  91. </style>