|
@@ -19,17 +19,20 @@ import {
|
|
|
TEditAgentCharacter,
|
|
|
TComponentItem,
|
|
|
} from "@/types/agent";
|
|
|
-import { isSuccess, pickNonEmpty } from "@/utils";
|
|
|
+import { isSuccess } from "@/utils";
|
|
|
import Taro from "@tarojs/taro";
|
|
|
|
|
|
export interface AgentStoreState {
|
|
|
agents: TAgent[];
|
|
|
agent: TAgentDetail | 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>;
|
|
|
editAgentCharacter: (
|
|
@@ -50,7 +53,9 @@ export interface AgentStoreState {
|
|
|
export const useAgentStore = create<AgentStoreState>((set, get) => ({
|
|
|
agents: [],
|
|
|
agent: null,
|
|
|
+ agentProfile: null,
|
|
|
agentContactCard: null,
|
|
|
+ agentProfileContactCard: null,
|
|
|
agentCharacter: null,
|
|
|
ents: [],
|
|
|
fetchAgents: async () => {
|
|
@@ -100,6 +105,29 @@ export const useAgentStore = create<AgentStoreState>((set, get) => ({
|
|
|
}
|
|
|
return null;
|
|
|
},
|
|
|
+ fetchAgentProfile: async (agentId: string, shareKey?:string) => {
|
|
|
+ // 如果自己的智能体列表中有 对应的 agentId,则请求自己的 agent, 否则请求无需登录的 getAgent 接口
|
|
|
+ const response = await _getAgent(agentId, shareKey);
|
|
|
+ const result = isSuccess(response.status)
|
|
|
+ if (result && response.data) {
|
|
|
+ const agent = response.data;
|
|
|
+ set({
|
|
|
+ agentProfile: response.data,
|
|
|
+ agentProfileContactCard: {
|
|
|
+ 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;
|
|
|
+ },
|
|
|
setDefaultAgent: async (agentId: string) => {
|
|
|
const response = await _setDefaultAgent(agentId);
|
|
|
const result = isSuccess(response.status)
|