MaterialController.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { PageListController } from "@queenjs/controllers";
  2. import { reactive } from "vue";
  3. export class MaterialController {
  4. state = reactive({currTab: "image", tabs:["image", "video", "task"], btns:["upload", "image","video"] , uploadType:"Default" as "image"|"video"|"Default"});
  5. imageCtrl = new PageListController<any, any>();
  6. vidoeCtrl = new PageListController<any, any>();
  7. taskCtrl = new PageListController<any, any>();
  8. tplCtrl = new PageListController<any, any>();
  9. async showDialog(type:string) {
  10. const ctrl = this.tplCtrl;
  11. ctrl.state.query = type == "video" ? { hasVideo: true } : {}
  12. ctrl.loadPage(1);
  13. const record:any = await this.onShowDialog(ctrl, type);
  14. if (record && record._id) {
  15. const url = `${location.origin}/index.html#/create/${record._id}`;
  16. location.href = url;
  17. }
  18. }
  19. switchTab(name: string, fresh = true) {
  20. this.state.currTab = name;
  21. const ctrol = this.getCurrControl();
  22. if(fresh) ctrol.fresh();
  23. }
  24. getCurrControl() : PageListController<any, any> {
  25. switch (this.state.currTab) {
  26. case "image": return this.imageCtrl;
  27. case "video": return this.vidoeCtrl;
  28. default: return this.taskCtrl;
  29. }
  30. }
  31. onBtnClick(name:string) {
  32. console.log("onBtnClick", name)
  33. }
  34. onItemClick(name: "delete" | "download", record:any) {
  35. console.log("onItemClick", name, record)
  36. }
  37. async onShowDialog(listCtrl: PageListController<any, any>, type:string) {
  38. console.log("onShowDialog", type)
  39. }
  40. }
  41. export const TabNames = {
  42. "video":"视频",
  43. "image": "图片",
  44. "task": "渲染任务"
  45. }
  46. export const BtnNames = {
  47. "video":"生成视频",
  48. "image": "生成图片",
  49. "upload": "上传素材"
  50. }
  51. export const renderStatus = {
  52. 'succ': "",
  53. 'error': "渲染失败",
  54. 'default': "渲染中…",
  55. };