import { TimeController } from "@/controllers/TimeController"; import { queenApi } from "queenjs"; import Modal from "queenjs/adapter/vue/components/modal"; import { ResourceModule } from ".."; export const materialActions = ResourceModule.action({ async createMaterial() { const { successRow, failRow } = await this.helper.uploadMaterials({ accept: "image/*,video/mp4,audio/mp3", multiple: true, }); for (const key in successRow) { const souceObj = successRow[key]; await this.https.createResource(souceObj); } this.controls.materialListCtrl.state.query = { fileType: this.store.type, }; this.controls.materialListCtrl.loadPage(1); return { successRow, failRow }; }, async createAudioMaterial() { const { successRow, failRow } = await this.helper.uploadMaterials({ accept: "audio/mp3", multiple: false, }); for (const key in successRow) { const souceObj = successRow[key]; await this.https.createResource(souceObj); } return { successRow, failRow }; }, async deleteMaterial(record) { const res = await queenApi.showConfirm({ content: `删除后不可恢复,是否要删除此素材?`, type: "danger", }); if (!res) return; await this.https.deleteResource(record._id); // this.controls.materialListCtrl.fresh(); }, publishMaterial(record: any, publish: boolean) { return this.https.publishResource({ _id: record._id, published: publish }); }, publishFrame(record: any, publish: boolean) { return this.https.publishFrame({ _id: record._id, published: publish }); }, downloadMaterial(record) { window.open(record.file.url); }, async selectMaterial(record) { const _params = new URLSearchParams(decodeURIComponent(location.search)); const host = _params.get("host"); // if (location.host == "www.infish.cn") { // const url = `${location.origin}/projects/queenshowv1/index.html?host=${host}#/create/${record._id}`; // location.href = url; // return; // } const url = `${location.origin}/index.html?host=${host}#/create/${record._id}`; location.href = url; }, });