import { queenApi } from "queenjs"; import { ResourceModule } from ".."; import { PromotionController } from "../controllers/PromotionController"; import { PageListController } from "@queenjs/controllers"; export const promotionAction = ResourceModule.action({ async renamePromotion(record: any) { const title = await queenApi.showInput({ title: "请输入标题", defaultValue: record.title, }); if (!title) return; await this.https.updatePromotion({ _id: record._id, title }); record.title = title; }, async deletePromotion(record: any) { const res = await queenApi.showConfirm({ content: `删除后无法恢复,确定要删除:${record.title}?`, type: "danger", }); if (!res) return; await this.https.deletePromotion(record._id); this.controls.promotionListCtrl.fresh(); }, async createPromotion() { const title = await queenApi.showInput({ title: "请输入标题", }); if (!title) return; const res = await this.https.createPromotion({ title }); const url = `${location.origin}/editor.html#/?id=${res.result}`; location.href = url; } });