index.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import NavBarNormal from "@/components/nav-bar-normal/index";
  2. import { View } from "@tarojs/components";
  3. import PageCustom from "@/components/page-custom/index";
  4. import TabBarButtons from "@/components/wemeta-tabs/TabBarButtons";
  5. import AgentSetting from './components/AgentSetting/'
  6. import { useAgentStore } from "@/store/agentStore";
  7. import { useEffect, useState } from "react";
  8. export default function Index() {
  9. const [tabIndex, setTabIndex] = useState("1");
  10. const agent = useAgentStore((state)=> state.agent)
  11. const {fetchAgent} = useAgentStore()
  12. const handleTabIndexChange = (index: string) => {
  13. setTabIndex(index);
  14. };
  15. const tabList = [
  16. {
  17. key: "1",
  18. label: "智能体",
  19. },
  20. {
  21. key: "2",
  22. label: "微官网",
  23. },
  24. ];
  25. useEffect(()=> {
  26. agent?.agentId && fetchAgent(agent.agentId)
  27. }, [agent?.agentId])
  28. return (
  29. <PageCustom>
  30. <NavBarNormal backText="创建"></NavBarNormal>
  31. <View className="px-16 w-full flex flex-col gap-20">
  32. <View className="w-full">
  33. <TabBarButtons
  34. current={tabIndex}
  35. list={tabList}
  36. onTabIndexChange={handleTabIndexChange}
  37. ></TabBarButtons>
  38. </View>
  39. <View className={`${tabIndex === '1' ? 'block':'hidden'}`}>
  40. <AgentSetting></AgentSetting>
  41. </View>
  42. <View className={`${tabIndex === '2' ? 'block':'hidden'}`}>
  43. components
  44. </View>
  45. </View>
  46. </PageCustom>
  47. );
  48. }