bill 4 hónapja
szülő
commit
fdb775ea4b

BIN
public/animation/Man.glb


+ 0 - 16
src/api/animation.ts

@@ -104,22 +104,6 @@ const localToService = (am: AnimationModel): ServiceAnimationModel => ({
 });
 
 export const fetchAnimationModels = async () => {
-  return [
-    {
-      id: "1",
-      title: "kid",
-      url: "/animation/kid.glb",
-      showTitle: true,
-      fontSize: 12,
-      globalVisibility: true,
-      visibilityRange: 100,
-      frames: [],
-      actions: [],
-      subtitles: [],
-      paths: [],
-    },
-  ] as AnimationModel[];
-
   const ams = await axios.get<ServiceAnimationModel[]>(AM_MODEL_LIST, {
     params: { caseId: params.caseId },
   });

+ 4 - 4
src/api/constant.ts

@@ -125,7 +125,7 @@ export const MATERIAL_GROUP_LIST = `/service/manage/dict/getByKey/media-library`
 
 
 // 动画模块
-export const AM_MODEL_LIST = `${namespace}/fusionGuide/allList`
-export const INSERT_AM_MODEL = `${namespace}/fusionGuide/add`
-export const UPDATE_AM_MODEL = `${namespace}/fusionGuide/update`
-export const DELETE_AM_MODEL = `${namespace}/fusionGuide/delete`
+export const AM_MODEL_LIST = `${namespace}/caseAnimation/list`
+export const INSERT_AM_MODEL = `${namespace}/caseAnimation/addOrUpdate`
+export const UPDATE_AM_MODEL = `${namespace}/caseAnimation/addOrUpdate`
+export const DELETE_AM_MODEL = `${namespace}/caseAnimation/delete`

+ 1 - 1
src/api/material.ts

@@ -77,7 +77,7 @@ export const fetchMaterialPage = async (params: MaterialPageProps) => {
   }
 
   const testUrls = [
-    'dog.glb', 'man--running.glb', 'man--walk.glb', 'Soldier.glb', 'Xbot.glb'
+    'dog.glb', 'man--running.glb', 'man--walk.glb', 'Soldier.glb', 'Xbot.glb', 'Man.glb'
   ]
   nm.list.unshift(
     ...testUrls.map((item, ndx) => ({

+ 12 - 5
src/sdk/association/animation.ts

@@ -392,6 +392,7 @@ watch(play, (_a, _b, onCleanup) => {
 
 export const currentTime = ref(0);
 export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
+  console.error('join animation-group')
   animationGroup = sdk.createAnimationGroup();
 
   watchEffect(() => {
@@ -405,9 +406,11 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
   watch(
     () => [...ams.value],
     (newv, oldv = []) => {
+      console.log('diffam', newv, oldv)
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addAM);
-    }
+    },
+    {immediate: true}
   );
 
   watch(
@@ -415,7 +418,8 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
     (newv, oldv = []) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addFrame);
-    }
+    },
+    {immediate: true}
   );
 
   watch(
@@ -423,7 +427,8 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
     (newv, oldv = []) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addAction);
-    }
+    },
+    {immediate: true}
   );
 
   watch(
@@ -431,14 +436,16 @@ export const associationAnimation = (sdk: SDK, el: HTMLDivElement) => {
     (newv, oldv = []) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addPath);
-    }
+    },
+    {immediate: true}
   );
   watch(
     () => ams.value.flatMap((am) => am.subtitles),
     (newv, oldv = []) => {
       const { added } = diffArrayChange(newv, oldv);
       added.forEach(addSubtitle);
-    }
+    },
+    {immediate: true}
   );
 
   let cleanupMap: Record<string, () => void> = {}

+ 7 - 1
src/store/animation.ts

@@ -20,6 +20,7 @@ import type {
   AnimationModel,
   AnimationModels,
 } from "@/api";
+import { inRevise } from "bill/utils";
 export type {
   AnimationModelAction,
   AnimationModelFrame,
@@ -50,7 +51,7 @@ export const createAnimationModel = (
 let bcAms: AnimationModels = [];
 export const getBackupAnimationModels = () => bcAms;
 export const backupAnimationModels = () => {
-  bcAms = ams.value.map((am) => ({ ...am }));
+  bcAms = JSON.parse(JSON.stringify(ams.value))
 };
 export const addAnimationModel = addStoreItem(ams, postInsertAnimationModel);
 export const updateAnimationModels = updateStoreItem(
@@ -81,7 +82,12 @@ export const saveAnimationModels = saveStoreItems(
 export const autoSaveAnimationModel = autoSetModeCallback([ams], {
   backup: togetherCallback([backupAnimationModels]),
   recovery: togetherCallback([recoverAnimationModels]),
+  isUpdate: (newv) => {
+    console.error('newv')
+    return inRevise(newv, getBackupAnimationModels())
+  },
   save: async () => {
+    console.error('savesave')
     await saveAnimationModels();
   },
 });

+ 1 - 0
src/store/sys.ts

@@ -137,6 +137,7 @@ export const autoSetModeCallback = <T extends object>(
 
   const handler = (newv: UnwrapRef<T>, oldv?: UnwrapRef<T>) => {
     if (isSave || isUnset || isLeaveIng) return;
+    console.log('change?', newv, oldv)
     if (!setting.isUpdate || setting.isUpdate(newv, oldv)) {
       isEdit.value || enterEdit();
       isOld.value || enterOld();

+ 2 - 3
src/views/animation/index.vue

@@ -47,7 +47,7 @@ import BottomPano from "@/layout/bottom-pano.vue";
 import router from "@/router";
 import { enterEdit } from "@/store";
 import { useViewStack } from "@/hook";
-import { ams, AnimationModel, initialAnimationModels } from "@/store/animation";
+import { ams, AnimationModel, autoSaveAnimationModel } from "@/store/animation";
 import { computed, nextTick, reactive, ref, watch, watchEffect } from "vue";
 import { Active } from "./type";
 import { getAddTLItemAttr } from "@/components/drawing-time-line/check";
@@ -65,8 +65,7 @@ import {
 } from "@/env";
 
 enterEdit(() => router.back());
-initialAnimationModels();
-// useViewStack(autoSaveAnimationModel);
+useViewStack(autoSaveAnimationModel);
 useViewStack(() =>
   mergeFuns(
     showBottomBarStack.push(ref(true)),

+ 2 - 1
src/views/animation/left.vue

@@ -68,7 +68,8 @@ const emit = defineEmits<{
 }>();
 
 const activeKey = ref("model");
-const { updateSelect, selects: selectAMs, unSelects } = useSelects(ams, true);
+const { updateSelect, selects: selectAMs, unSelects, all } = useSelects(ams, true);
+all.value = true;
 watchEffect(() => {
   emit("changeSelect", { select: selectAMs.value, unSelect: unSelects.value });
 });