index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { cx } from "@linaria/core";
  2. import { Button, Tooltip } from "ant-design-vue";
  3. import { computed, reactive } from "vue";
  4. import {
  5. IconAi,
  6. IconApplication,
  7. IconCombination,
  8. IconCube,
  9. IconImage,
  10. IconLayers,
  11. IconProfile,
  12. IconShape,
  13. IconText,
  14. IconTpl,
  15. IconVideo,
  16. } from "@/assets/icons";
  17. import { defineUI } from "queenjs";
  18. import { CompTree } from "../SliderRight/CompTree";
  19. import AiText from "./AiText";
  20. import Application from "./Application";
  21. import Comp3d from "./Comp3d";
  22. import CustomComps from "./CustomComps";
  23. import Shapes from "./Shapes";
  24. import { Sources } from "./Sources";
  25. import Templates from "./Templates";
  26. import Text from "./Text";
  27. const tabs = [
  28. {
  29. title: "模板",
  30. icon: IconTpl,
  31. component: Templates,
  32. },
  33. {
  34. title: "组合",
  35. icon: IconCombination,
  36. component: CustomComps,
  37. props: { compType: "senior" },
  38. },
  39. {
  40. title: "组件",
  41. icon: IconApplication,
  42. component: Application,
  43. },
  44. {
  45. title: "文字",
  46. icon: IconText,
  47. component: Text,
  48. },
  49. {
  50. title: "图片",
  51. icon: IconImage,
  52. component: Sources,
  53. props: { sourceType: "Image", sourceFrom: "system" },
  54. },
  55. {
  56. title: "视频",
  57. icon: IconVideo,
  58. component: Sources,
  59. props: { sourceType: "Video", sourceFrom: "system" },
  60. },
  61. {
  62. title: "3D",
  63. icon: IconCube,
  64. component: Comp3d,
  65. },
  66. {
  67. title: "形状",
  68. icon: IconShape,
  69. component: Shapes,
  70. },
  71. {
  72. title: "我的",
  73. icon: IconProfile,
  74. content: [
  75. {
  76. title: "图片",
  77. component: Sources,
  78. props: { sourceType: "Image", sourceFrom: "user" },
  79. },
  80. {
  81. title: "视频",
  82. component: Sources,
  83. props: { sourceType: "Video", sourceFrom: "user" },
  84. },
  85. {
  86. title: "组合",
  87. component: CustomComps,
  88. props: { compType: "user" },
  89. },
  90. ],
  91. },
  92. {
  93. title: "AI",
  94. icon: IconAi,
  95. component: AiText,
  96. },
  97. {
  98. title: "图层",
  99. icon: IconLayers,
  100. component: CompTree,
  101. },
  102. ];
  103. export default defineUI({
  104. setup() {
  105. // @ts-ignore
  106. const state = reactive({
  107. tabIndex: 8,
  108. compIndexs: [0, 0, 0, 0, 0, 0, 0, 0, 0],
  109. currentTab: computed(() => {
  110. return tabs[state.tabIndex];
  111. }),
  112. currCompIndex: computed(() => {
  113. return state.compIndexs[state.tabIndex];
  114. }),
  115. });
  116. return () => {
  117. const { tabIndex, currentTab, currCompIndex } = state;
  118. const currComp = currentTab.component
  119. ? currentTab
  120. : currentTab.content?.[state.currCompIndex];
  121. return (
  122. <div class="h-full flex">
  123. <div class="flex flex-col items-center w-70px py-10px border-right !border-2px overflow-hidden">
  124. {tabs.map((record, index) => {
  125. return (
  126. <>
  127. {index === tabs.length - 2 && <div class="flex-1"></div>}
  128. <div
  129. key={index}
  130. class={cx(
  131. "my-2px rounded cursor-pointer text-light-50 transition hover:(bg-[#1F1F1F] text-orange)",
  132. state.tabIndex == index && "bg-[#1F1F1F] text-orange"
  133. )}
  134. onClick={() => (state.tabIndex = index)}
  135. >
  136. <Tooltip title={record.title} placement="right">
  137. <record.icon class="px-15px py-10px text-28px" />
  138. </Tooltip>
  139. </div>
  140. </>
  141. );
  142. })}
  143. </div>
  144. <div class="flex-1 h-1/1 overflow-hidden flex flex-col">
  145. {currentTab.content && (
  146. <div class="mt-5px ml-10px space-x-10px">
  147. {currentTab.content?.map((item: any, index: number) => (
  148. <Button
  149. key={index}
  150. type="text"
  151. class={cx(
  152. "transition",
  153. currCompIndex == index && "font-bold"
  154. )}
  155. onClick={() => (state.compIndexs[tabIndex] = index)}
  156. >
  157. {item?.title}
  158. </Button>
  159. ))}
  160. </div>
  161. )}
  162. <currComp.component
  163. class="flex-1 h-1/1 px-16px !my-10px overflow-y-auto"
  164. {...currComp.props}
  165. />
  166. </div>
  167. </div>
  168. );
  169. };
  170. },
  171. });