index.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { Dict_Apis, getPathname } from "@/dict";
  2. import { UploadController } from "@queenjs/controllers";
  3. import { ModuleRoot } from "queenjs";
  4. import components from "../components";
  5. import { CompUICtrl } from "../controllers/CompUICtrl";
  6. import { HistoryCtrl } from "../controllers/HistoryCtrl";
  7. import { ImagePickController } from "../controllers/ImagePickerController";
  8. import { createProxy } from "../objects/ProxyStore/create";
  9. import { editActions } from "./actions/edit";
  10. import { ImgCompActions } from "./actions/image";
  11. import { initActions } from "./actions/init";
  12. import { helpers } from "./helpers";
  13. import { editHelpers } from "./helpers/edit";
  14. import { wxController } from "@/controllers/wxController";
  15. import { ImageCropperCtrl } from "../controllers/CropperCtrl";
  16. import { CtxMenuCtrl } from "../controllers/CtxMenuCtrl";
  17. import { DragAddCtrl } from "../controllers/DragAddCtrl";
  18. import { EditorCtrl } from "../controllers/EditorCtrl";
  19. import { MediaCtrl } from "../controllers/MediaCtrl/indext";
  20. import { PreviewCtrl } from "../controllers/PreviewCtrl";
  21. import { ScreenCtrl } from "../controllers/ScreenCtrl";
  22. import { SelectCtrl } from "../controllers/SelectCtrl";
  23. import { CompObject } from "../controllers/SelectCtrl/compObj";
  24. import { TextEditorCtrl } from "../controllers/TextEditorCtrl";
  25. import { manualActions } from "./actions/editWithManualHistory";
  26. import { https } from "./https";
  27. import { store } from "./stores";
  28. import { history } from "../objects/DesignTemp/factory";
  29. import { PageCtrl } from "../controllers/PageCtrl";
  30. import { PropsCtrl } from "../controllers/PropsCtrol";
  31. export class EditorModule extends ModuleRoot {
  32. config = this.setConfig({
  33. httpConfig: {
  34. baseURL: Dict_Apis.promotion,
  35. },
  36. });
  37. components = this.useComponents(components);
  38. actions = this.createActions([
  39. initActions,
  40. editActions,
  41. ImgCompActions,
  42. manualActions,
  43. ]);
  44. https = this.createHttps(https);
  45. store = this.createStore(store);
  46. helper = this.createHelper([helpers, editHelpers]);
  47. controls = {
  48. uploader: new UploadController({
  49. httpConfig: {
  50. baseURL: Dict_Apis.queentree,
  51. },
  52. dir: "queenshow",
  53. }),
  54. wxCtrl: new wxController({
  55. url: `${Dict_Apis.promotion}/wechat/share?`,
  56. }),
  57. dragAddCtrl: new DragAddCtrl(this),
  58. historyCtrl: new HistoryCtrl(this),
  59. pickCtrl: new ImagePickController(),
  60. compUICtrl: new CompUICtrl(this),
  61. selectCtrl: new SelectCtrl(this),
  62. cropCtrl: new ImageCropperCtrl(this),
  63. mediaCtrl: new MediaCtrl(this),
  64. textEditorCtrl: new TextEditorCtrl(this),
  65. screenCtrl: new ScreenCtrl(this),
  66. editorCtrl: new EditorCtrl(this),
  67. menuCtrl: new CtxMenuCtrl(this),
  68. previewCtrl: new PreviewCtrl(this),
  69. pageCtrl: new PageCtrl(this),
  70. propsCtrl: new PropsCtrl(this),
  71. };
  72. compObjsMap = new Map<string, CompObject>();
  73. onReady() {
  74. this.actions.init();
  75. this.controls.uploader.ignoreDashField = true;
  76. this.controls.screenCtrl.initEvent();
  77. this.controls.menuCtrl.initEvent();
  78. this.controls.propsCtrl.initEvents();
  79. }
  80. jumpIndexHtml(route = "#/") {
  81. const _params = new URLSearchParams(decodeURIComponent(location.search));
  82. const host = _params.get("host");
  83. let link = `${location.origin}${getPathname()}index.html?host=${host}${route}`;
  84. // if (location.host == "www.infish.cn") {
  85. // link = `${location.origin}${location.pathname}/projects/queenshowv1/index.html?host=${host}${route}`;
  86. // }
  87. location.href = link;
  88. }
  89. get selected () {
  90. return this.controls.selectCtrl.gizmo.state.transform.selected;
  91. }
  92. get gizmo() {
  93. return this.controls.selectCtrl.gizmo;
  94. }
  95. get history() {
  96. return history;
  97. }
  98. }