index.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { View } from "@tarojs/components";
  2. import EmptyData, {EmptyDataTitle, EmptyDataSubInfo} from "@/components/EmptyData";
  3. import StyleFilter, { TListStyle } from "../StyleFilter";
  4. import { useRef, useState } from "react";
  5. import CorrectionListChat from "./components/CorrectionListChat";
  6. import CorrectionList from "./components/CorrectionList";
  7. import { TEntItem } from "@/types/user";
  8. import CompanyList from "../CompanyList";
  9. const Index = () => {
  10. const [listStyle, setListStyle] = useState<TListStyle>("chat");
  11. const [ent, setEnt] = useState<TEntItem | null>(null);
  12. const [totalCount, setTotalCount] = useState<number>(0);
  13. const extraEnt: TEntItem[] = [
  14. {
  15. entName: "个人知识库",
  16. entId: undefined,
  17. expireTime: "0",
  18. isExpired: false,
  19. knowledgeCnt: 0,
  20. },
  21. ];
  22. // 渲染数据内容
  23. const renderScrollContent = () => {
  24. if (listStyle === "chat") {
  25. return (
  26. <CorrectionListChat
  27. setTotalCount={setTotalCount}
  28. entId={ent?.entId}
  29. />
  30. );
  31. }
  32. return (
  33. <CorrectionList
  34. setTotalCount={setTotalCount}
  35. entId={ent?.entId}
  36. />
  37. );
  38. };
  39. console.log("渲染纠错模块", totalCount);
  40. // 渲染主体
  41. const renderEmpty = () => {
  42. // 空数据
  43. if (!totalCount) {
  44. return (
  45. <EmptyData type={"whiteboard"}>
  46. <EmptyDataTitle>还没有纠正过的内容</EmptyDataTitle>
  47. <EmptyDataSubInfo>
  48. <View>当你发现 AI 理解有误的知识点并进行修改后,</View>
  49. <View>会汇总在这里,用于优化AI回答。</View>
  50. </EmptyDataSubInfo>
  51. </EmptyData>
  52. );
  53. }
  54. return <></>;
  55. };
  56. return (
  57. <View className="h-full flex flex-col">
  58. <View className="pt-20 pb-20">
  59. <View className="px-16">
  60. <CompanyList
  61. currentEnt={ent}
  62. setCurrentEnt={setEnt}
  63. extraEnt={extraEnt}
  64. ></CompanyList>
  65. </View>
  66. <StyleFilter listStyle={listStyle} setListStyle={setListStyle}>
  67. <View className="flex-1 text-12 leading-20 text-gray-45">
  68. 共纠正 {totalCount ?? 0} 条问答
  69. </View>
  70. </StyleFilter>
  71. </View>
  72. {renderEmpty()}
  73. {renderScrollContent()}
  74. </View>
  75. );
  76. };
  77. export default Index;