소스 검색

fix: 回退首页请求智能体错误

王晓东 3 주 전
부모
커밋
ef3f99ae62

+ 1 - 0
src/app.config.ts

@@ -20,6 +20,7 @@ export default defineAppConfig({
     'pages/editor-contact/index',
     'pages/contact-us/index',
     'pages/privacy/index',
+    'pages/account/index',
     'pages/agreement/index',
     
     'pages/test/index',

+ 3 - 1
src/components/LoginPopup/index.tsx

@@ -16,13 +16,15 @@ import { isSuccess } from "@/utils";
 interface IProps {
   showPopup: boolean
   setShowPopup: (b: boolean)=> void
+  onEnd: ()=>void
 }
 
-export default function Index({showPopup, setShowPopup}:IProps) {
+export default function Index({showPopup, setShowPopup, onEnd}:IProps) {
   const { onGetPhoneNumber, onError, onClick, openType } = useLogin({
     onSuccess: () => {
       console.log('yes')
       setShowPopup(false)
+      onEnd()
     },
   })
   const [checked, setChecked] = useState(false);

+ 7 - 2
src/components/list/card-list-item/index.tsx

@@ -1,7 +1,7 @@
 import { View, Image } from "@tarojs/components";
 import style from "./index.module.less";
 import IconArrowThin from "@/components/icon/icon-arrow-thin";
-
+import IconArrowRight24 from "@/components/icon/IconArrowRight24";
 
 interface Props {
   arrow?: boolean;
@@ -43,10 +43,15 @@ export default ({
           {children}
         </View>
         {rightRenderer && rightRenderer()}
-        {arrow && (
+        {/* {arrow && (
           <View className=''>
             <IconArrowThin/>
           </View>
+        )} */}
+        {arrow && (
+          <View className='flex-center pr-8'>
+            <IconArrowRight24 />
+          </View>
         )}
         
       </View>

+ 0 - 0
src/images/svgs/privacy/IconVisibleForRedirect.svg → src/images/svgs/privacy/IconVisibleForForward.svg


+ 2 - 2
src/pages/account/index.tsx

@@ -15,10 +15,10 @@ export default function Index() {
       <NavBarNormal backText="账号管理"></NavBarNormal>
       <View className="w-full px-16 py-24 flex flex-col gap-16">
         <ListWrapper>
-          <ListRow underline rightRenderer={()=> <View className="flex-center">{whoami?.mobile}</View>}>
+          <ListRow underline rightRenderer={()=> <View className="flex-center text-gray-65">{whoami?.mobile}</View>}>
             绑定手机
           </ListRow>
-          <ListRow rightRenderer={()=> <View className="flex-center">{whoami?.userId}</View>}>
+          <ListRow rightRenderer={()=> <View className="flex-center text-gray-65">{whoami?.userId}</View>}>
           用户ID
           </ListRow>
         </ListWrapper>

+ 1 - 0
src/pages/agent/components/AgentSetting/components/AgentContactCard/index.module.less

@@ -18,6 +18,7 @@
   font-weight: 400;
   font-size: 12px;
   line-height: 20px;
+  min-height: 26px;
 }
 .item{
   margin-bottom: 2px;

+ 127 - 68
src/pages/editor-contact/index.tsx

@@ -3,95 +3,154 @@ import { View } from "@tarojs/components";
 import PageCustom from "@/components/page-custom/index";
 
 import CardList from "@/components/list/card-list";
+import ListWrapper from "@/components/list/ListWrapper";
+import ListRow from "@/components/list/ListRow";
 import TagCertificated from "@/components/tag-certificated";
 import CardListItem from "@/components/list/card-list-item";
 import Taro, { useRouter } from "@tarojs/taro";
 import { useAgentStore } from "@/store/agentStore";
 import { TAgentDetail } from "@/types/agent";
-const  RenderEntCard = (agent: TAgentDetail|null, navToUrl: (url: string)=>void) => {
-  if(!agent?.entName){
-    return <></>
+const RenderEntCard = (
+  agent: TAgentDetail | null,
+  navToUrl: (url: string) => void
+) => {
+  if (!agent?.entName) {
+    return <></>;
   }
-  return <View className="px-16 w-full pt-12">
-    <CardList>
-      <View className="py-16 px-20 flex flex-col gap-20">
-        <CardListItem underline arrow onClick={()=> navToUrl('/pages/editor-pages/editor-company/index')}>
-          <View className="flex items-center font-normal pb-16">
-            <View className="flex-1 font-normal">企业</View>
-            <View className="text-gray-65 mr-8 truncate max-w-[188px]">{agent?.entName}</View>
-          </View>
-        </CardListItem>
-        <CardListItem underline>
-          <View className="flex items-center font-normal pb-16">
-            <View className="flex-1 font-normal">企业认证</View>
-            <TagCertificated />
-          </View>
-        </CardListItem>
-        <CardListItem arrow onClick={()=> navToUrl('/pages/editor-pages/editor-position/index')}>
-          <View className="flex items-center font-normal pb-16">
-            <View className="flex-1 font-normal">职位</View>
-            <View className="text-gray-65 mr-8">{agent?.position}</View>
-          </View>
-        </CardListItem>
-      </View>
-    </CardList>
-  </View>
-}
+  return (
+    <View className="px-16 w-full pt-12">
+      <CardList>
+        <View className="py-16 px-20 flex flex-col gap-20">
+          <CardListItem
+            underline
+            arrow
+            onClick={() => navToUrl("/pages/editor-pages/editor-company/index")}
+          >
+            <View className="flex items-center font-normal pb-16">
+              <View className="flex-1 font-normal">企业</View>
+              <View className="text-gray-65 truncate max-w-[188px]">
+                {agent?.entName}
+              </View>
+            </View>
+          </CardListItem>
+          <CardListItem underline>
+            <View className="flex items-center font-normal pb-16">
+              <View className="flex-1 font-normal">企业认证</View>
+              <TagCertificated />
+            </View>
+          </CardListItem>
+          <CardListItem
+            arrow
+            onClick={() =>
+              navToUrl("/pages/editor-pages/editor-position/index")
+            }
+          >
+            <View className="flex items-center font-normal pb-16">
+              <View className="flex-1 font-normal">职位</View>
+              <View className="text-gray-65 mr-8">{agent?.position}</View>
+            </View>
+          </CardListItem>
+        </View>
+      </CardList>
+    </View>
+  );
+};
 
 export default function Index() {
-  const router = useRouter()
-  const {agentId} = router.params
-  const agent = useAgentStore(state => state.agent)
-  
-  const navToUrl = (url: string)=> {
-    Taro.navigateTo({url})
-  }
+  const router = useRouter();
+  const { agentId } = router.params;
+  const agent = useAgentStore((state) => state.agent);
 
-  
-  
+  const navToUrl = (url: string) => {
+    Taro.navigateTo({ url });
+  };
 
   return (
     <PageCustom>
       <NavBarNormal backText="数字名片"></NavBarNormal>
       <View className="px-16 w-full pt-4">
-        <CardList>
-          <View className="py-16 px-20 flex flex-col gap-20">
-            <CardListItem underline arrow onClick={()=> navToUrl(`/pages/editor-pages/editor-name/index?agentId=${agentId}`)}>
-              <View className="flex items-center font-normal pb-16 truncate">
-                <View className="flex-1 font-normal">姓名</View>
-                <View className="text-gray-65 mr-8 truncate max-w-160">{agent?.name}</View>
-              </View>
-            </CardListItem>
-            <CardListItem underline arrow onClick={()=> navToUrl(`/pages/editor-pages/editor-phone/index?agentId=${agentId}`)}>
-              <View className="flex items-center font-normal pb-16">
-                <View className="flex-1 font-normal">手机号码</View>
-                <View className="text-gray-65 mr-8">{agent?.mobile}</View>
+        <ListWrapper>
+          <ListRow
+            underline
+            arrow
+            rightRenderer={() => (
+              <View className="text-gray-65 truncate max-w-160">
+                {agent?.name}
               </View>
-            </CardListItem>
-            <CardListItem underline arrow onClick={()=> navToUrl(`/pages/editor-pages/editor-email/index?agentId=${agentId}`)}>
-              <View className="flex items-center font-normal pb-16">
-                <View className="flex-1 font-normal">联系邮箱</View>
-                <View className="text-gray-65 mr-8 truncate max-w-[188px]">{agent?.email}</View>
+            )}
+            onClick={() =>
+              navToUrl(
+                `/pages/editor-pages/editor-name/index?agentId=${agentId}`
+              )
+            }
+          >
+            姓名
+          </ListRow>
+          <ListRow
+            rightRenderer={() => (
+              <View className="text-gray-65 truncate max-w-160">
+                {agent?.mobile}
               </View>
-            </CardListItem>
-            <CardListItem underline arrow onClick={()=> navToUrl(`/pages/editor-pages/editor-address/index?agentId=${agentId}`)}>
-              <View className="flex items-center font-normal pb-16">
-                <View className="flex-1 font-normal">联系地址</View>
-                <View className="text-gray-65 mr-8 truncate max-w-[188px]">{agent?.address}</View>
+            )}
+            underline
+            arrow
+            onClick={() =>
+              navToUrl(
+                `/pages/editor-pages/editor-phone/index?agentId=${agentId}`
+              )
+            }
+          >
+            手机号码
+          </ListRow>
+          <ListRow
+            rightRenderer={() => (
+              <View className="text-gray-65 truncate max-w-160">
+                {agent?.email}
               </View>
-            </CardListItem>
-            <CardListItem arrow onClick={()=> navToUrl('/pages/editor-pages/editor-qrcode/index')}>
-              <View className="flex items-center font-normal pb-16">
-                <View className="flex-1 font-normal">我的二维码</View>
-                {(!!agent?.qrCodeUrl?.length) && <View className="text-gray-65 mr-8 text-primary">已上传</View>}
+            )}
+            underline
+            arrow
+            onClick={() =>
+              navToUrl(
+                `/pages/editor-pages/editor-email/index?agentId=${agentId}`
+              )
+            }
+          >
+            联系邮箱
+          </ListRow>
+          <ListRow
+            rightRenderer={() => (
+              <View className="text-gray-65 truncate max-w-160">
+                {agent?.address}
               </View>
-            </CardListItem>
-          </View>
-        </CardList>
+            )}
+            underline
+            arrow
+            onClick={() =>
+              navToUrl(
+                `/pages/editor-pages/editor-address/index?agentId=${agentId}`
+              )
+            }
+          >
+            联系地址
+          </ListRow>
+          <ListRow
+            rightRenderer={() => {
+              return !!agent?.qrCodeUrl?.length ? (
+                <View className="text-gray-65 text-primary font-normal">已上传</View>
+              ) : (
+                <></>
+              );
+            }}
+            arrow
+            onClick={() => navToUrl("/pages/editor-pages/editor-qrcode/index")}
+          >
+            我的二维码
+          </ListRow>
+        </ListWrapper>
       </View>
 
       {RenderEntCard(agent, navToUrl)}
-      
     </PageCustom>
   );
 }

+ 10 - 10
src/pages/index/components/InitView/index.tsx

@@ -14,16 +14,16 @@ import { useSystemStore } from '@/store/systemStore'
 import { TAgent } from "@/types/agent";
 import { useUserStore } from "@/store/userStore";
 interface IProps {
-  setDefault: (agent: TAgent) => void
+  // setDefault: (agent: TAgent) => void
 }
-export default function Index({setDefault}: IProps) {
+export default function Index({}: IProps) {
 
   const [userInfo, setUserInfo] = useState<UserInfoResponse>()
   const isLogin = useIsLogin()
 
   const {fetchAgents} =  useAgentStore()
-  const { getSysCoreCnf } =  useSystemStore()
-  const { getMyInfo } = useUserStore()
+  const { fetchSysCoreCnf } =  useSystemStore()
+  const { fetchtMyInfo } = useUserStore()
 
   async function initUserInfo() {
     await refreshUserId()
@@ -42,13 +42,13 @@ export default function Index({setDefault}: IProps) {
           })
         }
       })
-    await getSysCoreCnf()
-    await getMyInfo()
+    await fetchSysCoreCnf()
+    await fetchtMyInfo()
     const agents = await fetchAgents()
     const agent = agents.find( item=> item.isDefault)
-    if(agent){
-      setDefault(agent)
-    }
+    // if(agent){
+    //   setDefault(agent)
+    // }
   }
 
   useEffect(() => {
@@ -66,7 +66,7 @@ export default function Index({setDefault}: IProps) {
     <PageCustom>
       <NavBarNormal leftColumn={renderLogo}></NavBarNormal>
       <View className="relative w-full">
-        <WelcomeTips setDefault={setDefault}></WelcomeTips>
+        <WelcomeTips></WelcomeTips>
       </View>
       </PageCustom>
   );

+ 2 - 6
src/pages/index/components/WelcomeTips/index.tsx

@@ -7,16 +7,12 @@ import { getAgents, getAgent, createAgent, } from "@/service/agent";
 import { isSuccess } from "@/utils";
 import { useAgentStore } from "@/store/agentStore";
 interface IProps {
-  setDefault: (agent: TAgent) => void
   // children: JSX.Element|JSX.Element[]
 }
-export default function Index({setDefault}: IProps) {  
+export default function Index({}: IProps) {  
   const { createAgent } = useAgentStore()
   const handleCreate = async ()=> {
-    const result = await createAgent()
-    if(result){
-      setDefault(result)
-    }
+    createAgent()
   }
   return (
     <View className={style.container}>

+ 14 - 17
src/pages/index/index.tsx

@@ -1,28 +1,25 @@
-import PageCustom from "@/components/page-custom/index";
-import { useEffect, useState } from "react";
 import DefaultAgent from '@/components/AgentPage'
 import InitView from './components/InitView'
-import { TAgent } from "@/types/agent";
 import { useDidShow } from "@tarojs/taro";
 import { useAgentStore } from "@/store/agentStore";
+import { useIsLogin } from "@/xiaolanbenlib/hooks/data/useAuth";
 
 export default function Index() {
-  const { fetchAgent } = useAgentStore()
-  const [defaultAgent, setDefaultAgent] = useState<TAgent|null>(null)
+  const isLogin = useIsLogin()
+  const { fetchAgents, defaultAgent } = useAgentStore()
 
   useDidShow(()=> {
-    if(defaultAgent?.agentId){
-      fetchAgent(defaultAgent?.agentId)
+    // 如果没有登录过,则显示默认欢迎页
+    // 如果有登录状态,主动获取智能体列表
+    if(isLogin){
+      fetchAgents()
     }
   })
-  
-  return (
-    <PageCustom>
-      <>
-      {/* <InitView setDefault={setDefaultAgent}></InitView> */}
-      {!defaultAgent && <InitView setDefault={setDefaultAgent}></InitView>}
-      {defaultAgent && <DefaultAgent agentId={defaultAgent.agentId}></DefaultAgent>}
-      </>
-    </PageCustom>
-  );
+  if(!defaultAgent){
+    return <InitView></InitView>
+  }
+
+  if(defaultAgent?.agentId){
+    return <DefaultAgent agentId={defaultAgent.agentId}></DefaultAgent>
+  }
 }

+ 24 - 29
src/pages/personal/index.tsx

@@ -7,25 +7,23 @@ import AvatarDefault from "@/components/AvatarDefault";
 import { useEffect, useState } from "react";
 import CardList from "@/components/list/card-list";
 import CardListItem from "@/components/list/card-list-item";
-import IconArrowRight24 from "@/components/icon/IconArrowRight24";
 import IconAccount from "@/images/svgs/personal/IconAccount.svg";
 import IconPrivacy from "@/images/svgs/personal/IconPrivacy.svg";
 import IconAgreement from "@/images/svgs/personal/IconAgreement.svg";
 import IconFeedback from "@/images/svgs/personal/IconFeedback.svg";
 import IconDesktop from "@/images/svgs/personal/IconDesktop.svg";
 import style from "./index.module.less";
-import MenuLabel from "./components/MenuLabel";
-import { navToWebView } from "@/utils/index";
 import Taro from "@tarojs/taro";
-import { getSysAgreements, type TAgreementItem } from "@/service/system";
-import { isSuccess } from "@/utils";
 import { useIsLogin } from '@/xiaolanbenlib/hooks/data/useAuth'
 
 import LoginPopup from '@/components/LoginPopup/index'
 import SaveToDesktopTip from './components/SaveToDesktopTip'
+import { useUserStore } from "@/store/userStore";
 
 export default function Index() {
 
+  const {fetchtMyInfo} = useUserStore()
+
   const isLogin = useIsLogin()
   
 
@@ -40,6 +38,9 @@ export default function Index() {
     }
   }
   
+  useEffect(()=>{
+    fetchtMyInfo()
+  }, [])
 
   // 自定义背景样式
   const handleNicknameChange = async (e: any) => {
@@ -49,14 +50,6 @@ export default function Index() {
     }
   };
 
-  const IconArrowRight = () => {
-    return (
-      <View className="flex items-center">
-        <IconArrowRight24 />
-      </View>
-    );
-  };
-
   
 
   return (
@@ -91,9 +84,9 @@ export default function Index() {
         
         <CardList>
           <CardListItem
-            className="pl-16 pr-8"
+            className="pl-16"
             underline
-            rightRenderer={IconArrowRight}
+            arrow
             leftRenderer={() => (
               <Image src={IconAccount} className="w-28 h-28" mode="widthFix" />
             )}
@@ -101,12 +94,12 @@ export default function Index() {
               Taro.navigateTo({ url: "/pages/account/index" });
             }}
           >
-            <MenuLabel>账号管理</MenuLabel>
+            <View className="py-18 label-text">账号管理</View>
           </CardListItem>
           <CardListItem
-            className="pl-16 pr-8"
+            className="pl-16"
             underline
-            rightRenderer={IconArrowRight}
+            arrow
             leftRenderer={() => (
               <Image src={IconPrivacy} className="w-28 h-28" mode="widthFix" />
             )}
@@ -114,13 +107,13 @@ export default function Index() {
               Taro.navigateTo({ url: "/pages/privacy/index" });
             }}
           >
-            <MenuLabel>隐私设置</MenuLabel>
+            <View className="py-18 label-text">隐私设置</View>
           </CardListItem>
           
           <CardListItem
-            className="pl-16 pr-8"
+            className="pl-16"
             underline
-            rightRenderer={IconArrowRight}
+            arrow
             leftRenderer={() => (
               <Image src={IconAgreement} className="w-28 h-28" mode="widthFix" />
             )}
@@ -128,15 +121,15 @@ export default function Index() {
               Taro.navigateTo({ url: "/pages/agreement/index" });
             }}
           >
-            <MenuLabel>服务协议</MenuLabel>
+            <View className="py-18 label-text">服务协议</View>
           </CardListItem>
         </CardList>
 
         <CardList>
           <CardListItem
-            className="pl-16 pr-8"
+            className="pl-16"
             underline
-            rightRenderer={IconArrowRight}
+            arrow
             leftRenderer={() => (
               <Image src={IconFeedback} className="w-28 h-28" mode="widthFix" />
             )}
@@ -144,12 +137,12 @@ export default function Index() {
               // Taro.navigateTo({ url: "/pages/voice/index" });
             }}
           >
-            <MenuLabel>意见反馈</MenuLabel>
+            <View className="py-18 label-text">意见反馈</View>
           </CardListItem>
           <CardListItem
-            className="pl-16 pr-8"
+            className="pl-16"
             underline
-            rightRenderer={IconArrowRight}
+            arrow
             leftRenderer={() => (
               <Image src={IconDesktop} className="w-28 h-28" mode="widthFix" />
             )}
@@ -158,11 +151,13 @@ export default function Index() {
               setSaveToDesktopTip(true)
             }}
           >
-            <MenuLabel>将智能体添加到桌面</MenuLabel>
+            <View className="py-18 label-text">将智能体添加到桌面</View>
           </CardListItem>
         </CardList>
       </View>
-      <LoginPopup showPopup={showPopup} setShowPopup={setShowPopup}></LoginPopup>
+      <LoginPopup onEnd={()=> {
+        // todo
+      }} showPopup={showPopup} setShowPopup={setShowPopup}></LoginPopup>
     </PageCustom>
   );
 }

+ 51 - 1
src/pages/privacy/index.tsx

@@ -1,7 +1,7 @@
 import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/NavBarNormal";
 import IconVisibleForDirect from "@/images/svgs/privacy/IconVisibleForDirect.svg";
-import IconVisibleForRedirect from "@/images/svgs/privacy/IconVisibleForRedirect.svg";
+import IconVisibleForForward from "@/images/svgs/privacy/IconVisibleForForward.svg";
 import IconVisibleForContact from "@/images/svgs/privacy/IconVisibleForContact.svg";
 import { View, Image } from "@tarojs/components";
 import ListWrapper from "@/components/list/ListWrapper";
@@ -51,6 +51,56 @@ export default function Index() {
               </View>
             </View>
           </ListRow>
+          <ListRow underline>
+            <View className="flex flex-col gap-8">
+              <View className="flex items-center">
+                <View className="flex items-center flex-1 gap-8">
+                  <Image
+                    src={IconVisibleForForward}
+                    className="w-28 h-28"
+                    mode="widthFix"
+                  />
+                  <View className="label-text">转发可见</View>
+                </View>
+                <View>
+                  <WemetaSwitch
+                    checked={privacy.forwardVisibleMyInfo}
+                    onChange={(checked) =>
+                      handleSwitchChange(checked, "forwardVisibleMyInfo")
+                    }
+                  ></WemetaSwitch>
+                </View>
+              </View>
+              <View className="text-gray-45 text-12 leading-20">
+              开启后,好友将你的智能体转发给他人时,他人可查看你的联系方式(手机、邮箱、微信二维码)
+              </View>
+            </View>
+          </ListRow>
+          <ListRow >
+            <View className="flex flex-col gap-8">
+              <View className="flex items-center">
+                <View className="flex items-center flex-1 gap-8">
+                  <Image
+                    src={IconVisibleForContact}
+                    className="w-28 h-28"
+                    mode="widthFix"
+                  />
+                  <View className="label-text">联系人可见</View>
+                </View>
+                <View>
+                  <WemetaSwitch
+                    checked={privacy.contactVisibleMyInfo}
+                    onChange={(checked) =>
+                      handleSwitchChange(checked, "contactVisibleMyInfo")
+                    }
+                  ></WemetaSwitch>
+                </View>
+              </View>
+              <View className="text-gray-45 text-12 leading-20">
+              开启后,在本人联系人列表中的人(本人访问过的智能体所属人)可查看到你的联系方式(手机、邮箱、微信二维码)
+              </View>
+            </View>
+          </ListRow>
         </ListWrapper>
       </View>
     </PageCustom>

+ 3 - 3
src/service/agent.ts

@@ -2,7 +2,7 @@ import {
   bluebookAiAgent,
 } from '@/xiaolanbenlib/api/index'
 import request from '@/xiaolanbenlib/module/axios.js'
-import { TAgentDetail, TComponentItem, TEditAgentCharacter, TAgentContactCard, TAgentShared } from '@/types/agent'
+import { TAgentDetail, TComponentItem, TEditAgentCharacter, TAgentContactCard, TAgentShared, TAgent } from '@/types/agent'
 
 
 // 创建一个新的智能体--用户点击创建按钮时调用获取新智能体id与名称信息
@@ -57,8 +57,8 @@ export const editAgentCard = (agentId: string, data: TAgentContactCard) => {
 
 
 // 我的智能体列表
-export const getAgents = (): Promise<TAgentDetail[]> =>  {
-  return request.get(`${bluebookAiAgent}api/v1/my/agents`)
+export const getAgents = () =>  {
+  return request.get<TAgent[]>(`${bluebookAiAgent}api/v1/my/agents`)
 }
 // 删除智能体--仅允许删除个人智能体
 export const deleteAgent = (agentId: string) => {

+ 15 - 13
src/store/agentStore.ts

@@ -4,6 +4,7 @@ import request from "@/xiaolanbenlib/module/axios.js";
 
 import {
   createAgent as _createAgent,
+  getAgents,
   getMyAgent as _getMyAgent,
   getAgent as _getAgent,
   setDefaultAgent as _setDefaultAgent,
@@ -25,13 +26,16 @@ import Taro from "@tarojs/taro";
 export interface AgentStoreState {
   agents: TAgent[];
   agent: TAgentDetail | null;
+  defaultAgent: TAgentDetail | TAgent | null;
   agentProfile: TAgentDetail | null;
   agentContactCard: TAgentContactCard | null;
   agentProfileContactCard: TAgentContactCard | null;
   agentCharacter: TEditAgentCharacter | null;
   ents: {entName: string, entId: string|number}[]
   fetchAgents: () => Promise<TAgent[]>;
+  // 请求智能体数据登录状态
   fetchAgent: (agentId: string) => Promise<TAgentDetail | null>;
+  // 请求智能体数据非登录状态
   fetchAgentProfile: (agentId: string) => Promise<TAgentDetail | null>;
   createAgent: () => Promise<TAgentDetail | null>;
   setDefaultAgent: (agentId: string) => Promise<TAgentDetail | null>;
@@ -55,28 +59,21 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
   agent: null,
   agentProfile: null,
   agentContactCard: null,
+  defaultAgent: null,
   agentProfileContactCard: null,
   agentCharacter: null,
   ents: [],
   fetchAgents: async () => {
-    const response = await request.get<TAgent[]>(
-      `${bluebookAiAgent}api/v1/my/agents`
-    );
+    const response = await getAgents();
     if (response && response?.data?.length) {
-      const ents = response.data.filter(item => item.isEnt).map( item => {
-        return {entName: item.entName ?? '', entId: item.entId}
-      })
-      set({ agents: response.data, ents });
+      const defaultAgent = response.data.find( item => item.isDefault)
+      set({ agents: response.data, defaultAgent });
       return response.data;
     }
 
     return [];
   },
-  fetchAgent: async (agentId: string, shareKey?:string) => {
-    // const { agents } = get()
-    // 如果自己的智能体列表中有 对应的 agentId,则请求自己的 agent, 否则请求无需登录的 getAgent 接口
-    // const isSelf = !!agents.find((item)=> item.agentId === agentId)
-    // const req = isSelf ?  : _getAgent; 
+  fetchAgent: async (agentId: string) => {
     const response = await _getMyAgent(agentId);
     const result = isSuccess(response.status)
     if (result && response.data) {
@@ -132,7 +129,11 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
     const response = await _setDefaultAgent(agentId);
     const result = isSuccess(response.status)
     if(result){
-      return await get().fetchAgent(agentId)
+      const agent = await get().fetchAgent(agentId)
+      set({
+        defaultAgent: agent
+      })
+      return agent
     }
     return null
   },
@@ -153,6 +154,7 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
             ...state.agents,
             a,
           ],
+          defaultAgent: a,
         };
       });
       return response.data;

+ 4 - 4
src/store/systemStore.ts

@@ -3,7 +3,7 @@ import { create } from "zustand";
 import type { TSystemCoreCnf } from '@/types/system'
 
 import {
-  getSysCoreCnf as _getSysCoreCnf,
+  getSysCoreCnf,
   
 } from "@/service/system";
 import Taro from "@tarojs/taro";
@@ -12,13 +12,13 @@ import { OSS_PUBLIC_BUCKET_NAME_KEY } from "@/xiaolanbenlib/constant";
 
 export interface SystemStoreState {
   sysCoreCnf: TSystemCoreCnf | null;
-  getSysCoreCnf: () => Promise<TSystemCoreCnf|null>;
+  fetchSysCoreCnf: () => Promise<TSystemCoreCnf|null>;
 }
 
 export const useSystemStore = create<SystemStoreState>((set, get) => ({
   sysCoreCnf: null,
-  getSysCoreCnf: async () => {
-    const response = await _getSysCoreCnf()
+  fetchSysCoreCnf: async () => {
+    const response = await getSysCoreCnf()
     if (response && response?.data) {
       Taro.setStorageSync(OSS_PUBLIC_BUCKET_NAME_KEY, response.data?.ossPublicBucketName)
       set({ sysCoreCnf: response.data });

+ 4 - 4
src/store/userStore.ts

@@ -1,12 +1,12 @@
 import { create } from 'zustand'
-import { getMyInfo as _getMyInfo, getMyEntList as _getMyEntList, getMyPrivacy } from '@/service/user'
+import { getMyInfo, getMyEntList as _getMyEntList, getMyPrivacy } from '@/service/user'
 import { TEntItem, TUserInfo, TMyPrivacy } from '@/types/user'
 import { isSuccess } from '@/utils'
 export interface UserState {
   whoami: TUserInfo | null
   entList: TEntItem[]
   privacy: TMyPrivacy
-  getMyInfo: ()=> Promise<void>
+  fetchtMyInfo: ()=> Promise<void>
   fetchMyPrivacy: ()=> Promise<void>
   fetchMyEntList: ()=> Promise<void>
 }
@@ -19,8 +19,8 @@ export const useUserStore = create<UserState>((set) => ({
     forwardVisibleMyInfo: false
   },
   entList: [],
-  getMyInfo: async () => {
-    const res = await _getMyInfo()
+  fetchtMyInfo: async () => {
+    const res = await getMyInfo()
     if(isSuccess(res.status)){
       set({ whoami: res.data})
     }

+ 1 - 1
src/xiaolanbenlib/module/axios.js

@@ -67,7 +67,7 @@ axiosIns.interceptors.response.use(
         : err.response.data
     }
     if (error.code === 401) {
-      //   await customCallback()
+      Taro.setStorageSync('hasLogin', '0')
       Taro.switchTab({
         url: '/pages/personal/index',
       });