index.v1.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { useEditor } from "@/modules/editor";
  2. import { css } from "@linaria/core";
  3. import { useReactive } from "@queenjs/use";
  4. import { defineUI } from "queenjs";
  5. import CustomComps from "./CustomComps";
  6. import Frames from "./Templates";
  7. import { Sources } from "./Sources";
  8. export default defineUI({
  9. setup() {
  10. const editor = useEditor();
  11. const { compUICtrl, frameControl } = editor.controls;
  12. const tabs = [
  13. { label: "模板", value: "frame" },
  14. { label: "平台组件", value: "senior" },
  15. { label: "我的组件", value: "user" },
  16. { label: "我的素材", value: "source" },
  17. ];
  18. const state = useReactive(() => ({
  19. currTabType: "frame",
  20. basicComps() {
  21. return ["Text", "Image", "Video", "Web3D"].map(
  22. (key) => compUICtrl.state.components.get(key) as any
  23. );
  24. },
  25. currComps() {
  26. return Array.from(compUICtrl.state.components.values()).filter(
  27. (item) => state.currTabType === item.compType
  28. );
  29. },
  30. }));
  31. return () => (
  32. <div class="h-full flex flex-col">
  33. <div class="p-16px border-bottom !border-2px">资源中心</div>
  34. <div class="m-16px flex-1 flex flex-col h-0">
  35. <div class={tabStyle}>
  36. {tabs.map((item) => {
  37. return (
  38. <span
  39. class={[state.currTabType === item.value && "checked"]}
  40. onClick={() => (state.currTabType = item.value)}
  41. >
  42. {item.label}
  43. </span>
  44. );
  45. })}
  46. </div>
  47. {state.currTabType == "frame" && (
  48. <Frames
  49. class="flex-1 -mx-16px p-16px"
  50. // dataSource={frameControl.listCtrl.state.list}
  51. />
  52. )}
  53. {/* {(state.currTabType == "user" || state.currTabType == "senior") && (
  54. <CustomComps
  55. class="flex-1 -mx-16px p-16px"
  56. components={state.currComps}
  57. />
  58. )} */}
  59. {state.currTabType == "source" && (
  60. <Sources class="flex-1 -mx-16px p-16px" />
  61. )}
  62. </div>
  63. </div>
  64. );
  65. },
  66. });
  67. const tabStyle = css`
  68. @apply text-16px my-16px space-x-10px;
  69. span {
  70. cursor: pointer;
  71. &.checked {
  72. font-weight: bold;
  73. }
  74. }
  75. `;