fix(web): use modal.warning replace modal.confirm
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-03-04 16:22:03
|
* @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 { useTranslation } from 'react-i18next'
|
||||||
import { useParams } from 'react-router-dom'
|
import { useParams } from 'react-router-dom'
|
||||||
import { App } from 'antd'
|
import { App } from 'antd'
|
||||||
@@ -43,9 +43,11 @@ const Suggestions = forwardRef<{ handleRefresh: () => void; }, { refresh: () =>
|
|||||||
const { modal } = App.useApp()
|
const { modal } = App.useApp()
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [suggestions, setSuggestions] = useState<Suggestions | null>(null)
|
const [suggestions, setSuggestions] = useState<Suggestions | null>(null)
|
||||||
|
const modalInstanceRef = useRef<{ destroy: () => void } | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getSuggestionData()
|
getSuggestionData()
|
||||||
|
return () => modalInstanceRef.current?.destroy()
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
const getSuggestionData = () => {
|
const getSuggestionData = () => {
|
||||||
@@ -57,10 +59,9 @@ const Suggestions = forwardRef<{ handleRefresh: () => void; }, { refresh: () =>
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
const response = res as Suggestions
|
const response = res as Suggestions
|
||||||
if (!response.exists && (!response.suggestions || !response.suggestions?.length)) {
|
if (!response.exists && (!response.suggestions || !response.suggestions?.length)) {
|
||||||
modal.confirm({
|
modalInstanceRef.current = modal.warning({
|
||||||
title: t('statementDetail.noData'),
|
title: t('statementDetail.noData'),
|
||||||
okText: t('common.refresh'),
|
okText: t('common.refresh'),
|
||||||
cancelText: t('common.cancel'),
|
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,19 +36,20 @@ const ImplicitDetail = forwardRef<{ handleRefresh: () => void; }, { refresh: ()
|
|||||||
// Check if implicit data exists, prompt user to initialize if not
|
// Check if implicit data exists, prompt user to initialize if not
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!id) return
|
if (!id) return
|
||||||
|
let modalInstance: { destroy: () => void } | null = null
|
||||||
implicitCheckData(id)
|
implicitCheckData(id)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (!(res as { exists: boolean }).exists) {
|
if (!(res as { exists: boolean }).exists) {
|
||||||
modal.confirm({
|
modalInstance = modal.warning({
|
||||||
title: t('implicitDetail.noData'),
|
title: t('implicitDetail.noData'),
|
||||||
okText: t('common.refresh'),
|
okText: t('common.refresh'),
|
||||||
cancelText: t('common.cancel'),
|
onOk: () => {
|
||||||
onOk: () => {
|
refresh()
|
||||||
refresh()
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
return () => modalInstance?.destroy()
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
// Refresh all implicit memory components by regenerating profile
|
// Refresh all implicit memory components by regenerating profile
|
||||||
|
|||||||
Reference in New Issue
Block a user