bill преди 4 месеца
родител
ревизия
cf49957c89
променени са 4 файла, в които са добавени 14 реда и са изтрити 11 реда
  1. 2 1
      src/api/animation.ts
  2. 8 8
      src/sdk/association/animation.ts
  3. 3 2
      src/store/animation.ts
  4. 1 0
      src/utils/store-help.ts

+ 2 - 1
src/api/animation.ts

@@ -140,7 +140,8 @@ export const postInsertAnimationModel = async (am: AnimationModel) => {
 
 export const postUpdateAnimationModel = async (guide: AnimationModel) => {
   console.log('set', guide)
-  return axios.post<undefined>(UPDATE_AM_MODEL, { ...localToService(guide) });
+  const data = await axios.post<ServiceAnimationModel>(UPDATE_AM_MODEL, { ...localToService(guide) });
+  return {...guide, id: data.id}
 };
 
 export const postDeleteAnimationModel = (id: AnimationModel["id"]) => {

+ 8 - 8
src/sdk/association/animation.ts

@@ -55,6 +55,7 @@ export const addAM = (data: AnimationModel): Promise<AnimationModel3D> => {
         Object.values(des.actions || {}).forEach((frame) => frame.destroy());
         Object.values(des.paths || {}).forEach((frame) => frame.destroy());
         des.am?.destroy();
+        console.error('destory', key, data)
         delete amMap[key];
       } else if (!amMap[key]) {
         amMap[key] = {
@@ -267,7 +268,6 @@ export const addPath = (
       amMap[key]?.paths[data.id]?.changeDuration(data.duration)
     ),
     watch(path, (p) => {
-      console.log('0.0 changePath', p)
       const path = toRaw(p)
       path && amMap[key]?.paths[data.id]?.changePath(path);
 
@@ -456,11 +456,11 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
   watch(
     () => [...ams.value],
     (newv, oldv = []) => {
-      console.log("diffam", newv, oldv);
-      const { added } = diffArrayChange(newv, oldv);
+      const { added, deleted } = diffArrayChange(newv, oldv);
+      console.log("diffam", added, deleted, ams.value);
       added.forEach(addAM);
     },
-    { immediate: true }
+    { immediate: true, deep: true }
   );
 
   watch(
@@ -469,7 +469,7 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addFrame);
     },
-    { immediate: true }
+    { immediate: true, deep: true }
   );
 
   watch(
@@ -478,7 +478,7 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addAction);
     },
-    { immediate: true }
+    { immediate: true, deep: true }
   );
 
   watch(
@@ -487,7 +487,7 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addPath);
     },
-    { immediate: true }
+    { immediate: true, deep: true }
   );
   watch(
     () => ams.value.flatMap((am) => am.subtitles),
@@ -495,7 +495,7 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addSubtitle);
     },
-    { immediate: true }
+    { immediate: true, deep: true }
   );
 
   let cleanupMap: Record<string, () => void> = {};

+ 3 - 2
src/store/animation.ts

@@ -1,5 +1,5 @@
 import { ref } from "vue";
-import { autoSetModeCallback, createTemploraryID } from "./sys";
+import { autoSetModeCallback, createTemploraryID, isTemploraryID } from "./sys";
 import {
   fetchAnimationActions,
   fetchAnimationModels,
@@ -21,6 +21,7 @@ import type {
   AnimationModels,
 } from "@/api";
 import { inRevise } from "bill/utils";
+import { uuid } from "@/components/drawing/hook";
 export type {
   AnimationModelAction,
   AnimationModelFrame,
@@ -41,6 +42,7 @@ export const createAnimationModel = (
   fontSize: 12,
   globalVisibility: true,
   visibilityRange: 12,
+  key: uuid(),
   subtitles: [],
   actions: [],
   frames: [],
@@ -86,7 +88,6 @@ export const autoSaveAnimationModel = autoSetModeCallback([ams], {
     return inRevise(newv, getBackupAnimationModels())
   },
   save: async () => {
-    console.error('savesave')
     await saveAnimationModels();
   },
 });

+ 1 - 0
src/utils/store-help.ts

@@ -84,6 +84,7 @@ export function updateStoreItem<
     if (storeItem) {
       Object.assign(storeItem, item);
     }
+    return item
   };
 }