refactor(Company): fetch 请求迁移至 axios

- DeepAnalysis: 4 个 fetch → axios
- DynamicTracking: 3 个 fetch → axios (NewsPanel, ForecastPanel)
- MarketDataView/services: 4 个 fetch → axios
- CompanyOverview/hooks: 9 个 fetch → axios (6 个文件)
- StockQuoteCard/hooks: 1 个 fetch → axios
- ValueChainNodeCard: 1 个 fetch → axios

清理:
- 删除未使用的 useCompanyOverviewData.ts
- 移除所有 getApiBase/API_BASE_URL 引用

总计: 22 个 fetch 调用迁移, 复用项目已有的 axios 拦截器配置

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-17 11:54:32 +08:00
parent c4900bd280
commit c83d239219
13 changed files with 62 additions and 257 deletions

View File

@@ -12,9 +12,7 @@ import {
} from '@chakra-ui/react';
import { Tag } from 'antd';
import { logger } from '@utils/logger';
import { getApiBase } from '@utils/apiConfig';
const API_BASE_URL = getApiBase();
import axios from '@utils/axiosConfig';
// 黑金主题
const THEME = {
@@ -53,10 +51,9 @@ const ForecastPanel = ({ stockCode }) => {
setLoading(true);
try {
const response = await fetch(
`${API_BASE_URL}/api/stock/${stockCode}/forecast`
const { data: result } = await axios.get(
`/api/stock/${stockCode}/forecast`
);
const result = await response.json();
if (result.success && result.data) {
setForecast(result.data);
}

View File

@@ -3,11 +3,9 @@
import React, { useState, useEffect, useCallback } from 'react';
import { logger } from '@utils/logger';
import { getApiBase } from '@utils/apiConfig';
import axios from '@utils/axiosConfig';
import NewsEventsTab from '../../CompanyOverview/NewsEventsTab';
const API_BASE_URL = getApiBase();
const NewsPanel = ({ stockCode }) => {
const [newsEvents, setNewsEvents] = useState([]);
const [loading, setLoading] = useState(false);
@@ -25,10 +23,9 @@ const NewsPanel = ({ stockCode }) => {
// 获取股票名称
const fetchStockName = useCallback(async () => {
try {
const response = await fetch(
`${API_BASE_URL}/api/stock/${stockCode}/basic-info`
const { data: result } = await axios.get(
`/api/stock/${stockCode}/basic-info`
);
const result = await response.json();
if (result.success && result.data) {
const name = result.data.SECNAME || result.data.ORGNAME || stockCode;
setStockName(name);
@@ -47,10 +44,9 @@ const NewsPanel = ({ stockCode }) => {
setLoading(true);
try {
const searchTerm = query || stockName || stockCode;
const response = await fetch(
`${API_BASE_URL}/api/events?q=${encodeURIComponent(searchTerm)}&page=${page}&per_page=10`
const { data: result } = await axios.get(
`/api/events?q=${encodeURIComponent(searchTerm)}&page=${page}&per_page=10`
);
const result = await response.json();
if (result.success) {
setNewsEvents(result.data || []);