import { PageListController } from "@queenjs/controllers"; import { reactive } from "vue"; export class MaterialController { state = reactive({currTab: "image", tabs:["image", "video", "task"], btns:["upload", "image","video"] , uploadType:"Default" as "image"|"video"|"Default"}); imageCtrl = new PageListController(); vidoeCtrl = new PageListController(); taskCtrl = new PageListController(); tplCtrl = new PageListController(); async showDialog(type:string) { const ctrl = this.tplCtrl; ctrl.state.query = type == "video" ? { hasVideo: true } : {} ctrl.loadPage(1); const record:any = await this.onShowDialog(ctrl, type); if (record && record._id) { const url = `${location.origin}/index.html#/create/${record._id}`; location.href = url; } } switchTab(name: string, fresh = true) { this.state.currTab = name; const ctrol = this.getCurrControl(); if(fresh) ctrol.fresh(); } getCurrControl() : PageListController { switch (this.state.currTab) { case "image": return this.imageCtrl; case "video": return this.vidoeCtrl; default: return this.taskCtrl; } } onBtnClick(name:string) { console.log("onBtnClick", name) } onItemClick(name: "delete" | "download", record:any) { console.log("onItemClick", name, record) } async onShowDialog(listCtrl: PageListController, type:string) { console.log("onShowDialog", type) } } export const TabNames = { "video":"视频", "image": "图片", "task": "渲染任务" } export const BtnNames = { "video":"生成视频", "image": "生成图片", "upload": "上传素材" } export const renderStatus = { 'succ': "", 'error': "渲染失败", 'default': "渲染中…", };