index.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { BusController } from "@/controllers/natsController";
  2. import { TreeController } from "@/controllers/queentreeController";
  3. import { Dict_Apis } from "@/dict";
  4. import { PageListController, UploadController } from "@queenjs/controllers";
  5. import { ModuleRoot } from "queenjs";
  6. import { actions } from "./actions";
  7. import { compoents } from "./components";
  8. import { helper } from "./helper";
  9. import { http } from "./http";
  10. import { store } from "./store";
  11. export class ResourceModule extends ModuleRoot {
  12. config = this.setConfig({
  13. httpConfig: {
  14. baseURL: Dict_Apis.promotion,
  15. },
  16. });
  17. actions = this.createActions(actions);
  18. components = this.useComponents(compoents);
  19. store = this.createStore([store]);
  20. https = this.createHttps(http);
  21. helper = this.createHelper(helper);
  22. controls = {
  23. uploader: new UploadController({
  24. httpConfig: {
  25. baseURL: Dict_Apis.queentree,
  26. },
  27. dir: "queenshow",
  28. }),
  29. promotionListCtrl: new PageListController(this.config?.httpConfig),
  30. materialListCtrl: new PageListController(this.config?.httpConfig),
  31. matTempListCtrl: new PageListController(this.config?.httpConfig),
  32. renderTaskListCtrl: new PageListController(this.config?.httpConfig),
  33. materialImageListCtrl: new PageListController(this.config?.httpConfig),
  34. materialVideoListCtrl: new PageListController(this.config?.httpConfig),
  35. // 用户资源
  36. custImageListCtrl: new PageListController(this.config?.httpConfig),
  37. custVideoListCtrl: new PageListController(this.config?.httpConfig),
  38. custCompListCtrl: new PageListController(this.config?.httpConfig),
  39. custTextListCtrl: new PageListController(this.config?.httpConfig),
  40. custShapeListCtrl: new PageListController(this.config?.httpConfig),
  41. // 平台资源
  42. sysTplListCtrl: new PageListController(this.config?.httpConfig),
  43. sysImageListCtrl: new PageListController(this.config?.httpConfig),
  44. sysVideoListCtrl: new PageListController(this.config?.httpConfig),
  45. sysCompListCtrl: new PageListController<compType, any>(
  46. this.config?.httpConfig
  47. ),
  48. sysShapeListCtrl: new PageListController<compType, any>(
  49. this.config?.httpConfig
  50. ),
  51. sysTextListCtrl: new PageListController<compType, any>(
  52. this.config?.httpConfig
  53. ),
  54. };
  55. natsBus = new BusController();
  56. treeController = new TreeController(this.natsBus);
  57. onReady() {
  58. this.controls.promotionListCtrl.setCrudPrefix("/h5");
  59. this.controls.promotionListCtrl.state.size = 12;
  60. this.controls.materialListCtrl.setCrudPrefix("/source");
  61. this.controls.materialListCtrl.state.size = 24;
  62. this.controls.renderTaskListCtrl.setCrudPrefix("/sourceGen");
  63. this.controls.renderTaskListCtrl.state.size = 24;
  64. this.controls.matTempListCtrl.setCrudPrefix("/tpls");
  65. this.controls.matTempListCtrl.state.size = 20;
  66. this.controls.materialImageListCtrl.setCrudPrefix("/source");
  67. this.controls.materialImageListCtrl.state.size = 18;
  68. this.controls.materialImageListCtrl.state.query = { fileType: "image" };
  69. this.controls.materialVideoListCtrl.setCrudPrefix("/source");
  70. this.controls.materialVideoListCtrl.state.size = 18;
  71. this.controls.materialVideoListCtrl.state.query = { fileType: "video" };
  72. this.controls.custImageListCtrl.setCrudPrefix("/source");
  73. this.controls.custImageListCtrl.state.size = 20;
  74. this.controls.custImageListCtrl.state.query = { fileType: "image" };
  75. this.controls.custVideoListCtrl.setCrudPrefix("/source");
  76. this.controls.custVideoListCtrl.state.size = 20;
  77. this.controls.custVideoListCtrl.state.query = { fileType: "video" };
  78. this.controls.custCompListCtrl.setCrudPrefix("/frame");
  79. this.controls.custCompListCtrl.state.size = 20;
  80. this.controls.custCompListCtrl.state.query = { type: "comp" };
  81. this.controls.custTextListCtrl.setCrudPrefix("/frame");
  82. this.controls.custTextListCtrl.state.size = 20;
  83. this.controls.custTextListCtrl.state.query = { type: "text" };
  84. this.controls.custShapeListCtrl.setCrudPrefix("/frame");
  85. this.controls.custShapeListCtrl.state.size = 20;
  86. this.controls.custShapeListCtrl.state.query = { type: "shape" };
  87. this.controls.sysTplListCtrl.setCrudPrefix("/sys/h5");
  88. this.controls.sysTplListCtrl.state.size = 20;
  89. this.controls.sysTplListCtrl.state.query = { published: true };
  90. this.controls.sysImageListCtrl.setCrudPrefix("/sys/source");
  91. this.controls.sysImageListCtrl.state.size = 20;
  92. this.controls.sysImageListCtrl.state.query = {
  93. fileType: "image",
  94. isSvg: { $ne: true },
  95. published: true,
  96. };
  97. this.controls.sysVideoListCtrl.setCrudPrefix("/sys/source");
  98. this.controls.sysVideoListCtrl.state.size = 20;
  99. this.controls.sysVideoListCtrl.state.query = {
  100. fileType: "video",
  101. published: true,
  102. };
  103. this.controls.sysCompListCtrl.setCrudPrefix("sys/frame");
  104. this.controls.sysCompListCtrl.state.size = 20;
  105. this.controls.sysCompListCtrl.state.query = {
  106. type: "comp",
  107. published: true,
  108. };
  109. this.controls.sysShapeListCtrl.setCrudPrefix("/sys/frame");
  110. this.controls.sysShapeListCtrl.state.size = 20;
  111. this.controls.sysShapeListCtrl.state.query = {
  112. type: "shape",
  113. published: true,
  114. };
  115. this.controls.sysTextListCtrl.setCrudPrefix("/sys/frame");
  116. this.controls.sysTextListCtrl.state.size = 20;
  117. this.controls.sysTextListCtrl.state.query = {
  118. type: "text",
  119. published: true,
  120. };
  121. this.natsBus.init();
  122. }
  123. }
  124. export const { useResource, initResource } = ResourceModule.hook("Resource");