Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:修复编辑助手名称重名后仍修改全局数据问题 #688

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import EditAssistantDialog from "./EditAssistantDialog";
import { useTranslation } from "react-i18next";
import { useToast } from '@/components/bs-ui/toast/use-toast';
import { captureAndAlertRequestErrorHoc } from '@/controllers/request';
import { saveAssistanttApi } from '@/controllers/API/assistant';

export default function Header({ onSave, onLine }) {
const { t } = useTranslation()
Expand All @@ -18,18 +21,29 @@ export default function Header({ onSave, onLine }) {
{/* 编辑助手 */ }
const [editShow, setEditShow] = useState(false);

const needSaveRef = useRef(false)
useEffect(() => {
if (needSaveRef.current) {
needSaveRef.current = false
onSave()
}
}, [assistantState])
const handleEditSave = (form) => {
dispatchAssistant('setBaseInfo', form)
setEditShow(false)
needSaveRef.current = true
}
const { message } = useToast();

const handleEditSave = async (form) => {
await captureAndAlertRequestErrorHoc(
saveAssistanttApi({
...assistantState,
flow_list: assistantState.flow_list.map((item) => item.id),
tool_list: assistantState.tool_list.map((item) => item.id),
knowledge_list: assistantState.knowledge_list.map((item) => item.id),
guide_question: assistantState.guide_question.filter((item) => item),
...form
})
).then((res) => {
if (!res) return;
message({
title: t('prompt'),
variant: 'success',
description: t('skills.saveSuccessful'),
});
dispatchAssistant('setBaseInfo', form);
setEditShow(false);
});
};

return <div className="flex justify-between items-center border-b px-4">
<div className="flex items-center gap-2 py-4">
Expand Down