refactor(frontend): P0 API 层收口与 http 统一

- 统一 http.ts baseURL:get/post/download/upload 均走 resolveApiUrl
- agentUtils 下沉至 lib/agent-utils,API 层移除对 components 的依赖
- 扩展 metricsApi/snmpApi/prometheusProxyApi/zabbixProxyApi
- 扩展 pipelineApi/credentialApi 覆盖流水线与凭证场景
- 14 个组件/页面禁止直连 http,统一走 @/services/api
This commit is contained in:
Logan.Li committed 2026-06-25 23:49:46 +08:00
1 parent bfd6431b9d
commit 7fb2236b4d
27 files changed
+194 -150

No files matched your search

@@ -6,7 +6,7 @@ import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { StatStrip } from '@/components/ui/stat-strip';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { http } from '@/services/http';
import { prometheusProxyApi } from '@/services/api';
interface Props { dsUrl?: string; }
@@ -139,7 +139,7 @@ export const PrometheusDashboard: React.FC<Props> = ({ dsUrl }) => {
const doConnect = async (u: string) => {
setLoading(true); setError('');
try {
const data: Record<string, any> = await http.post('/prometheus/connect', { url: u });
const data: Record<string, any> = await prometheusProxyApi.connect(u);
setConnected(true); setTargets(data.targets||0);
loadAll(u);
} catch (e: any) { setConnected(false); setError((e as Record<string, any>).message||'连接失败'); }
@@ -149,7 +149,7 @@ export const PrometheusDashboard: React.FC<Props> = ({ dsUrl }) => {
const loadAll = async (u: string) => {
for (const t of ['kubernetes','node','pod','jvm']) {
try {
const data: Record<string, any> = await http.post('/prometheus/dashboard', { url: u, type: t });
const data: Record<string, any> = await prometheusProxyApi.dashboard(u, t);
const items: Record<string, any> = {};
for (const [k, v] of Object.entries(data||{}))
items[k] = Array.isArray(v) ? v : ((v as Record<string, any>)?.data?.result ? parsePrune((v as Record<string, any>).data.result) : v);