feat(DeepAnalysis): 增强策略Tab功能
- 新增策略相关类型定义 - StrategyTab 功能增强 - 调整组件结构
This commit is contained in:
@@ -40,17 +40,20 @@ const DeepAnalysis = ({ stockCode }) => {
|
||||
const [comprehensiveData, setComprehensiveData] = useState(null);
|
||||
const [valueChainData, setValueChainData] = useState(null);
|
||||
const [keyFactorsData, setKeyFactorsData] = useState(null);
|
||||
const [industryRankData, setIndustryRankData] = useState(null);
|
||||
|
||||
// 各接口独立的 loading 状态
|
||||
const [comprehensiveLoading, setComprehensiveLoading] = useState(false);
|
||||
const [valueChainLoading, setValueChainLoading] = useState(false);
|
||||
const [keyFactorsLoading, setKeyFactorsLoading] = useState(false);
|
||||
const [industryRankLoading, setIndustryRankLoading] = useState(false);
|
||||
|
||||
// 已加载的接口记录(用于缓存判断)
|
||||
const loadedApisRef = useRef({
|
||||
comprehensive: false,
|
||||
valueChain: false,
|
||||
keyFactors: false,
|
||||
industryRank: false,
|
||||
});
|
||||
|
||||
// 业务板块展开状态
|
||||
@@ -114,6 +117,17 @@ const DeepAnalysis = ({ stockCode }) => {
|
||||
}
|
||||
break;
|
||||
|
||||
case "industryRank":
|
||||
setIndustryRankLoading(true);
|
||||
const industryRankRes = await fetch(
|
||||
`${API_BASE_URL}/api/financial/industry-rank/${stockCode}`
|
||||
).then((r) => r.json());
|
||||
if (currentStockCodeRef.current === stockCode) {
|
||||
if (industryRankRes.success) setIndustryRankData(industryRankRes.data);
|
||||
loadedApisRef.current.industryRank = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -126,6 +140,7 @@ const DeepAnalysis = ({ stockCode }) => {
|
||||
if (apiKey === "comprehensive") setComprehensiveLoading(false);
|
||||
if (apiKey === "valueChain") setValueChainLoading(false);
|
||||
if (apiKey === "keyFactors") setKeyFactorsLoading(false);
|
||||
if (apiKey === "industryRank") setIndustryRankLoading(false);
|
||||
}
|
||||
},
|
||||
[stockCode]
|
||||
@@ -165,17 +180,20 @@ const DeepAnalysis = ({ stockCode }) => {
|
||||
setComprehensiveData(null);
|
||||
setValueChainData(null);
|
||||
setKeyFactorsData(null);
|
||||
setIndustryRankData(null);
|
||||
setExpandedSegments({});
|
||||
loadedApisRef.current = {
|
||||
comprehensive: false,
|
||||
valueChain: false,
|
||||
keyFactors: false,
|
||||
industryRank: false,
|
||||
};
|
||||
|
||||
// 重置为默认 Tab 并加载数据
|
||||
setActiveTab("strategy");
|
||||
// 加载默认 Tab 的数据
|
||||
// 加载默认 Tab 的数据(战略分析需要 comprehensive 和 industryRank)
|
||||
loadApiData("comprehensive");
|
||||
loadApiData("industryRank");
|
||||
}
|
||||
}, [stockCode, loadApiData]);
|
||||
|
||||
@@ -199,6 +217,7 @@ const DeepAnalysis = ({ stockCode }) => {
|
||||
comprehensiveData={comprehensiveData}
|
||||
valueChainData={valueChainData}
|
||||
keyFactorsData={keyFactorsData}
|
||||
industryRankData={industryRankData}
|
||||
loading={getCurrentLoading()}
|
||||
cardBg="white"
|
||||
expandedSegments={expandedSegments}
|
||||
|
||||
Reference in New Issue
Block a user