Merge pull request #461 from SuanmoSuanyangTechnology/fix/memory_web_zy

fix(web): use modal.warning replace modal.confirm
This commit is contained in:
yingzhao
2026-03-05 10:02:19 +08:00
committed by GitHub
2 changed files with 13 additions and 11 deletions

View File

@@ -4,7 +4,7 @@
* @Last Modified by: ZhaoYing
* @Last Modified time: 2026-03-04 16:22:03
*/
import { useEffect, useState, forwardRef, useImperativeHandle } from 'react'
import { useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import { App } from 'antd'
@@ -43,9 +43,11 @@ const Suggestions = forwardRef<{ handleRefresh: () => void; }, { refresh: () =>
const { modal } = App.useApp()
const [loading, setLoading] = useState(false)
const [suggestions, setSuggestions] = useState<Suggestions | null>(null)
const modalInstanceRef = useRef<{ destroy: () => void } | null>(null)
useEffect(() => {
getSuggestionData()
return () => modalInstanceRef.current?.destroy()
}, [id])
const getSuggestionData = () => {
@@ -57,10 +59,9 @@ const Suggestions = forwardRef<{ handleRefresh: () => void; }, { refresh: () =>
.then((res) => {
const response = res as Suggestions
if (!response.exists && (!response.suggestions || !response.suggestions?.length)) {
modal.confirm({
modalInstanceRef.current = modal.warning({
title: t('statementDetail.noData'),
okText: t('common.refresh'),
cancelText: t('common.cancel'),
onOk: () => {
refresh()
}

View File

@@ -36,19 +36,20 @@ const ImplicitDetail = forwardRef<{ handleRefresh: () => void; }, { refresh: ()
// Check if implicit data exists, prompt user to initialize if not
useEffect(() => {
if (!id) return
let modalInstance: { destroy: () => void } | null = null
implicitCheckData(id)
.then(res => {
if (!(res as { exists: boolean }).exists) {
modal.confirm({
title: t('implicitDetail.noData'),
okText: t('common.refresh'),
cancelText: t('common.cancel'),
onOk: () => {
refresh()
}
})
modalInstance = modal.warning({
title: t('implicitDetail.noData'),
okText: t('common.refresh'),
onOk: () => {
refresh()
}
})
}
})
return () => modalInstance?.destroy()
}, [id])
// Refresh all implicit memory components by regenerating profile