editor.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { queenApi } from "queenjs";
  2. import { ResourceModule } from "..";
  3. import { cloneDeep } from "lodash";
  4. export const editorActions = ResourceModule.action({
  5. async queryTplsDetail(id) {
  6. const res = await this.https.queryTplsDetail(id);
  7. this.store.setSourceDetail(res.result);
  8. this.actions.initTreeData();
  9. },
  10. initTreeData() {
  11. const data: any = [];
  12. this.store.sourceDetail.webEditor?.meshSlots?.forEach((mesh: any) => {
  13. mesh.children = this.store.sourceDetail.webEditor?.matSlots?.filter(
  14. (mat: any) => mat.meshSlotId == mesh.Id
  15. );
  16. data.push(cloneDeep(mesh));
  17. });
  18. this.store.setTreeData(data);
  19. },
  20. async submitRender(id: string, images: any, videos: any) {
  21. queenApi.showLoading("任务提交中");
  22. console.log("iamges=>", images, "videos->", videos);
  23. try {
  24. await this.https.sourceGen({
  25. genRequest: {
  26. templateId: id,
  27. videos: videos,
  28. images: images,
  29. matSlots: this.store.matSlots,
  30. meshSlots: this.store.meshSlots,
  31. },
  32. });
  33. queenApi.messageSuccess("任务提交成功");
  34. return true;
  35. } catch (error) {
  36. console.error(error);
  37. } finally {
  38. queenApi.hideLoading();
  39. }
  40. },
  41. });