refactor(frontend): API 子模块化、大组件拆分与 TanStack Query hooks

P1: kubernetes/system API 拆为子目录模块,导出工具下沉到 lib/export-utils,
    http 统一 buildApiUrl/getWsBase;HostMonitor、DeploymentEdit* 拆至子组件。

P2: 新增 hooks/api(queryKeys、useTerminalSessions、useHostMonitor),
    TerminalSessionsTab 与 HostMonitor 接入 TanStack Query。

P3: 保留 services/api 路径,未迁移至 api/ 目录。
This commit is contained in:
Logan.Li committed 2026-06-26 00:02:29 +08:00
1 parent 7fb2236b4d
commit 0b404b4611
226 files changed
+3040 -2596

No files matched your search

@@ -0,0 +1 @@
import{r,j as e,B as y,O as le,J as he,D as Q,a as q,b as H,c as J,Q as ge,d as Z,a4 as w,a5 as ue,C as Te,P as je,V as Me,o as Ne,a6 as fe,S as ve}from"./index-Dmami9WE.js";import{I as ye}from"./input-NsU9nXZF.js";import{B as j}from"./badge-3UzCvU7L.js";import{C as M,a as N,b as S,c as b}from"./card-CIfC-8Rh.js";import{S as we}from"./stat-strip-BteRU1Iu.js";import{S as C,a as D,b as I,c as L,d as n}from"./select-DUbxjT0z.js";import{T as Se,a as be,b as O,c as R}from"./tabs-lV44z_UR.js";import{L as s}from"./label-Ap_-SPYI.js";import{t as B}from"./index-BuEnLCjT.js";import{t as F}from"./monitor-CicbJUrQ.js";import{S as Ce}from"./search-Dd-PeBfg.js";import{R as De}from"./refresh-cw-CTBERyFc.js";import{T as Ie}from"./trending-up-d1DKmRom.js";import{C as Le}from"./circle-x-BBQeW1R3.js";import{C as Oe}from"./code-BAhZJUYV.js";import{B as Re}from"./box-88Ol5qY-.js";import{Z as Be}from"./zap-CocSkPPl.js";import{A as Fe}from"./arrow-right-CkKR0P0R.js";import"./index-CtCQcvyh.js";import"./chevron-up-Cq4GPopa.js";const aa=()=>{const[k,G]=r.useState([]),[p,K]=r.useState([]),[U,A]=r.useState(!1),[f,X]=r.useState(""),[l,W]=r.useState("all"),[h,Y]=r.useState("all"),[g,_]=r.useState("1h"),[ee,ae]=r.useState("traces"),[m,te]=r.useState(null),[o,re]=r.useState(null),[ce,E]=r.useState(!1),[se,$]=r.useState(!1);r.useEffect(()=>{oe()},[g]);const oe=async()=>{await Promise.all([P(),ne()])},P=async()=>{A(!0);try{const a=await F.getTraces({timeRange:g,service:l,status:h});G(a.data||[])}catch{B.error("获取链路数据失败")}finally{A(!1)}},ne=async()=>{try{const a=await F.getServices(g);K(a.data||[])}catch{B.error("获取服务数据失败")}},me=async a=>{try{return(await F.getTraceDetail(a)).data}catch{return B.error("获取链路详情失败"),null}},v=a=>{switch(a){case"success":return e.jsxs(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:141:16",variant:"default",className:"bg-green-500 gap-1",children:[e.jsx(je,{"code-path":"src/components/monitor/trace/TraceManager.tsx:141:72",className:"w-3 h-3"}),"成功"]});case"error":return e.jsxs(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:143:16",variant:"destructive",className:"gap-1",children:[e.jsx(Le,{"code-path":"src/components/monitor/trace/TraceManager.tsx:143:63",className:"w-3 h-3"}),"错误"]});case"pending":return e.jsxs(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:145:16",variant:"outline",className:"gap-1",children:[e.jsx(Te,{"code-path":"src/components/monitor/trace/TraceManager.tsx:145:59",className:"w-3 h-3"}),"进行中"]});default:return e.jsx(j,{"code-path":"src/components/monitor/trace/TraceManager.tsx:147:16",variant:"secondary",children:"未知"})}},ie=a=>{switch(a){case"client":return e.jsx(Fe,{"code-path":"src/components/monitor/trace/TraceManager.tsx:153:29",className:"w-4 h-4"});case"server":return e.jsx(ve,{"code-path":"src/components/monitor/trace/TraceManager.tsx:154:29",className:"w-4 h-4"});case"producer":return e.jsx(Be,{"code-path":"src/components/monitor/trace/TraceManager.tsx:155:31",className:"w-4 h-4"});case"consumer":return e.jsx(Re,{"code-path":"src/components/monitor/trace/TraceManager.tsx:156:31",className:"w-4 h-4"});default:return e.jsx(Oe,{"code-path":"src/components/monitor/trace/TraceManager.tsx:157:23",className:"w-4 h-4"})}},de=a=>{switch(a){case"success":return"bg-green-500";case"error":return"bg-red-500";case"pending":return"bg-yellow-500";default:return"bg-gray-500"}},i=a=>a<1?`${(a*1e3).toFixed(2)}μs`:a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`,V=k.filter(a=>{const t=a.traceId.toLowerCase().includes(f.toLowerCase())||a.operationName.toLowerCase().includes(f.toLowerCase()),d=l==="all"||a.serviceName===l,c=h==="all"||a.status===h;return t&&d&&c}),pe=Array.from(new Set(k.map(a=>a.serviceName))),xe=a=>{const t=new Map,d=[];return a.forEach(c=>{t.set(c.spanId,{...c,children:[]})}),a.forEach(c=>{const u=t.get(c.spanId);if(c.parentSpanId&&t.has(c.parentSpanId)){const x=t.get(c.parentSpanId);x.children=x.children||[],x.children.push(u)}else d.push(u)}),d},z=({span:a,level:t,totalDuration:d})=>{const[c,u]=r.useState(!0),x=d>0?a.duration/d*100:0;return e.jsxs("div",{"code-path":"src/components/monitor/trace/TraceManager.tsx:216:7",className:"select-none",children:[e.jsxs("div",{"code-path":"src/components/monitor/trace/TraceManager.tsx:217:9",className:"flex items-center py-2 hover:bg-muted/50 cursor-pointer border-l-2 border-transparent hover:border-blue-500",style:{paddingLeft:`${t*24+12}px`},onClick:()=>{re(a),$(!0)},children:[a.children?.length>0&&e.jsx(y,{"code-path":"src/components/monitor/trace/TraceManager.tsx:223:13",variant:"ghost",size:"sm",className:"h-4 w-4 p-0 mr-1",onClick:T=>{T.stopPropagation(),u(!c)},children:c?e.jsx(Me,{"code-path":"src/components/monitor/trace/TraceManager.tsx:229:27",className:"w-3 h-3"}):e.jsx(Ne,{"code-path":"src/components/monitor/trace/TraceManager.tsx:229:65",className:"w-3 h-3"})}),!a.children?.length&&e.jsx("span",{"code-path":"src/compLine truncated