|
@@ -1,76 +1,189 @@
|
|
-import axios from './instance'
|
|
|
|
-import { params } from '@/env'
|
|
|
|
-import {
|
|
|
|
|
|
+import axios from "./instance";
|
|
|
|
+import { params } from "@/env";
|
|
|
|
+import {
|
|
AM_MODEL_LIST,
|
|
AM_MODEL_LIST,
|
|
INSERT_AM_MODEL,
|
|
INSERT_AM_MODEL,
|
|
UPDATE_AM_MODEL,
|
|
UPDATE_AM_MODEL,
|
|
DELETE_AM_MODEL,
|
|
DELETE_AM_MODEL,
|
|
-} from './constant'
|
|
|
|
|
|
+} from "./constant";
|
|
|
|
|
|
-type ServiceAnimationModel = AnimationModel
|
|
|
|
-
|
|
|
|
-export interface AnimationAction {
|
|
|
|
- id: string,
|
|
|
|
- title: string,
|
|
|
|
- url: string,
|
|
|
|
|
|
+type ServiceAnimationModel = AnimationModel;
|
|
|
|
|
|
|
|
+export interface AnimationAction {
|
|
|
|
+ id: string;
|
|
|
|
+ title: string;
|
|
|
|
+ url: string;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+export type AnimationModelAction = {
|
|
|
|
+ amplitude: number;
|
|
|
|
+ speed: number;
|
|
|
|
+ time: number;
|
|
|
|
+ duration: number;
|
|
|
|
+ id: string;
|
|
|
|
+ name: string
|
|
|
|
+};
|
|
|
|
+export type AnimationModelSubtitle = {
|
|
|
|
+ content: string;
|
|
|
|
+ duration: number;
|
|
|
|
+ time: number;
|
|
|
|
+ id: string;
|
|
|
|
+ background: string;
|
|
|
|
+ name: string
|
|
|
|
+};
|
|
|
|
+export type AnimationModelFrame = {
|
|
|
|
+ time: number;
|
|
|
|
+ id: string;
|
|
|
|
+ name: string
|
|
|
|
+ duration?: number;
|
|
|
|
+};
|
|
|
|
+export type AnimationModelPath = {
|
|
|
|
+ reverse: boolean;
|
|
|
|
+ pathId: string;
|
|
|
|
+ time: number;
|
|
|
|
+ duration: number;
|
|
|
|
+ id: string;
|
|
|
|
+ name: string
|
|
|
|
+};
|
|
|
|
+
|
|
export interface AnimationModel {
|
|
export interface AnimationModel {
|
|
- id: string,
|
|
|
|
- title: string,
|
|
|
|
- url: string,
|
|
|
|
- showTitle: boolean
|
|
|
|
- fontSize: number
|
|
|
|
- globalVisibility: boolean
|
|
|
|
- visibilityRange: number
|
|
|
|
|
|
+ id: string;
|
|
|
|
+ title: string;
|
|
|
|
+ url: string;
|
|
|
|
+ showTitle: boolean;
|
|
|
|
+ fontSize: number;
|
|
|
|
+ globalVisibility: boolean;
|
|
|
|
+ visibilityRange: number;
|
|
|
|
+ frames: AnimationModelFrame[];
|
|
|
|
+ actions: AnimationModelAction[];
|
|
|
|
+ subtitles: AnimationModelSubtitle[];
|
|
|
|
+ paths: AnimationModelPath[];
|
|
}
|
|
}
|
|
|
|
|
|
-export type AnimationModels = AnimationModel[]
|
|
|
|
|
|
+export type AnimationModels = AnimationModel[];
|
|
|
|
|
|
const serviceToLocal = (serviceAM: ServiceAnimationModel): AnimationModel => ({
|
|
const serviceToLocal = (serviceAM: ServiceAnimationModel): AnimationModel => ({
|
|
...serviceAM,
|
|
...serviceAM,
|
|
-})
|
|
|
|
|
|
+});
|
|
|
|
|
|
const localToService = (am: AnimationModel): ServiceAnimationModel => ({
|
|
const localToService = (am: AnimationModel): ServiceAnimationModel => ({
|
|
...am,
|
|
...am,
|
|
-})
|
|
|
|
|
|
+});
|
|
|
|
|
|
export const fetchAnimationModels = async () => {
|
|
export const fetchAnimationModels = async () => {
|
|
return [
|
|
return [
|
|
- { id: '1', title: '模型1', url: '' },
|
|
|
|
- { id: '2', title: '模型2', url: '' },
|
|
|
|
- { id: '3', title: '模型3', url: '' },
|
|
|
|
- ] as AnimationModel[]
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- const ams = await axios.get<ServiceAnimationModel[]>(AM_MODEL_LIST, { params: { caseId: params.caseId } })
|
|
|
|
- return ams.map(serviceToLocal)
|
|
|
|
-}
|
|
|
|
|
|
+ {
|
|
|
|
+ id: "1",
|
|
|
|
+ title: "模型1",
|
|
|
|
+ url: "",
|
|
|
|
+ frames: [
|
|
|
|
+ { time: 10, name: "帧1" },
|
|
|
|
+ { time: 20, name: "帧2" },
|
|
|
|
+ { time: 30, name: "帧3" },
|
|
|
|
+ ],
|
|
|
|
+ actions: [
|
|
|
|
+ { time: 10, duration: 3, name: "动作1" },
|
|
|
|
+ { time: 20, duration: 5, name: "动作2" },
|
|
|
|
+ { time: 30, duration: 3, name: "动作3" },
|
|
|
|
+ ],
|
|
|
|
+ subtitles: [
|
|
|
|
+ { time: 0, duration: 15, name: "字幕1" },
|
|
|
|
+ { time: 20, duration: 15, name: "字幕2" },
|
|
|
|
+ { time: 40, duration: 30, name: "字幕3" },
|
|
|
|
+ ],
|
|
|
|
+ paths: [
|
|
|
|
+ { time: 0, duration: 15, name: "路径1" },
|
|
|
|
+ { time: 20, duration: 15, name: "路径2" },
|
|
|
|
+ { time: 40, duration: 30, name: "路径3" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: "2",
|
|
|
|
+ title: "模型2",
|
|
|
|
+ url: "",
|
|
|
|
+ frames: [
|
|
|
|
+ { time: 10, name: "帧1" },
|
|
|
|
+ { time: 20, name: "帧2" },
|
|
|
|
+ { time: 30, name: "帧3" },
|
|
|
|
+ ],
|
|
|
|
+ actions: [
|
|
|
|
+ { time: 10, duration: 3, name: "动作1" },
|
|
|
|
+ { time: 20, duration: 5, name: "动作2" },
|
|
|
|
+ { time: 30, duration: 3, name: "动作3" },
|
|
|
|
+ ],
|
|
|
|
+ subtitles: [
|
|
|
|
+ { time: 0, duration: 15, name: "字幕1" },
|
|
|
|
+ { time: 20, duration: 15, name: "字幕2" },
|
|
|
|
+ { time: 40, duration: 30, name: "字幕3" },
|
|
|
|
+ ],
|
|
|
|
+ paths: [
|
|
|
|
+ { time: 0, duration: 15, name: "路径1" },
|
|
|
|
+ { time: 20, duration: 15, name: "路径2" },
|
|
|
|
+ { time: 40, duration: 30, name: "路径3" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: "3",
|
|
|
|
+ title: "模型3",
|
|
|
|
+ url: "",
|
|
|
|
+ frames: [
|
|
|
|
+ { time: 10, name: "帧1" },
|
|
|
|
+ { time: 20, name: "帧2" },
|
|
|
|
+ { time: 30, name: "帧3" },
|
|
|
|
+ ],
|
|
|
|
+ actions: [
|
|
|
|
+ { time: 10, duration: 3, name: "动作1" },
|
|
|
|
+ { time: 20, duration: 5, name: "动作2" },
|
|
|
|
+ { time: 30, duration: 3, name: "动作3" },
|
|
|
|
+ ],
|
|
|
|
+ subtitles: [
|
|
|
|
+ { time: 0, duration: 15, name: "字幕1" },
|
|
|
|
+ { time: 20, duration: 15, name: "字幕2" },
|
|
|
|
+ { time: 40, duration: 30, name: "字幕3" },
|
|
|
|
+ ],
|
|
|
|
+ paths: [
|
|
|
|
+ { time: 0, duration: 15, name: "路径1" },
|
|
|
|
+ { time: 20, duration: 15, name: "路径2" },
|
|
|
|
+ { time: 40, duration: 30, name: "路径3" },
|
|
|
|
+ ],
|
|
|
|
+ },
|
|
|
|
+ ] as unknown as AnimationModel[];
|
|
|
|
+
|
|
|
|
+ const ams = await axios.get<ServiceAnimationModel[]>(AM_MODEL_LIST, {
|
|
|
|
+ params: { caseId: params.caseId },
|
|
|
|
+ });
|
|
|
|
+ return ams.map(serviceToLocal);
|
|
|
|
+};
|
|
|
|
|
|
export const fetchAnimationActions = async () => {
|
|
export const fetchAnimationActions = async () => {
|
|
return [
|
|
return [
|
|
- { id: '1', title: '模型1', url: '' },
|
|
|
|
- { id: '2', title: '模型2', url: '' },
|
|
|
|
- { id: '3', title: '模型3', url: '' },
|
|
|
|
- { id: '2', title: '模型2', url: '' },
|
|
|
|
- { id: '3', title: '模型3', url: '' },
|
|
|
|
- { id: '2', title: '模型2', url: '' },
|
|
|
|
- { id: '3', title: '模型3', url: '' },
|
|
|
|
- ]
|
|
|
|
-}
|
|
|
|
|
|
+ { id: "1", title: "模型1", url: "" },
|
|
|
|
+ { id: "2", title: "模型2", url: "" },
|
|
|
|
+ { id: "3", title: "模型3", url: "" },
|
|
|
|
+ { id: "2", title: "模型2", url: "" },
|
|
|
|
+ { id: "3", title: "模型3", url: "" },
|
|
|
|
+ { id: "2", title: "模型2", url: "" },
|
|
|
|
+ { id: "3", title: "模型3", url: "" },
|
|
|
|
+ ];
|
|
|
|
+};
|
|
|
|
|
|
export const postInsertAnimationModel = async (am: AnimationModel) => {
|
|
export const postInsertAnimationModel = async (am: AnimationModel) => {
|
|
- const addData = { ...localToService(am), caseId: params.caseId, id: undefined }
|
|
|
|
- const serviceData = await axios.post<ServiceAnimationModel>(INSERT_AM_MODEL, addData)
|
|
|
|
- return serviceToLocal(serviceData)
|
|
|
|
-}
|
|
|
|
|
|
+ const addData = {
|
|
|
|
+ ...localToService(am),
|
|
|
|
+ caseId: params.caseId,
|
|
|
|
+ id: undefined,
|
|
|
|
+ };
|
|
|
|
+ const serviceData = await axios.post<ServiceAnimationModel>(
|
|
|
|
+ INSERT_AM_MODEL,
|
|
|
|
+ addData
|
|
|
|
+ );
|
|
|
|
+ return serviceToLocal(serviceData);
|
|
|
|
+};
|
|
|
|
|
|
export const postUpdateAnimationModel = async (guide: AnimationModel) => {
|
|
export const postUpdateAnimationModel = async (guide: AnimationModel) => {
|
|
- return axios.post<undefined>(UPDATE_AM_MODEL, { ...localToService(guide)})
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-export const postDeleteAnimationModel = (id: AnimationModel['id']) => {
|
|
|
|
- return axios.post<undefined>(DELETE_AM_MODEL, { id: Number(id) })
|
|
|
|
-}
|
|
|
|
|
|
+ return axios.post<undefined>(UPDATE_AM_MODEL, { ...localToService(guide) });
|
|
|
|
+};
|
|
|
|
|
|
-
|
|
|
|
|
|
+export const postDeleteAnimationModel = (id: AnimationModel["id"]) => {
|
|
|
|
+ return axios.post<undefined>(DELETE_AM_MODEL, { id: Number(id) });
|
|
|
|
+};
|