feat(web): add loading
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-05 10:44:08
|
* @Date: 2026-02-05 10:44:08
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-02-05 10:52:29
|
* @Last Modified time: 2026-02-05 10:56:28
|
||||||
*/
|
*/
|
||||||
import { type FC, useEffect, useRef, useState } from "react";
|
import { type FC, useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -15,7 +15,7 @@ import AiPromptModal from '@/views/ApplicationConfig/components/AiPromptModal'
|
|||||||
import ToolList from '../components/ToolList/ToolList'
|
import ToolList from '../components/ToolList/ToolList'
|
||||||
import type { AiPromptModalRef } from '@/views/ApplicationConfig/types'
|
import type { AiPromptModalRef } from '@/views/ApplicationConfig/types'
|
||||||
import exitIcon from '@/assets/images/knowledgeBase/exit.png';
|
import exitIcon from '@/assets/images/knowledgeBase/exit.png';
|
||||||
import type { SkillFormData, Skill } from '../types'
|
import type { SkillFormData } from '../types'
|
||||||
import { getSkillDetail, createSkill, updateSkill } from '@/api/skill'
|
import { getSkillDetail, createSkill, updateSkill } from '@/api/skill'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +42,6 @@ const SkillConfig: FC = () => {
|
|||||||
const { message } = App.useApp()
|
const { message } = App.useApp()
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [form] = Form.useForm<SkillFormData>();
|
const [form] = Form.useForm<SkillFormData>();
|
||||||
const [data, setData] = useState<Skill>({} as Skill)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effect: Load skill data if editing existing skill
|
* Effect: Load skill data if editing existing skill
|
||||||
@@ -69,7 +68,6 @@ const SkillConfig: FC = () => {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
getSkillDetail(id)
|
getSkillDetail(id)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setData(res as Skill)
|
|
||||||
form.setFieldsValue(res as SkillFormData)
|
form.setFieldsValue(res as SkillFormData)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -108,7 +106,6 @@ const SkillConfig: FC = () => {
|
|||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
form.validateFields()
|
form.validateFields()
|
||||||
.then((values) => {
|
.then((values) => {
|
||||||
console.log(values, data)
|
|
||||||
const { tools, ...rest } = values;
|
const { tools, ...rest } = values;
|
||||||
// Format tools data for API
|
// Format tools data for API
|
||||||
const formData = {
|
const formData = {
|
||||||
@@ -118,6 +115,7 @@ const SkillConfig: FC = () => {
|
|||||||
operation: item.operation
|
operation: item.operation
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
setLoading(true)
|
||||||
// Choose create or update based on whether id exists
|
// Choose create or update based on whether id exists
|
||||||
const request = id ? updateSkill(id, formData) : createSkill(formData)
|
const request = id ? updateSkill(id, formData) : createSkill(formData)
|
||||||
request
|
request
|
||||||
|
|||||||
Reference in New Issue
Block a user