mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 10:28:42 +00:00
perf: optimize simple app history (#2782)
* simple app history * ui * extract context content into hooks
This commit is contained in:
@@ -15,8 +15,8 @@ export const getAppLatestVersion = (data: getLatestVersionQuery) =>
|
||||
export const postPublishApp = (appId: string, data: PostPublishAppProps) =>
|
||||
POST(`/core/app/version/publish?appId=${appId}`, data);
|
||||
|
||||
export const getPublishList = (data: PaginationProps<{ appId: string }>) =>
|
||||
POST<PaginationResponse<AppVersionSchemaType>>('/core/app/version/list', data);
|
||||
// export const getPublishList = (data: PaginationProps<{ appId: string }>) =>
|
||||
// POST<PaginationResponse<AppVersionSchemaType>>('/core/app/version/list', data);
|
||||
|
||||
export const getWorkflowVersionList = (data: PaginationProps<{ appId: string }>) =>
|
||||
POST<PaginationResponse<versionListResponse>>('/core/app/version/listWorkflow', data);
|
||||
@@ -24,8 +24,8 @@ export const getWorkflowVersionList = (data: PaginationProps<{ appId: string }>)
|
||||
export const getAppVersionDetail = (versionId: string, appId: string) =>
|
||||
GET<AppVersionSchemaType>(`/core/app/version/detail?versionId=${versionId}&appId=${appId}`);
|
||||
|
||||
export const postRevertVersion = (appId: string, data: PostRevertAppProps) =>
|
||||
POST(`/core/app/version/revert?appId=${appId}`, data);
|
||||
// export const postRevertVersion = (appId: string, data: PostRevertAppProps) =>
|
||||
// POST(`/core/app/version/revert?appId=${appId}`, data);
|
||||
|
||||
export const updateAppVersion = (data: UpdateAppVersionBody) =>
|
||||
POST(`/core/app/version/update`, data);
|
||||
|
@@ -438,94 +438,6 @@ export const getLatestNodeTemplate = (
|
||||
return updatedNode;
|
||||
};
|
||||
|
||||
type WorkflowType = {
|
||||
nodes: StoreNodeItemType[];
|
||||
edges: StoreEdgeItemType[];
|
||||
chatConfig: AppChatConfigType;
|
||||
};
|
||||
export const compareWorkflow = (workflow1: WorkflowType, workflow2: WorkflowType) => {
|
||||
const clone1 = cloneDeep(workflow1);
|
||||
const clone2 = cloneDeep(workflow2);
|
||||
|
||||
if (!isEqual(clone1.edges, clone2.edges)) {
|
||||
console.log('Edge not equal');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
clone1.chatConfig &&
|
||||
clone2.chatConfig &&
|
||||
!isEqual(
|
||||
{
|
||||
welcomeText: clone1.chatConfig?.welcomeText || '',
|
||||
variables: clone1.chatConfig?.variables || [],
|
||||
questionGuide: clone1.chatConfig?.questionGuide || false,
|
||||
ttsConfig: clone1.chatConfig?.ttsConfig || undefined,
|
||||
whisperConfig: clone1.chatConfig?.whisperConfig || undefined,
|
||||
scheduledTriggerConfig: clone1.chatConfig?.scheduledTriggerConfig || undefined,
|
||||
chatInputGuide: clone1.chatConfig?.chatInputGuide || undefined,
|
||||
fileSelectConfig: clone1.chatConfig?.fileSelectConfig || undefined
|
||||
},
|
||||
{
|
||||
welcomeText: clone2.chatConfig?.welcomeText || '',
|
||||
variables: clone2.chatConfig?.variables || [],
|
||||
questionGuide: clone2.chatConfig?.questionGuide || false,
|
||||
ttsConfig: clone2.chatConfig?.ttsConfig || undefined,
|
||||
whisperConfig: clone2.chatConfig?.whisperConfig || undefined,
|
||||
scheduledTriggerConfig: clone2.chatConfig?.scheduledTriggerConfig || undefined,
|
||||
chatInputGuide: clone2.chatConfig?.chatInputGuide || undefined,
|
||||
fileSelectConfig: clone2.chatConfig?.fileSelectConfig || undefined
|
||||
}
|
||||
)
|
||||
) {
|
||||
console.log('chatConfig not equal');
|
||||
return false;
|
||||
}
|
||||
|
||||
const formatNodes = (nodes: StoreNodeItemType[]) => {
|
||||
return nodes
|
||||
.filter((node) => {
|
||||
if (!node) return;
|
||||
if ([FlowNodeTypeEnum.systemConfig].includes(node.flowNodeType)) return;
|
||||
|
||||
return true;
|
||||
})
|
||||
.map((node) => ({
|
||||
flowNodeType: node.flowNodeType,
|
||||
inputs: node.inputs.map((input) => ({
|
||||
key: input.key,
|
||||
selectedTypeIndex: input.selectedTypeIndex ?? 0,
|
||||
renderTypeLis: input.renderTypeList,
|
||||
valueType: input.valueType,
|
||||
value: input.value ?? undefined
|
||||
})),
|
||||
outputs: node.outputs.map((item) => ({
|
||||
key: item.key,
|
||||
type: item.type,
|
||||
value: item.value ?? undefined
|
||||
})),
|
||||
name: node.name,
|
||||
intro: node.intro,
|
||||
avatar: node.avatar,
|
||||
version: node.version,
|
||||
position: node.position
|
||||
}));
|
||||
};
|
||||
const node1 = formatNodes(clone1.nodes);
|
||||
const node2 = formatNodes(clone2.nodes);
|
||||
|
||||
// console.log(node1);
|
||||
// console.log(node2);
|
||||
|
||||
node1.forEach((node, i) => {
|
||||
if (!isEqual(node, node2[i])) {
|
||||
console.log('node not equal');
|
||||
}
|
||||
});
|
||||
|
||||
return isEqual(node1, node2);
|
||||
};
|
||||
|
||||
export const compareSnapshot = (
|
||||
snapshot1: {
|
||||
nodes: Node<FlowNodeItemType, string | undefined>[] | undefined;
|
||||
|
Reference in New Issue
Block a user