promotion.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { queenApi } from "queenjs";
  2. import { ResourceModule } from "..";
  3. export const promotionAction = ResourceModule.action({
  4. async renamePromotion(record: any) {
  5. const title = await queenApi.showInput({
  6. title: "请输入标题",
  7. defaultValue: record.title,
  8. });
  9. if (!title) return;
  10. await this.https.updatePromotion({ _id: record._id, title });
  11. record.title = title;
  12. },
  13. async deletePromotion(record: any) {
  14. const res = await queenApi.showConfirm({
  15. content: `删除后无法恢复,确定要删除:${record.title}?`,
  16. type: "danger",
  17. });
  18. if (!res) return;
  19. await this.https.deletePromotion(record._id);
  20. // this.controls.promotionListCtrl.fresh();
  21. },
  22. async createPromotion() {
  23. const title = await queenApi.showInput({
  24. title: "请输入标题",
  25. });
  26. if (!title) return;
  27. const res = await this.https.createPromotion({ title });
  28. //console.log(location.host, location.host == "www.infish.cn");
  29. // if (location.host == "www.infish.cn") {
  30. // const url = `${location.origin}/projects/queenshowv1/editor.html#/?id=${res.result}`;
  31. // location.href = url;
  32. // return;
  33. // }
  34. const url = `${location.origin}/editor.html#/?id=${res.result}`;
  35. location.href = url;
  36. },
  37. async createComp() {
  38. const title = await queenApi.showInput({
  39. title: "请输入标题",
  40. });
  41. if (!title) return;
  42. const res = await this.https.createComp({ title });
  43. // console.log(location.host, location.host == "www.infish.cn");
  44. // if (location.host == "www.infish.cn") {
  45. // const url = `${location.origin}/projects/queenshowv1/editor.html#/?id=${res.result}&mode=editComp`;
  46. // location.href = url;
  47. // return;
  48. // }
  49. const url = `${location.origin}/editor.html#/?id=${res.result}&mode=editComp`;
  50. location.href = url;
  51. },
  52. async deleteComp(record: any) {
  53. const res = await queenApi.showConfirm({
  54. content: `删除后无法恢复,确定要删除:${record.title}?`,
  55. type: "danger",
  56. });
  57. if (!res) return;
  58. await this.https.deleteComp(record._id);
  59. // this.controls.promotionListCtrl.fresh();
  60. },
  61. async renameComp(record: any) {
  62. const title = await queenApi.showInput({
  63. title: "请输入标题",
  64. defaultValue: record.title,
  65. });
  66. if (!title) return;
  67. await this.https.updateComp({ _id: record._id, title });
  68. record.title = title;
  69. },
  70. });