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:
@@ -3,11 +3,9 @@
|
||||
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { logger } from "@utils/logger";
|
||||
import { getApiBase } from "@utils/apiConfig";
|
||||
import axios from "@utils/axiosConfig";
|
||||
import type { Announcement } from "../types";
|
||||
|
||||
const API_BASE_URL = getApiBase();
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
data: T;
|
||||
@@ -35,10 +33,9 @@ export const useAnnouncementsData = (stockCode?: string): UseAnnouncementsDataRe
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/api/stock/${stockCode}/announcements?limit=20`
|
||||
const { data: result } = await axios.get<ApiResponse<Announcement[]>>(
|
||||
`/api/stock/${stockCode}/announcements?limit=20`
|
||||
);
|
||||
const result = (await response.json()) as ApiResponse<Announcement[]>;
|
||||
|
||||
if (result.success) {
|
||||
setAnnouncements(result.data);
|
||||
|
||||
Reference in New Issue
Block a user