|
|
@@ -10,21 +10,26 @@ import { TAgent } from "@/types/agent";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
import ContactIcon from "@/components/ContactIcon";
|
|
|
import { useEffect } from "react";
|
|
|
-import EmptyData, { EmptyDataSubInfo, EmptyDataTitle } from "@/components/EmptyData";
|
|
|
+import EmptyData, {
|
|
|
+ EmptyDataSubInfo,
|
|
|
+ EmptyDataTitle,
|
|
|
+} from "@/components/EmptyData";
|
|
|
interface IProps {
|
|
|
show: boolean;
|
|
|
setShow: (show: boolean) => void;
|
|
|
}
|
|
|
export default ({ show, setShow }: IProps) => {
|
|
|
const agents = useAgentStore((state) => state.agents);
|
|
|
- const { setDefaultAgent, fetchAgents, clearEditAgent, fetchDefaultNewAgentInfo } = useAgentStoreActions();
|
|
|
+ const {
|
|
|
+ setDefaultAgent,
|
|
|
+ fetchAgents,
|
|
|
+ clearEditAgent,
|
|
|
+ fetchDefaultNewAgentInfo,
|
|
|
+ } = useAgentStoreActions();
|
|
|
let loading = false;
|
|
|
const personalAgents = agents.filter((item) => !item.isEnt);
|
|
|
const entAgents = agents.filter((item) => item.isEnt);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
const handleClick = async (item: TAgent) => {
|
|
|
if (loading) {
|
|
|
return;
|
|
|
@@ -38,37 +43,37 @@ export default ({ show, setShow }: IProps) => {
|
|
|
}
|
|
|
loading = false;
|
|
|
Taro.hideLoading();
|
|
|
- setShow(false)
|
|
|
-
|
|
|
+ setShow(false);
|
|
|
};
|
|
|
|
|
|
- const handleCreate = async ()=> {
|
|
|
- Taro.showTabBar().catch(()=> {});
|
|
|
+ const handleCreate = async () => {
|
|
|
+ Taro.showTabBar().catch(() => {});
|
|
|
if (loading) {
|
|
|
return;
|
|
|
}
|
|
|
loading = true;
|
|
|
- try{
|
|
|
- clearEditAgent()
|
|
|
+ try {
|
|
|
+ clearEditAgent();
|
|
|
await fetchDefaultNewAgentInfo();
|
|
|
- Taro.navigateTo({ url: `/pages/agent/index`});
|
|
|
+ Taro.navigateTo({ url: `/pages/agent/index` });
|
|
|
loading = false;
|
|
|
- setShow(false)
|
|
|
- }catch(e:any){
|
|
|
+ setShow(false);
|
|
|
+ } catch (e: any) {
|
|
|
loading = false;
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
- useEffect(()=> {
|
|
|
- fetchAgents()
|
|
|
- }, [show])
|
|
|
+ useEffect(() => {
|
|
|
+ fetchAgents();
|
|
|
+ }, [show]);
|
|
|
|
|
|
const renderCard = (item: TAgent, isEnt: boolean) => {
|
|
|
return (
|
|
|
- <View className={item.isDefault ? style.cardActive : style.card} onClick={() => handleClick(item)}>
|
|
|
- <View
|
|
|
- className="flex items-start mb-12"
|
|
|
- >
|
|
|
+ <View
|
|
|
+ className={item.isDefault ? style.cardActive : style.card}
|
|
|
+ onClick={() => handleClick(item)}
|
|
|
+ >
|
|
|
+ <View className="flex items-start mb-12">
|
|
|
<View className="flex flex-col flex-1 truncate">
|
|
|
<View className="flex items-end gap-8 text-gray-5 truncate">
|
|
|
<View className="text-20 font-medium leading-28 text-black truncate">
|
|
|
@@ -97,8 +102,8 @@ export default ({ show, setShow }: IProps) => {
|
|
|
};
|
|
|
|
|
|
const renderAgents = () => {
|
|
|
- if(agents.length <= 0){
|
|
|
- return <EmptyData type='search' className="mt-44"></EmptyData>
|
|
|
+ if (agents.length <= 0) {
|
|
|
+ return <EmptyData type="search" className="mt-44"></EmptyData>;
|
|
|
}
|
|
|
return agents.map((item) => {
|
|
|
return renderCard(item, !!item.entId);
|
|
|
@@ -106,15 +111,14 @@ export default ({ show, setShow }: IProps) => {
|
|
|
};
|
|
|
|
|
|
const renderPersonalAgents = () => {
|
|
|
- if(personalAgents.length <= 0){
|
|
|
- return <EmptyData type='search' className="mt-44"></EmptyData>
|
|
|
+ if (personalAgents.length <= 0) {
|
|
|
+ return <EmptyData type="search" className="mt-44"></EmptyData>;
|
|
|
}
|
|
|
return personalAgents.map((item) => {
|
|
|
return renderCard(item, false);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-
|
|
|
const renderEntAgents = () => {
|
|
|
if (entAgents.length) {
|
|
|
return entAgents.map((item) => {
|
|
|
@@ -123,20 +127,37 @@ export default ({ show, setShow }: IProps) => {
|
|
|
}
|
|
|
return (
|
|
|
<View className={`${style.card} h-full`}>
|
|
|
- <EmptyData type='box'>
|
|
|
+ <EmptyData type="box">
|
|
|
<EmptyDataTitle>你还没有加入任何企业</EmptyDataTitle>
|
|
|
- <EmptyDataSubInfo>访问公司统一知识内容,提升回复效率与专业度</EmptyDataSubInfo>
|
|
|
+ <EmptyDataSubInfo>
|
|
|
+ 访问公司统一知识内容,提升回复效率与专业度
|
|
|
+ </EmptyDataSubInfo>
|
|
|
<View
|
|
|
- className="button-rounded button-primary-light button-border-primary button-inline-flex mt-20"
|
|
|
- onClick={() => Taro.navigateTo({ url: "/pages/contact-us/index" })}
|
|
|
- >
|
|
|
- 联系我们
|
|
|
+ className="button-rounded button-primary-light button-border-primary button-inline-flex mt-20"
|
|
|
+ onClick={() => Taro.navigateTo({ url: "/pages/contact-us/index" })}
|
|
|
+ >
|
|
|
+ 联系我们
|
|
|
</View>
|
|
|
</EmptyData>
|
|
|
</View>
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+ const renderCreateNewButton = () => {
|
|
|
+ return (
|
|
|
+
|
|
|
+ <View
|
|
|
+ className="absolute left-0 right-0 bottom-0 z-10 bg-white pt-14"
|
|
|
+ onClick={handleCreate}
|
|
|
+ >
|
|
|
+ <View className="button-rounded button-primary-light gap-8 mb-15">
|
|
|
+ <IconPlusBlue />
|
|
|
+ <View>创建新智能体</View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
const tabList = [
|
|
|
{
|
|
|
key: "all",
|
|
|
@@ -145,19 +166,12 @@ export default ({ show, setShow }: IProps) => {
|
|
|
<>
|
|
|
<View className="pt-12 relative">
|
|
|
<View className={style.tabContainer}>
|
|
|
- <View className="pb-66">
|
|
|
- {renderAgents()}
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <View className="absolute left-0 right-0 bottom-0 z-10 bg-white pt-14" onClick={handleCreate}>
|
|
|
- <View className="button-rounded button-primary-light gap-8 mb-15">
|
|
|
- <IconPlusBlue />
|
|
|
- <View>创建新的智能体</View>
|
|
|
- </View>
|
|
|
+ <View className="pb-66">{renderAgents()}</View>
|
|
|
</View>
|
|
|
+ {renderCreateNewButton()}
|
|
|
</View>
|
|
|
</>
|
|
|
- )
|
|
|
+ ),
|
|
|
},
|
|
|
{
|
|
|
key: "personal",
|
|
|
@@ -166,16 +180,9 @@ export default ({ show, setShow }: IProps) => {
|
|
|
<>
|
|
|
<View className="pt-12 relative">
|
|
|
<View className={style.tabContainer}>
|
|
|
- <View className="pb-66">
|
|
|
- {renderPersonalAgents()}
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <View className="absolute left-0 right-0 bottom-0 z-10 bg-white pt-14" onClick={handleCreate}>
|
|
|
- <View className="button-rounded button-primary-light gap-8 mb-15">
|
|
|
- <IconPlusBlue />
|
|
|
- <View>创建新的智能体</View>
|
|
|
- </View>
|
|
|
+ <View className="pb-66">{renderPersonalAgents()}</View>
|
|
|
</View>
|
|
|
+ {renderCreateNewButton()}
|
|
|
</View>
|
|
|
</>
|
|
|
),
|