Commit ecc76730 by Liu

fix:进入页面时业务接口调用时机

parent 9bb6ef57
......@@ -291,11 +291,18 @@ export const Home: React.FC = () => {
useEffect(() => {
login()
}, []) // 依赖数组为空,只在组件挂载时执行一次
useEffect(() => {
// 只有登录成功(拿到 token)后才拉业务接口
if (!token)
return
// 首页首次挂载时重置为通用模式:
// 1. 清除 Redux 中的 currentToolId
dispatch(clearCurrentToolId())
// 2. 拉取常见问题等业务数据
_handleToolClick(false, '', true)
}, []) // 依赖数组为空,只在组件挂载时执行一次
}, [token, dispatch, _handleToolClick])
return (
<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