fix: 修复开发模式下,首页请求两次的问题

master
Lxy 3 months ago
parent 02606aeaad
commit c8329f0d07

@ -68,7 +68,7 @@
"enabled": true, "enabled": true,
"username": "windsdreamer", "username": "windsdreamer",
"password": "1qazse42W3", "password": "1qazse42W3",
"pythonPort": 8001 , "pythonPort": 8001,
"timeout": 10000, "timeout": 10000,
"retries": 10, "retries": 10,
"maxConnections": 20 "maxConnections": 20

@ -21,13 +21,20 @@ const Dashboard = () => {
const [pushForm] = Form.useForm(); const [pushForm] = Form.useForm();
const [messageApi, contextHolder] = message.useMessage(); const [messageApi, contextHolder] = message.useMessage();
// refAPI
const fetchingRef = React.useRef(false);
useEffect(() => { useEffect(() => {
dispatch(fetchFuturesOverview()); if (!fetchingRef.current) {
dispatch(fetchRiskAlerts()); fetchingRef.current = true;
dispatch(fetchAIMarketAnalysis()); dispatch(fetchFuturesOverview());
dispatch(fetchRiskAlerts());
dispatch(fetchAIMarketAnalysis());
}
}, [dispatch]); }, [dispatch]);
const handleRefresh = () => { const handleRefresh = () => {
fetchingRef.current = false;
dispatch(fetchFuturesOverview()); dispatch(fetchFuturesOverview());
dispatch(fetchRiskAlerts()); dispatch(fetchRiskAlerts());
dispatch(fetchAIMarketAnalysis()); dispatch(fetchAIMarketAnalysis());

Loading…
Cancel
Save