Browse Source

feat: 请求返回完整信息

王晓东 1 day ago
parent
commit
00d9bf7f40

+ 6 - 0
src/app.tsx

@@ -2,6 +2,7 @@ import Taro, { useLaunch } from "@tarojs/taro";
 import { PropsWithChildren } from "react";
 import "./app.less";
 import { useAppStore } from "./store/appStore";
+import { generateRandomId } from '@/utils/index'
 
 if (process.env.TARO_ENV == "h5") {
   const VConsole = require("vconsole");
@@ -46,6 +47,11 @@ function App({ children }: PropsWithChildren<any>) {
         setSystemInfo(res);
       },
     });
+
+    const uuid = generateRandomId()
+    console.log(uuid)
+    // Taro.setStorageSync('hasLogin', '1') // 已经登录过,可以认为微信号跟手机号绑定了,后面可以只授权微信信息登录
+
   });
   return <>{children}</>;
 }

+ 7 - 4
src/pages/agent/components/AgentSetting/components/AgentContactCard/index.tsx

@@ -6,16 +6,19 @@ import IconLocationGray from "@/components/icon/icon-location-gray"
 import IconQRCodeGray from "@/components/icon/icon-qrcode-gray"
 import IconEditGray from "@/components/icon/icon-edit-gray"
 import Taro from "@tarojs/taro";
+import { useAgentStore } from "@/store/agentStore";
+
 export default () => {
+  const agent = useAgentStore((state)=> state.agent)
   const handleEdit = ()=> {
     Taro.navigateTo({
-      url: '/pages/editor-contact/index',
+      url: `/pages/editor-contact/index?agentId=${agent?.agentId}`,
     })
   }
   return(
     <View className={style.container}>
       <View className={style.header}>
-        <View className={style.name}>你的名字</View>
+        <View className={style.name}>{agent?.name}</View>
         <View className={style.icons}>
           <View className={style.icon}><IconPhoneGray/></View>
           <View className={style.icon}><IconMailGray/></View>
@@ -25,10 +28,10 @@ export default () => {
       </View>
       <View className={style.items}>
         <View className={style.item}>
-          你的公司名称
+        {agent?.entName}
         </View>
         <View className={style.item}>
-          你的岗位
+        {agent?.position}
         </View>
       </View>
       <View className={style.editButton} onClick={handleEdit}>

+ 7 - 4
src/pages/agent/index.tsx

@@ -5,12 +5,13 @@ import PageCustom from "@/components/page-custom/index";
 
 import TabBarButtons from "@/components/wemeta-tabs/TabBarButtons";
 import AgentSetting from './components/AgentSetting/'
-
-import { useState } from "react";
+import { useAgentStore } from "@/store/agentStore";
+import { useEffect, useState } from "react";
 
 export default function Index() {
   const [tabIndex, setTabIndex] = useState("1");
-
+  const agent = useAgentStore((state)=> state.agent)
+  const {fetchAgent} = useAgentStore()
   const handleTabIndexChange = (index: string) => {
     setTabIndex(index);
   };
@@ -26,7 +27,9 @@ export default function Index() {
     },
   ];
 
-
+  useEffect(()=> {
+    agent?.agentId && fetchAgent(agent.agentId)
+  }, [agent?.agentId])
 
   return (
     <PageCustom>

+ 6 - 6
src/pages/chat/components/input-bar/index.tsx

@@ -1,14 +1,14 @@
 import { useState } from "react";
 import TextInputBar from "./TextInputBar";
 import VoiceInputBar from "./VoiceInputBar";
-import { textChat } from "@/service/character";
+import { textChat } from "@/service/bot";
 import { useTextChat } from "@/store/textChat";
-import { ICharacter } from "@/types";
+import { TAgentDetail } from "@/types/agent";
 import { delay } from "@/utils";
 import { EAI_MODEL } from "@/consts/enum";
 import { useUnload } from "@tarojs/taro";
 interface Props {
-  character: ICharacter;
+  character: TAgentDetail;
   aiModel: EAI_MODEL;
 }
 
@@ -46,16 +46,16 @@ export default ({ character, aiModel }: Props) => {
     setDisabled(true);
     // 发起文本聊天
     stopReceiveChunk = textChat({
-      profileId: character.profileId,
+      agentId: character.agentId,
       params: { message, model: aiModel },
       onStart: () => {
         currentRobotMessageId = pushRobotMessage({
           content: "",
           reasoningContent: "",
           robot: {
-            avatar: character.avatar ?? "",
+            avatar: character.avatarUrl ?? "",
             name: character.name ?? "",
-            profileId: character.profileId ?? "",
+            agentId: character.agentId ?? "",
           },
         });
       },

+ 8 - 9
src/pages/chat/index.tsx

@@ -2,7 +2,6 @@ import { View, ScrollView } from "@tarojs/components";
 import NavBarNormal from "@/components/nav-bar-normal/index";
 import PageCustom from "@/components/page-custom/index";
 import Taro, { useUnload } from "@tarojs/taro";
-import { useCurrentCharacter } from "@/store/characterStore";
 import ChatMessage from "@/components/chat-message";
 import style from "./index.module.less";
 // import { useAppStore } from "@/store/appStore";
@@ -15,7 +14,7 @@ import type { TMessage, TRobotMessage } from "@/store/textChat";
 import ChatWelcome from './components/chat-welcome'
 import IconArrowLeft from "@/components/icon/icon-arrow-left";
 import PersonalCard from './components/personal-card'
-
+import { useAgentStore } from "@/store/agentStore";
 // 类型谓词函数
 function isRobotMessage(message: TMessage | TRobotMessage): message is TRobotMessage {
   return 'robot' in message && 'reasoningContent' in message;
@@ -29,7 +28,7 @@ export default function Index() {
   const [scrollViewHeight, setScrollViewHeight] = useState(0);
   const scrollViewRef = useRef<any>(null);
   // const headerHeight = useAppStore((state) => state.headerHeight);
-  const character = useCurrentCharacter();
+  const agent = useAgentStore((state)=> state.agent)  
   const messageList = useTextChat((state) => state.list);
   const { destroy } = useTextChat();
   const scrollTop = useTextChat((state) => state.scrollTop);
@@ -100,15 +99,15 @@ export default function Index() {
 
   useEffect(() => {
     // 主动打招呼
-    if (character) {
-      const greetingText = `Hi~我是${character.name},和我聊聊吧~`;
+    if (agent) {
+      const greetingText = `Hi~我是${agent.name},和我聊聊吧~`;
       pushRobotMessage({
         content: greetingText,
         reasoningContent: "",
         robot: {
-          avatar: character.avatar ?? "",
-          name: character.name ?? "",
-          profileId: character.profileId ?? "",
+          avatar: agent.avatarUrl ?? "",
+          name: agent.name ?? "",
+          agentId: agent.agentId ?? "",
         },
       });
     }
@@ -173,7 +172,7 @@ export default function Index() {
           >
             深度思考(R1)
           </View>
-          <InputBar aiModel={deepThink} character={null}></InputBar>
+          <InputBar aiModel={deepThink} character={agent}></InputBar>
         </View>
       </View>
     </PageCustom>

+ 6 - 4
src/pages/editor-contact/index.tsx

@@ -5,10 +5,12 @@ import PageCustom from "@/components/page-custom/index";
 import CardList from "@/components/list/card-list";
 import TagCertificated from "@/components/tag-certificated";
 import CardListItem from "@/components/list/card-list-item";
-import Taro from "@tarojs/taro";
+import Taro, { useRouter } from "@tarojs/taro";
 
 
 export default function Index() {
+  const router = useRouter()
+  const {agentId} = router.params
   const navToUrl = (url: string)=> {
     Taro.navigateTo({url})
   }
@@ -18,19 +20,19 @@ export default function Index() {
       <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')}>
+            <CardListItem underline arrow onClick={()=> navToUrl(`/pages/editor-pages/editor-name/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">张三</View>
               </View>
             </CardListItem>
-            <CardListItem underline arrow onClick={()=> navToUrl('/pages/editor-pages/editor-phone/index')}>
+            <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">137 1234 1234</View>
               </View>
             </CardListItem>
-            <CardListItem underline arrow onClick={()=> navToUrl('/pages/editor-pages/editor-email/index')}>
+            <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]">zhangsan@eyeclear.com</View>

+ 23 - 33
src/pages/editor-pages/editor-name/index.tsx

@@ -4,55 +4,42 @@ import { View } from "@tarojs/components";
 import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/nav-bar-normal/index";
 import editorStyle from "../editor.module.less";
-import WemetaRadioGroup from "@/components/wemeta-radio-group/index";
-import { useComponentStore } from '@/store/componentStore'
-import { useCharacterStore } from '@/store/characterStore'
+import BottomBar from "@/components/BottomBar";
+
 import WemetaTextarea from "@/components/wemeta-textarea/index";
 import Taro, {useRouter, useUnload} from "@tarojs/taro";
+import { useAgentStore } from "@/store/agentStore";
+
 export default function Index() {
   const router = useRouter();
-  const { id } = router.params;
-  const deltaNum = id ? 1 : 2
-  let currentComponent = useComponentStore((state)=>  state.currentComponent);
-  const character = useCharacterStore((state)=> state.character);
-  const loading = useComponentStore((state)=> state.loading);
-  const { saveComponent } = useComponentStore();
-  const [value, setValue] = useState(currentComponent?.data?.text ?? '');
-  
-  const handleSave = async () => {
-    if(loading){
-      return
+  const { agentId } = router.params;
+  const agent = useAgentStore((state)=> state.agent)
+  const agentCard = useAgentStore((state)=> state.agentCard)
+  const {editAgentCard} = useAgentStore()
+  const [value, setValue] = useState(agentCard?.name ?? '');
+  const handleSubmit = async () => {
+    if(!agent?.agentId){
+      return;
     }
     if(value.length <= 0){
       return;
     }
-    // const c = {
-    //   data: {
-    //     text: value,
-    //     layout: radioValue,
-    //   },
-    //   enabled: currentComponent?.enabled ?? true,
-    //   id: currentComponent?.id,
-    //   name: currentComponent?.name ?? "姓名",
-    //   index: currentComponent?.index,
-    //   characterProfileId: currentComponent?.characterProfileId ?? character?.profileId,
-    //   type: "title",
-    // };
+    
+    
+
+    
+    await editAgentCard(agent.agentId, {
+      ...agentCard,
+      name: value
+    })
 
     
-    // await saveComponent(c)
   };
 
   const onChange = (e: any) => {
     setValue(e);
   };
-  
-
-  
 
-  const handleNavBack = async () => {
-    await handleSave()
-  }
   
   
 
@@ -73,6 +60,9 @@ export default function Index() {
             />
           </View>
         </View>
+        <BottomBar>
+          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
+        </BottomBar>
       </View>
     </PageCustom>
   );

+ 20 - 34
src/pages/editor-pages/editor-personality/index.tsx

@@ -4,53 +4,40 @@ import { View } from "@tarojs/components";
 import PageCustom from "@/components/page-custom/index";
 import NavBarNormal from "@/components/nav-bar-normal/index";
 import editorStyle from "../editor.module.less";
-import { useComponentStore } from '@/store/componentStore'
-import { useCharacterStore } from '@/store/characterStore'
+import BottomBar from "@/components/BottomBar";
 import WemetaTextarea from "@/components/wemeta-textarea/index";
 import Taro, {useRouter, useUnload} from "@tarojs/taro";
+import { useAgentStore } from "@/store/agentStore";
+
 export default function Index() {
   const router = useRouter();
-  const { id } = router.params;
-  let currentComponent = useComponentStore((state)=>  state.currentComponent);
-  const character = useCharacterStore((state)=> state.character);
-  const loading = useComponentStore((state)=> state.loading);
-  const { saveComponent } = useComponentStore();
-  const [value, setValue] = useState(currentComponent?.data?.text ?? '');
+  const { agentId } = router.params;
+  const agent = useAgentStore((state)=> state.agent)  
+  const {editAgentCharacter} = useAgentStore()  
+  const [value, setValue] = useState(agent?.personality ?? '');
   
-  const handleSave = async () => {
-    if(loading){
+  const handleSubmit = async () => {
+    if(!agent?.agentId){
       return
     }
     if(value.length <= 0){
       return;
     }
-    // const c = {
-    //   data: {
-    //     text: value,
-    //     layout: radioValue,
-    //   },
-    //   enabled: currentComponent?.enabled ?? true,
-    //   id: currentComponent?.id,
-    //   name: currentComponent?.name ?? "姓名",
-    //   index: currentComponent?.index,
-    //   characterProfileId: currentComponent?.characterProfileId ?? character?.profileId,
-    //   type: "title",
-    // };
 
+    await editAgentCharacter(agent.agentId, {
+      enabledPersonalKb: agent.enabledPersonalKb ?? false,
+      greeting: agent.greeting ?? '',
+      personality: value,
+      questionGuides: agent.questionGuides ?? [],
+      voiceId: agent.voiceId ?? '',
+    })
     
-    // await saveComponent(c)
   };
 
   const onChange = (e: any) => {
     setValue(e);
   };
   
-
-  
-
-  const handleNavBack = async () => {
-    await handleSave()
-  }
   
   
 
@@ -72,11 +59,10 @@ export default function Index() {
             />
           </View>
         </View>
-        <View className="bottom-bar">
-          <View className="pt-12 px-20">
-            <View className={`button-rounded button-primary`}>保存</View>
-          </View>
-        </View>
+        
+        <BottomBar>
+          <View className="button-rounded button-primary flex-1" onClick={handleSubmit}>保存</View>
+        </BottomBar>
       </View>
     </PageCustom>
   );

+ 3 - 3
src/pages/index/components/welcome/index.tsx

@@ -16,10 +16,10 @@ export default function Index({children}) {
   const test = ()=> {
     
   }
-  const go = ()=> {
-    getAgents()
+  const go = async () => {
+    const response = await getAgents()
     
-    console.log('gogogo')
+    console.log(response, 'gogogo')
     // return 
     // saveAgent({
     //   address: '浙江杭州余杭文一西路1700号',

+ 4 - 1
src/pages/index/index.tsx

@@ -45,8 +45,11 @@ export default function Index() {
   useEffect(() => {
     if (isLogin) {
       initUserInfo()
+    }else{
+      // Taro.navigateTo({url: '/pages/login/index'})
     }
-    // Taro.navigateTo({url: '/pages/login/index'})
+    // console.log(isLogin,1111)
+    // 
   }, [isLogin])
   
 

+ 11 - 13
src/service/agent.ts

@@ -2,13 +2,13 @@ import {
   bluebookAiAgent,
 } from '@/xiaolanbenlib/api/index'
 import request from '@/xiaolanbenlib/module/axios.js'
-import { TAgentDetail, TComponentItem, TAgent } from '@/types/agent'
+import { TAgentDetail, TComponentItem, TEditAgentCharacter, TAgentContactCard } from '@/types/agent'
 
 
 // 创建一个新的智能体--用户点击创建按钮时调用获取新智能体id与名称信息
-
-export const createAgent = (data: TAgentDetail) => {
-  return request.post<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent`, data)
+// 仅创建一个空智能体
+export const createAgent = () => {
+  return request.post<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent`)
 }
 
 // 获取我的智能体详细信息
@@ -17,6 +17,11 @@ export const getAgent = (agentId: string) => {
   return request.get<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent/${agentId}`)
 }
 
+// 编辑智能体--声音、人设、开场白、问题引导、知识库
+export const editAgentCharacter = (agentId: string, data: TEditAgentCharacter) => {
+  return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/character`, data)
+}
+
 // 编辑智能体--设置形象ID
 export const editAgentAvatar = (agentId: string, avatarUrl: string, enabledChatBg:boolean) => {
   return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/avatar`, {
@@ -24,6 +29,7 @@ export const editAgentAvatar = (agentId: string, avatarUrl: string, enabledChatB
     enabledChatBg,
   })
 }
+
 // 设置当前我的默认智能体
 export const setDefaultAgent = (agentId: string) => {
   return request.put(`${bluebookAiAgent}api/v1/my/agent/${agentId}/default`)
@@ -43,15 +49,7 @@ export const editAgentWebsite = (agentId: string, data: {components: TComponentI
 // name (string, optional): 智能体名称--名片的姓名;长度最多20 ,
 // position (string, optional): 职位,长度最多30 ,
 // qrCodeUrl (string, optional): 二维码地址,长度最多250
-export type TAgentContactCard = {
-  "address"?: string,
-  "email"?: string,
-  "entName"?: string,
-  "mobile"?: string,
-  "name"?: string,
-  "position"?: string,
-  "qrCodeUrl"?: string
-}
+
 
 export const editAgentCard = (agentId: string, data: TAgentContactCard) => {
   return request.put<any, any>(`${bluebookAiAgent}api/v1/my/agent/${agentId}/card`, data)

+ 93 - 44
src/store/agentStore.ts

@@ -1,61 +1,113 @@
-import { create } from 'zustand'
-import {
-  bluebookAiAgent,
-} from '@/xiaolanbenlib/api/index'
-import request from '@/xiaolanbenlib/module/axios.js'
+import { create } from "zustand";
+import { bluebookAiAgent } from "@/xiaolanbenlib/api/index";
+import request from "@/xiaolanbenlib/module/axios.js";
 
-import { createAgent as _createAgent, deleteAgent as _deleteAgent } from "@/service/agent";
-import { TAgentDetail, TAgent } from '@/types/agent'
+import {
+  createAgent as _createAgent,
+  deleteAgent as _deleteAgent,
+  editAgentCard as _editAgentCard,
+  editAgentCharacter as _editAgentCharacter,
+} from "@/service/agent";
+import { TAgentDetail, TAgent, TAgentContactCard, TEditAgentCharacter } from "@/types/agent";
 
 export interface AgentStoreState {
-  agents: TAgent[]
-  agent: TAgentDetail | null
-  fetchAgents: () => Promise<TAgent[]>
-  fetchAgent: (agentId: string) => Promise<TAgentDetail | null>
-  createAgent: (data: TAgentDetail) => Promise<TAgentDetail | null>
+  agents: TAgent[];
+  agent: TAgentDetail | null;
+  agentCard: TAgentContactCard | null;
+  fetchAgents: () => Promise<TAgent[]>;
+  fetchAgent: (agentId: string) => Promise<TAgentDetail | null>;
+  createAgent: (data: TAgentDetail) => Promise<TAgentDetail | null>;
+  editAgentCharacter: (agentId: string, data: TEditAgentCharacter) => Promise<void>;
+  editAgentCard: (
+    agentId: string,
+    data: TAgentContactCard
+  ) => Promise<TAgentContactCard | null>;
   // deleteAgent: (agentId: string) => Promise<void>
 }
 
-
-
-
 export const useAgentStore = create<AgentStoreState>((set, get) => ({
   agents: [],
   agent: null,
+  agentCard: null,
   fetchAgents: async () => {
-    const response = await request.get<TAgent[]>(`${bluebookAiAgent}api/v1/my/agents`)
-    if(response && response?.data?.length){
-      set({ agents: response.data })
-      return response.data
+    const response = await request.get<TAgent[]>(
+      `${bluebookAiAgent}api/v1/my/agents`
+    );
+    if (response && response?.data?.length) {
+      set({ agents: response.data });
+      return response.data;
     }
-    
-    return []
+
+    return [];
   },
   fetchAgent: async (agentId: string) => {
-    const response = await request.get<TAgentDetail>(`${bluebookAiAgent}api/v1/my/agent/${agentId}`)
-    if(response.data){
-      set({ agent: response.data})
-      return response.data
+    const response = await request.get<TAgentDetail>(
+      `${bluebookAiAgent}api/v1/my/agent/${agentId}`
+    );
+    if (response.data) {
+      const agent = response.data;
+      set({
+        agent: response.data,
+        agentCard: {
+          address: agent.address ?? "",
+          email: agent.email ?? "",
+          entName: agent.entName ?? "",
+          mobile: agent.mobile ?? "",
+          name: agent.name ?? "",
+          position: agent.position ?? "",
+          qrCodeUrl: agent.qrCodeUrl ?? "",
+        },
+      });
+
+      return response.data;
     }
-    return null
+    return null;
   },
-  createAgent: async (data: TAgentDetail) => {
-    const newAgent = await request.post(`${bluebookAiAgent}api/v1/my/agent`, data) as TAgentDetail
-    if(newAgent){
+  createAgent: async () => {
+    const response = await _createAgent();
+    if (response.data) {
       set((state) => {
         return {
-          agents: [...state.agents, {
-            "agentId": newAgent.agentId ?? '',
-            "isDefault": newAgent.isDefault ?? false,
-            "isEnt": newAgent.isEnt ?? false,
-            "isNewEnt": newAgent.isNewEnt ?? false,
-            "name": newAgent.name ?? ''
-          }]
-        }
-      })
-      return newAgent
+          agents: [
+            ...state.agents,
+            {
+              agentId: response.data.agentId ?? "",
+              isDefault: response.data.isDefault ?? false,
+              isEnt: response.data.isEnt ?? false,
+              isNewEnt: response.data.isNewEnt ?? false,
+              name: response.data.name ?? "",
+            },
+          ],
+        };
+      });
+      return response.data;
     }
-    return null
+    return null;
+  },
+  editAgentCharacter: async (agentId: string, data: TEditAgentCharacter) => {
+    const response = await _editAgentCharacter(agentId, data);
+    console.log(response.data);
+    
+  },
+  editAgentCard: async (agentId: string, data: TAgentContactCard) => {
+    const response = await _editAgentCard(agentId, data);
+    console.log(response.data);
+    if (response) {
+      // set((state) => {
+      //   return {
+      //     agents: [...state.agents, {
+      //       "agentId": newAgent.agentId ?? '',
+      //       "isDefault": newAgent.isDefault ?? false,
+      //       "isEnt": newAgent.isEnt ?? false,
+      //       "isNewEnt": newAgent.isNewEnt ?? false,
+      //       "name": newAgent.name ?? ''
+      //     }]
+      //   }
+      // })
+      // return newAgent
+      return null;
+    }
+    return null;
   },
   // deleteAgent: async (agentId: string)=> {
   //   const response = await _deleteAgent(agentId)
@@ -68,7 +120,4 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
   //     })
   //   }
   // }
-}))
-
-
-
+}));

+ 1 - 1
src/store/textChat.ts

@@ -14,7 +14,7 @@ export type TRobotMessage = {
   reasoningContent: string
   robot: {
     avatar: string;
-    profileId: string;
+    agentId: string;
     name: string;
   };
 } & TMessage;

+ 39 - 21
src/types/agent.ts

@@ -12,25 +12,43 @@ export type TComponentItem = {
   "type"?: string
 }
 export type TAgentDetail = {
-  "address"?: string,
-  "agentId"?: string,
-  "avatarUrl"?: string,
-  "components"?: TComponentItem[],
-  "email"?: string,
-  "enabledChatBg"?: boolean,
-  "enabledPersonalKb"?: boolean,
-  "entId"?: string,
-  "entName"?: string,
-  "greeting"?: string,
-  "isDefault"?: boolean,
-  "isEnt"?: boolean,
-  "isNewEnt"?: boolean,
-  "isSystemVoice"?: boolean,
-  "mobile"?: string,
-  "name"?: string,
-  "personality"?: string,
-  "position"?: string,
-  "qrCodeUrl"?: string,
-  "questionGuides"?: string[],
-  "voice"?: string
+  address?: string,
+  agentId?: string,
+  avatarUrl?: string,
+  components?: TComponentItem[],
+  email?: string,
+  enabledChatBg?: boolean,
+  enabledPersonalKb?: boolean,
+  entId?: string,
+  entName?: string,
+  greeting?: string,
+  isDefault?: boolean,
+  isEnt?: boolean,
+  isNewEnt?: boolean,
+  isSystemVoice?: boolean,
+  mobile?: string,
+  name?: string,
+  personality?: string,
+  position?: string,
+  qrCodeUrl?: string,
+  questionGuides?: string[],
+  voiceId?: string
+}
+
+export type TAgentContactCard = {
+  address?: string,
+  email?: string,
+  entName?: string,
+  mobile?: string,
+  name?: string,
+  position?: string,
+  qrCodeUrl?: string
+}
+
+export type TEditAgentCharacter = {
+  enabledPersonalKb: boolean,
+  greeting: string,
+  personality: string,
+  questionGuides: string[],
+  voiceId: string
 }

+ 34 - 1
src/utils/index.ts

@@ -359,4 +359,37 @@ export function generateRandomId(): string {
   const timestamp = Date.now().toString(36); // 当前时间戳转换为 base-36 字符串
   const randomNum = Math.random().toString(36).substring(2, 8); // 生成随机数并转换为 base-36 字符串
   return `${timestamp}-${randomNum}`; // 组合时间戳和随机数
-}
+}
+
+
+/**
+ * 生成符合 RFC 4122 标准的 UUID v4
+ * @returns 生成的 UUID 字符串
+ */
+export const generateUUID = (): string => {
+  // 创建16字节(128位)的 ArrayBuffer
+  const buffer = new ArrayBuffer(16);
+  const view = new DataView(buffer);
+  
+  // 使用 Taro 的 getRandomValues 方法填充随机值
+  // 注意:Taro 3+ 版本可能需要使用 Taro.getRandomValues
+  const randomValues = Taro.getRandomValues(new Uint8Array(16));
+  for (let i = 0; i < 16; i++) {
+    view.setUint8(i, randomValues[i]);
+  }
+
+  // 设置版本号(第6-7位为4)
+  view.setUint8(6, (view.getUint8(6) & 0x0f) | 0x40);
+  // 设置变体(第8-9位为10)
+  view.setUint8(8, (view.getUint8(8) & 0x3f) | 0x80);
+
+  // 转换为UUID格式字符串
+  const hex: string[] = [];
+  for (let i = 0; i < 16; i++) {
+    hex.push(view.getUint8(i).toString(16).padStart(2, '0'));
+  }
+  
+  return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${
+    hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${
+    hex.slice(10, 16).join('')}`;
+};

+ 4 - 3
src/xiaolanbenlib/api/auth.ts

@@ -4,6 +4,7 @@ import {
   usercenterbase,
 } from '@/xiaolanbenlib/api/index'
 import request from '@/xiaolanbenlib/module/axios.js'
+import { AxiosResponse } from 'taro-axios'
 
 export interface loginWithoutAuthorizeProps {
   autoPwd: number // "密码是否由系统自动生成(0不是,1是)",
@@ -27,7 +28,7 @@ export interface loginWithoutAuthorizeProps {
 // 小程序小蓝本注册不授权用户信息
 export const loginWithoutAuthorize = async (
   payload,
-): Promise<loginWithoutAuthorizeProps> => {
+): Promise<AxiosResponse<loginWithoutAuthorizeProps>> => {
 
   return request.post(
     `${usercenterbase}usercenter-gateway/api/v2/web/mini/sns/weixin/login/withoutAuthorize`,
@@ -81,7 +82,7 @@ interface WechatUserInfo {
  */
 export const getWechatUserInfoByCode = async (
   code: string,
-): Promise<WechatUserInfo> => {
+): Promise<AxiosResponse<WechatUserInfo>> => {
   return request.post(
     `${usercenterbase}usercenter-gateway/api/v2/web/mini/sns/weixin/login/checkRegister`,
     {
@@ -130,7 +131,7 @@ export interface BetaUser {
   destUrlV2: string
 }
 
-export const getMyInfo = async (): Promise<UserInfoResponse> => {
+export const getMyInfo = async (): Promise< AxiosResponse<UserInfoResponse>> => {
   return request.get(`${bluebookBaseConst}api/v2/user/myInfo`, {
     omitError: true,
   })

+ 1 - 1
src/xiaolanbenlib/hooks/data/useAuth.tsx

@@ -50,7 +50,7 @@ export function loginByMobile({
           icon: 'success',
           duration: 1500,
         })
-        resolve(data)
+        resolve(data.data)
       },
       (err) => {
         console.log(err)

+ 8 - 0
src/xiaolanbenlib/module/sign.js

@@ -136,12 +136,20 @@ export default async function sign (config) {
         config.data = tempData
         return Promise.resolve();
     }
+    if (config.method === 'put') {
+      const tempData = config.data;
+      config.data = JSON.stringify(tempData || {})
+      await runtimeSigner.sign(config)
+      config.data = tempData
+      return Promise.resolve();
+    }
     if (config.method === 'delete') {
       config.method = 'get'
       await runtimeSigner.sign(config)
       config.method = 'delete'
       return Promise.resolve();
     }
+    
     await runtimeSigner.sign(config)
     return Promise.resolve();
 }

+ 6 - 5
src/xiaolanbenlib/utils/auth.ts

@@ -73,7 +73,7 @@ export function getUserInfo() {
 // 获取用户登录
 export const getWechatUserInfo = async () => {
   const code = await getNewCodeIfLogin()
-  const data = await getWechatUserInfoByCode(code)
+  const data = (await getWechatUserInfoByCode(code)).data
 
   return data
 }
@@ -86,10 +86,11 @@ export default function refreshUserId(canUseCache = false) {
   }
   if (Taro.getStorageSync(IS_LOGIN_STORAGE_KEY)) {
     return getMyInfo().then((res) => {
-      Taro.setStorageSync(USER_ID_ENCODED_STORAGE_KEY, res.encodeUserId)
-      Taro.setStorageSync(USER_ID_STORAGE_KEY, res.userId)
-      userInfo = res
-      return res
+      console.log(res,8888)
+      Taro.setStorageSync(USER_ID_ENCODED_STORAGE_KEY, res.data.encodeUserId)
+      Taro.setStorageSync(USER_ID_STORAGE_KEY, res.data.userId)
+      userInfo = res.data
+      return res.data
     })
   } else {
     return Promise.reject(new Error('unauthorized'))