index.tsx 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import { View } from "@tarojs/components";
  2. import RoundedLabel from "../RoundedLabel";
  3. import IconFilterFeeds from "@/components/icon/IconFilterFeeds";
  4. import IconFilterBatch from "@/components/icon/IconFilterBatch";
  5. import IconFilterList from "@/components/icon/IconFilterList";
  6. import EmptyData from "@/components/empty-data";
  7. import Popup from "@/components/popup/popup";
  8. import WemetaSwitch from "@/components/WemetaSwitch";
  9. import { useState } from "react";
  10. import ViewStyleChatEnt from "../view-style/ViewStyleChatEnt";
  11. import ViewStyleListEnt from "../view-style/ViewStyleListEnt";
  12. import PickerSingleColumn from "@/components/Picker/PickerSingleColumn";
  13. import IconArrowDownRounded from "@/components/icon/IconArrowDownRounded";
  14. import { useKnowledgeEntStore } from "@/store/knowledgeEnt";
  15. import { useUserStore } from "@/store/userStore";
  16. import { useAgentStore } from "@/store/agentStore";
  17. type TListStyle = "chat" | "list";
  18. const Index = () => {
  19. const ents = useUserStore((state) => state.entList);
  20. const [checked, setChecked] = useState(false);
  21. const [showPopup, setShowPopup] = useState(false);
  22. const [listStyle, setListStyle] = useState<TListStyle>("chat");
  23. const { ent, setEnt, total, listTotalCount } = useKnowledgeEntStore();
  24. // const agents = useAgentStore((state) => state.agents);
  25. const handleListStyleChange = (listStyle: TListStyle) => {
  26. setListStyle(listStyle);
  27. };
  28. // 如果没有当前企业,则默认第一个
  29. if (!ent) {
  30. setEnt(ents[0]);
  31. }
  32. const renderTabContent = () => {
  33. if (!ents.length) {
  34. return (
  35. <View className="flex-center pt-40">
  36. <EmptyData type={7}>
  37. <View className="text-center text-14 leading-28 text-gray-45 mb-44 w-172">
  38. <View className="text-center text-16 leading-24 font-medium text-black">
  39. 绑定企业,知识自动到位
  40. </View>
  41. <View>访问公司统一知识内容</View>
  42. <View>一键同步到你的智能体</View>
  43. <View>提升回复效率与专业度</View>
  44. <View
  45. className="button-rounded button-primary-light button-border-primary button-inline-flex mt-24"
  46. onClick={() =>
  47. Taro.navigateTo({ url: "/pages/contact-us/index" })
  48. }
  49. >
  50. 联系我们
  51. </View>
  52. </View>
  53. </EmptyData>
  54. </View>
  55. );
  56. }
  57. return (
  58. <>
  59. <View className="px-16 pb-20">
  60. <View className="pb-8">
  61. <PickerSingleColumn
  62. options={options}
  63. selected={selected}
  64. onChange={handleChange}
  65. showPicker={showPicker}
  66. setShowPicker={setShowPicker}
  67. >
  68. <View
  69. className="flex items-center gap-2 bg-gray-3 rounded-12 p-12 mb-16"
  70. onClick={() => setShowPicker(true)}
  71. >
  72. <View className="flex-1 text-14 leading-22 text-gray-45">
  73. {selected}
  74. </View>
  75. <View className="flex-center">
  76. <IconArrowDownRounded />
  77. </View>
  78. </View>
  79. </PickerSingleColumn>
  80. </View>
  81. <View className="flex items-center">
  82. <View className="flex-1 text-12 leading-20 text-gray-45">
  83. 共 {listStyle === "chat" ? total : listTotalCount} 个文件
  84. </View>
  85. <View className="flex items-center">
  86. {listStyle === "chat" ? (
  87. <RoundedLabel
  88. onClick={() => setShowPopup(true)}
  89. text="信息流"
  90. icon={IconFilterFeeds}
  91. ></RoundedLabel>
  92. ) : (
  93. <>
  94. <RoundedLabel
  95. onClick={() => {
  96. console.log("batch");
  97. }}
  98. text="批量"
  99. icon={IconFilterBatch}
  100. ></RoundedLabel>
  101. <RoundedLabel
  102. text="列表"
  103. onClick={() => {
  104. setShowPopup(true);
  105. }}
  106. icon={IconFilterList}
  107. ></RoundedLabel>
  108. </>
  109. )}
  110. </View>
  111. </View>
  112. </View>
  113. <View className="px-16 h-full">{renderContent()}</View>
  114. </>
  115. );
  116. };
  117. // 当前选中的值
  118. const options = ents.map((item) => item.entName);
  119. // 是否显示选择器
  120. const [showPicker, setShowPicker] = useState(false);
  121. // 当前选中的值
  122. const [selected, setSelected] = useState(options[0]);
  123. const handleChange = (value: string) => {
  124. setSelected(value);
  125. const ent = ents.find((item) => item.entName === value);
  126. if (ent) {
  127. setEnt(ent);
  128. }
  129. };
  130. const renderContent = () => {
  131. if (!ent?.entId) {
  132. return <></>;
  133. }
  134. if (listStyle === "chat") {
  135. return <ViewStyleChatEnt entId={ent.entId} />;
  136. }
  137. return <ViewStyleListEnt entId={ent.entId} />;
  138. };
  139. return (
  140. <>
  141. <View className="pt-12 h-full">
  142. <View className="rounded-container-header"></View>
  143. {renderTabContent()}
  144. </View>
  145. <Popup setShow={setShowPopup} show={showPopup} title="展示样式">
  146. <View
  147. className={`rounded-card ${
  148. listStyle === "chat" ? "rounded-card-actived" : ""
  149. }`}
  150. onClick={() => {
  151. handleListStyleChange("chat");
  152. }}
  153. >
  154. <View className="border-bottom1-gray mb-12">
  155. <View className="mb-8 text-14 font-medium leading-22">
  156. 对话信息流
  157. </View>
  158. <View className="mb-12 text-12 leading-20 text-gray-45">
  159. 以对话形式展示,模拟自然的对话流程。
  160. </View>
  161. </View>
  162. <View className="flex items-center">
  163. <View className="flex-1 text-14 font-medium leading-22">
  164. 仅显示 AI 助手信息
  165. </View>
  166. <WemetaSwitch
  167. checked={checked}
  168. onChange={(checked) => setChecked(checked)}
  169. ></WemetaSwitch>
  170. </View>
  171. </View>
  172. <View
  173. className={`rounded-card ${
  174. listStyle === "list" ? "rounded-card-actived" : ""
  175. }`}
  176. onClick={() => {
  177. handleListStyleChange("list");
  178. }}
  179. >
  180. <View className="mb-8 text-14 font-medium leading-22">列表形式</View>
  181. <View className="mb-12 text-12 leading-20 text-gray-45">
  182. 将知识点以简洁列表呈现,清晰快速地提供信息。
  183. </View>
  184. </View>
  185. </Popup>
  186. </>
  187. );
  188. };
  189. export default Index;