material.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { queenApi } from "queenjs";
  2. import { ResourceModule } from "..";
  3. export const materialActions = ResourceModule.action({
  4. async uploadMaterial() {
  5. const files = await this.helper.uploadResource({
  6. accept: "image/*, video/mp4",
  7. multiple: true,
  8. });
  9. let souceObj = files[0];
  10. for (const key in files) {
  11. souceObj = files[key];
  12. await this.https.createResource(souceObj);
  13. }
  14. this.controls.materialListCtrl.state.query = {
  15. fileType: this.store.type,
  16. };
  17. this.controls.materialListCtrl.loadPage(1);
  18. return souceObj;
  19. },
  20. async deleteMaterial(record) {
  21. const res = await queenApi.showConfirm({
  22. content: `删除后不可恢复,是否要删除此素材?`,
  23. type: "danger",
  24. });
  25. if (!res) return;
  26. await this.https.deleteResource(record._id);
  27. // this.controls.materialListCtrl.fresh();
  28. },
  29. downloadMaterial(record) {
  30. window.open(record.file.url);
  31. },
  32. async selectMaterial(record) {
  33. const _params = new URLSearchParams(decodeURIComponent(location.search));
  34. const host = _params.get("host");
  35. if (location.host == "www.infish.cn") {
  36. const url = `${location.origin}/projects/queenshowv1/index.html?host=${host}#/create/${record._id}`;
  37. location.href = url;
  38. return;
  39. }
  40. const url = `${location.origin}/index.html?host=${host}#/create/${record._id}`;
  41. location.href = url;
  42. },
  43. });