|
@@ -1,6 +1,7 @@
|
|
|
import { cx } from "@linaria/core";
|
|
|
import { Tooltip } from "ant-design-vue";
|
|
|
-import { computed, reactive } from "vue";
|
|
|
+import { defineComponent, reactive } from "vue";
|
|
|
+import { number, object } from "vue-types";
|
|
|
|
|
|
import {
|
|
|
IconAi,
|
|
@@ -115,70 +116,146 @@ const tabs = [
|
|
|
|
|
|
export default defineUI({
|
|
|
setup() {
|
|
|
- // @ts-ignore
|
|
|
const state = reactive({
|
|
|
tabIndex: 0,
|
|
|
- compIndexs: [0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
- currentTab: computed(() => {
|
|
|
- return tabs[state.tabIndex];
|
|
|
- }),
|
|
|
- currCompIndex: computed(() => {
|
|
|
- return state.compIndexs[state.tabIndex];
|
|
|
- }),
|
|
|
+ list: [0],
|
|
|
});
|
|
|
|
|
|
return () => {
|
|
|
- const { tabIndex, currentTab, currCompIndex } = state;
|
|
|
- const currComp = currentTab.component
|
|
|
- ? currentTab
|
|
|
- : currentTab.content?.[state.currCompIndex];
|
|
|
+ const { list, tabIndex } = state;
|
|
|
|
|
|
return (
|
|
|
<div class="h-full flex">
|
|
|
- <div class="flex flex-col items-center w-70px py-10px border-right !border-2px overflow-x-hidden overflow-y-auto scrollbar">
|
|
|
- {tabs.map((record, index) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- {index === tabs.length - 3 && <div class="flex-1"></div>}
|
|
|
- <div
|
|
|
- key={index}
|
|
|
- class={cx(
|
|
|
- "my-2px rounded cursor-pointer text-light-50 transition hover:(bg-[#1F1F1F] text-orange)",
|
|
|
- state.tabIndex == index && "bg-[#1F1F1F] text-orange"
|
|
|
- )}
|
|
|
- onClick={() => (state.tabIndex = index)}
|
|
|
- >
|
|
|
- <Tooltip title={record.title} placement="right">
|
|
|
- <record.icon class="px-15px py-10px text-28px" />
|
|
|
- </Tooltip>
|
|
|
- </div>
|
|
|
- </>
|
|
|
- );
|
|
|
- })}
|
|
|
- </div>
|
|
|
- <div class="flex-1 h-1/1 overflow-hidden flex flex-col">
|
|
|
- {currentTab.content && (
|
|
|
- <div class="mt-15px mx-5px flex items-center justify-around space-x-1">
|
|
|
- {currentTab.content?.map((item: any, index: number) => (
|
|
|
- <span
|
|
|
- class={cx(
|
|
|
- "px-14px py-9px transition cursor-pointer bg-[#303030] text-light-50 text-opacity-70 rounded-4px text-12px hover:(text-[#EA9E40])",
|
|
|
- currCompIndex == index &&
|
|
|
- "bg-[#EA9E40] bg-opacity-20 text-orange"
|
|
|
- )}
|
|
|
- onClick={() => (state.compIndexs[tabIndex] = index)}
|
|
|
- >
|
|
|
- {item?.title}
|
|
|
- </span>
|
|
|
- ))}
|
|
|
- </div>
|
|
|
- )}
|
|
|
+ <PanelTabs
|
|
|
+ tabIndex={tabIndex}
|
|
|
+ onChange={(index) => {
|
|
|
+ if (!list.includes(index)) {
|
|
|
+ state.list.push(index);
|
|
|
+ }
|
|
|
+ state.tabIndex = index;
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {tabs.map((tab, index) => {
|
|
|
+ if (!list.includes(index)) return null;
|
|
|
+ return (
|
|
|
+ <PanelContent
|
|
|
+ key={index}
|
|
|
+ currentTab={tab}
|
|
|
+ class={tabIndex !== index && "hidden"}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ };
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const PanelTabs = defineComponent({
|
|
|
+ props: {
|
|
|
+ tabIndex: number().isRequired,
|
|
|
+ },
|
|
|
+ emits: ["change"],
|
|
|
+ setup(props, { emit }) {
|
|
|
+ return () => {
|
|
|
+ const { tabIndex } = props;
|
|
|
+ return (
|
|
|
+ <div class="flex flex-col items-center w-70px py-10px border-right !border-2px overflow-x-hidden overflow-y-auto scrollbar">
|
|
|
+ {tabs.map((record, index) => {
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {index === tabs.length - 3 && <div class="flex-1"></div>}
|
|
|
+ <div
|
|
|
+ key={index}
|
|
|
+ class={cx(
|
|
|
+ "my-2px rounded cursor-pointer text-light-50 transition hover:(bg-[#1F1F1F] text-orange)",
|
|
|
+ tabIndex == index && "bg-[#1F1F1F] text-orange"
|
|
|
+ )}
|
|
|
+ onClick={() => emit("change", index)}
|
|
|
+ >
|
|
|
+ <Tooltip title={record.title} placement="right">
|
|
|
+ <record.icon class="px-15px py-10px text-28px" />
|
|
|
+ </Tooltip>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ };
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+const PanelContent = defineComponent({
|
|
|
+ props: {
|
|
|
+ currentTab: object().isRequired,
|
|
|
+ },
|
|
|
+ setup(props) {
|
|
|
+ const state = reactive({
|
|
|
+ currCompIndex: 0,
|
|
|
+ list: [0],
|
|
|
+ });
|
|
|
+
|
|
|
+ const SubTabs = () => {
|
|
|
+ const { currentTab } = props;
|
|
|
+ const { currCompIndex, list } = state;
|
|
|
+
|
|
|
+ if (!currentTab.content) return null;
|
|
|
+ return (
|
|
|
+ <div class="mt-15px mx-5px flex items-center justify-around space-x-1">
|
|
|
+ {currentTab.content?.map((item: any, index: number) => (
|
|
|
+ <span
|
|
|
+ class={cx(
|
|
|
+ "px-14px py-9px transition cursor-pointer bg-[#303030] text-light-50 text-opacity-70 rounded-4px text-12px hover:(text-[#EA9E40])",
|
|
|
+ currCompIndex == index &&
|
|
|
+ "bg-[#EA9E40] bg-opacity-20 text-orange"
|
|
|
+ )}
|
|
|
+ onClick={() => {
|
|
|
+ if (!list.includes(index)) {
|
|
|
+ state.list.push(index);
|
|
|
+ }
|
|
|
+ state.currCompIndex = index;
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item?.title}
|
|
|
+ </span>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ };
|
|
|
|
|
|
- <currComp.component
|
|
|
- class="flex-1 h-1/1 px-16px !my-10px overflow-y-auto"
|
|
|
- {...currComp.props}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ const Subcontent = () => {
|
|
|
+ const { currentTab } = props;
|
|
|
+ const { currCompIndex, list } = state;
|
|
|
+
|
|
|
+ const currComps = currentTab.component
|
|
|
+ ? [currentTab]
|
|
|
+ : currentTab.content;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ {currComps.map((currComp: any, index: number) => {
|
|
|
+ if (!list.includes(index)) return null;
|
|
|
+ return (
|
|
|
+ <currComp.component
|
|
|
+ key={index}
|
|
|
+ class={cx(
|
|
|
+ "flex-1 h-1/1 px-16px !my-10px overflow-x-hidden overflow-y-auto scrollbar",
|
|
|
+ currCompIndex !== index && "hidden"
|
|
|
+ )}
|
|
|
+ {...currComp.props}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </>
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ return (
|
|
|
+ <div class="flex-1 h-1/1 overflow-hidden flex flex-col">
|
|
|
+ <SubTabs />
|
|
|
+ <Subcontent />
|
|
|
</div>
|
|
|
);
|
|
|
};
|