diff --git a/web/src/views/UserMemoryDetail/components/Suggestions.tsx b/web/src/views/UserMemoryDetail/components/Suggestions.tsx index c67c0d80..3b7c1800 100644 --- a/web/src/views/UserMemoryDetail/components/Suggestions.tsx +++ b/web/src/views/UserMemoryDetail/components/Suggestions.tsx @@ -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(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() } diff --git a/web/src/views/UserMemoryDetail/pages/ImplicitDetail.tsx b/web/src/views/UserMemoryDetail/pages/ImplicitDetail.tsx index aa6f40c7..46286fff 100644 --- a/web/src/views/UserMemoryDetail/pages/ImplicitDetail.tsx +++ b/web/src/views/UserMemoryDetail/pages/ImplicitDetail.tsx @@ -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