fix: 修复ConfigForm和EmbeddingConfigForm组件watch死循环导致内存溢出 [AC-AISVC-50]

This commit is contained in:
MerCry 2026-02-26 12:30:04 +08:00
parent 6c16132557
commit 3f1f4cd98d
2 changed files with 14 additions and 0 deletions

View File

@ -92,6 +92,7 @@ const emit = defineEmits<{
const formRef = ref<FormInstance>()
const formData = ref<Record<string, any>>({})
const isUpdating = ref(false)
const schemaProperties = computed(() => {
return props.schema?.properties || {}
@ -174,6 +175,7 @@ const initFormData = () => {
watch(
() => props.modelValue,
(newVal) => {
if (isUpdating.value) return
if (JSON.stringify(newVal) !== JSON.stringify(formData.value)) {
initFormData()
}
@ -192,8 +194,13 @@ watch(
watch(
formData,
(val) => {
if (isUpdating.value) return
if (JSON.stringify(val) !== JSON.stringify(props.modelValue)) {
isUpdating.value = true
emit('update:modelValue', val)
Promise.resolve().then(() => {
isUpdating.value = false
})
}
},
{ deep: true }

View File

@ -92,6 +92,7 @@ const emit = defineEmits<{
const formRef = ref<FormInstance>()
const formData = ref<Record<string, any>>({})
const isUpdating = ref(false)
const schemaProperties = computed(() => {
return props.schema?.properties || {}
@ -174,6 +175,7 @@ const initFormData = () => {
watch(
() => props.modelValue,
(newVal) => {
if (isUpdating.value) return
if (JSON.stringify(newVal) !== JSON.stringify(formData.value)) {
initFormData()
}
@ -192,8 +194,13 @@ watch(
watch(
formData,
(val) => {
if (isUpdating.value) return
if (JSON.stringify(val) !== JSON.stringify(props.modelValue)) {
isUpdating.value = true
emit('update:modelValue', val)
Promise.resolve().then(() => {
isUpdating.value = false
})
}
},
{ deep: true }