Commit 9112f406 by Liu

fix:常见问题接口重复调用

parent b4204fda
...@@ -120,13 +120,6 @@ export const Home: React.FC = () => { ...@@ -120,13 +120,6 @@ export const Home: React.FC = () => {
setIsDataLoaded(false) // 重置加载状态 setIsDataLoaded(false) // 重置加载状态
try { try {
const storedToolId = safeSessionStorageGetItem('currentToolId') || '' const storedToolId = safeSessionStorageGetItem('currentToolId') || ''
// eslint-disable-next-line no-console
console.log('20251211 _handleToolClick before calc', {
isToolBtn,
toolId,
ignoreUrlToolId,
storedToolId,
})
// 首页初始化加载常见问题时,允许忽略路由中的 toolId,避免带入上一次的工具 ID // 首页初始化加载常见问题时,允许忽略路由中的 toolId,避免带入上一次的工具 ID
const shouldForceClearToolId = !storedToolId const shouldForceClearToolId = !storedToolId
...@@ -147,13 +140,6 @@ export const Home: React.FC = () => { ...@@ -147,13 +140,6 @@ export const Home: React.FC = () => {
// 调用真实 API 获取常见问题列表,优先使用 sessionStorage 中的 currentToolId // 调用真实 API 获取常见问题列表,优先使用 sessionStorage 中的 currentToolId
const sessionToolId = safeSessionStorageGetItem('currentToolId') || '' const sessionToolId = safeSessionStorageGetItem('currentToolId') || ''
// 调试:记录最终用于请求的 toolId
// 20251211 调试:记录最终用于请求的 toolId
// eslint-disable-next-line no-console
console.log('20251211 _handleToolClick fetch', {
sessionToolId,
finalToolId,
})
const res = await fetchEfficiencyQuestionList({ const res = await fetchEfficiencyQuestionList({
toolId: sessionToolId || finalToolId, toolId: sessionToolId || finalToolId,
}) })
...@@ -246,7 +232,7 @@ export const Home: React.FC = () => { ...@@ -246,7 +232,7 @@ export const Home: React.FC = () => {
window.dispatchEvent(new CustomEvent('forceResetToGeneralMode')) window.dispatchEvent(new CustomEvent('forceResetToGeneralMode'))
initConversation() initConversation()
dispatch(fetchConversations()) dispatch(fetchConversations())
// 2. 拉取常见问题等业务数据 // 2. 拉取常见问题等业务数据
_handleToolClick(false, '', true) _handleToolClick(false, '', true)
} }
} }
...@@ -301,10 +287,8 @@ export const Home: React.FC = () => { ...@@ -301,10 +287,8 @@ export const Home: React.FC = () => {
// 只有登录成功(拿到 token)后才拉业务接口 // 只有登录成功(拿到 token)后才拉业务接口
if (!token) if (!token)
return return
// 首页首次挂载时重置为制度活化:
// 1. 清除 Redux 中的 currentToolId
dispatch(clearCurrentToolId()) dispatch(clearCurrentToolId())
}, [token, dispatch, _handleToolClick]) }, [token, dispatch])
return ( return (
<div className={styles.homePage}> <div className={styles.homePage}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment