chore: 重新编译前端产物(补装CodeMirror依赖)
This commit is contained in:
1 parent
23e9e3da62
commit
4e384ca401
115 files changed
+147
-147
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import{r,j as e}from"./vendor-codemirror-B1SGo4xl.js";import{B as T,Q as oe,N as Pe,y as Te,w as le,R as Me,x as q,z as Y,T as Ee,A as X,P as Ae,C as Ie,m as M,D as ue,a as de,b as Fe,c as ie,d as xe,e as Ge,t as I,o as Le,ab as Oe,ac as ze,ad as Be,ae as Ue,af as ee,ag as F}from"./index-Dungj95X.js";import{C as G,b as W,c as $,d as pe,a as L}from"./card-BIfzBCEy.js";import{I as z}from"./input-CXoUQQLm.js";import{B as y}from"./badge-CGJlVD3L.js";import{k as w}from"./index-drGq01ok.js";import{T as We,a as $e,b as E,c as A}from"./tabs-D87nAyJR.js";import{i as me,a as be,R as V,aK as Ve,r as qe,L as he,at as He,au as Xe,X as Ye,P as Je,S as Qe,aP as Ze,x as et,p as tt,k as st,v as te,T as rt,l as nt,y as at}from"./vendor-icons-DmqcWdzX.js";import{R as ct,A as ot,C as lt,X as ut,Y as dt,T as it,a as se}from"./AreaChart-yrR-Mxho.js";import{T as re}from"./textarea-BxfjmLq5.js";import{L as P}from"./label-CMpUoC87.js";import{u as xt}from"./index-5FEebgvX.js";import{x as pt,a as mt}from"./vendor-xterm-20M9KZE1.js";function bt({cluster:a,onClose:p}){const[n,g]=r.useState([]),[s,l]=r.useState([]),[x,j]=r.useState([]),[k,C]=r.useState([]),[b,f]=r.useState([]),h=r.useMemo(()=>{if(!n||n.length===0)return{cpuPct:0,memPct:0};let t=0,u=0,v=0;for(const K of n){const o=K.cpu||0,i=K.cpu_usage_m?parseFloat(String(K.cpu_usage_m).replace("m","")):0,N=o>0?i/1e3/o*100:0,S=K.memory_mb||0,O=K.mem_usage_mi?parseFloat(String(K.mem_usage_mi).replace("Mi","").replace("Ki","")):0,B=K.mem_usage_mi?.includes?.("Ki")?O/1024:K.mem_usage_mi?.includes?.("Gi")?O*1024:O,U=S>0?B/S*100:0;(N>0||U>0)&&(t+=N,u+=U,v++)}return{cpuPct:v>0?t/v:0,memPct:v>0?u/v:0}},[n]),m=r.useMemo(()=>{const t=Math.max(0,Math.min(100,Number(h.cpuPct.toFixed(1)))),u=Math.max(0,Math.min(100,Number(h.memPct.toFixed(1))));return[{time:"10m前",cpu:Math.max(0,t*.72),memory:Math.max(0,u*.78)},{time:"7m前",cpu:Math.max(0,t*.82),memory:Math.max(0,u*.85)},{time:"4m前",cpu:Math.max(0,t*.9),memory:Math.max(0,u*.93)},{time:"2m前",cpu:Math.max(0,t*.96),memory:Math.max(0,u*.97)},{time:"现在",cpu:t,memory:u}]},[h]),d=async t=>{try{const[u,v,K,o,i]=await Promise.all([w.getNodes(t).catch(()=>[]),w.getPods(t).catch(()=>[]),w.getDeployments(t).catch(()=>[]),w.getServices(t).catch(()=>[]),w.getIngresses(t).catch(()=>[])]),N=S=>Array.isArray(S)?S:S?.list||[];g(N(u)),l(N(v)),j(N(K)),C(N(o)),f(N(i))}catch(u){console.error("加载集群详情失败:",u)}};return r.useEffect(()=>{a?.id&&d(a.id)},[a?.id]),e.jsxs(G,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:98:5",className:"bg-slate-900 border-slate-800",children:[e.jsx(W,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:99:7",children:e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:100:9",className:"flex items-center justify-between",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:101:11",className:"flex items-center gap-3",children:[e.jsx(me,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:102:13",className:"h-6 w-6 text-blue-400"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:103:13",children:[e.jsx($,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:104:15",className:"text-slate-100",children:a.name}),e.jsxs(pe,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:105:15",className:"text-slate-500",children:[a.version," · ",a.node_count||0," 节点 · 创建于"," ",a.created_at?new Date(a.created_at).toLocaleDateString():"-"]})]})]}),e.jsxs(T,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:111:11",variant:"ghost",size:"sm",className:"text-slate-400 hover:text-slate-100",onClick:p,children:[e.jsx(be,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:117:13",className:"h-4 w-4 mr-2"}),"关闭"]})]})}),e.jsx(L,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:122:7",children:e.jsxs(We,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:123:9",defaultValue:"overview",className:"w-full",children:[e.jsxs($e,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:124:11",className:"bg-slate-800 border border-slate-700 flex-wrap h-auto",children:[e.jsx(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:125:13",value:"overview",className:"data-[state=active]:bg-slate-700",children:"概览"}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:128:13",value:"nodes",className:"data-[state=active]:bg-slate-700",children:["节点 (",n.length,")"]}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:131:13",value:"pods",className:"data-[state=active]:bg-slate-700",children:["Pod (",s.length,")"]}),e.jsxs(E,{"code-path":"src/components/kubernetes/KubernetesClusterDetail.tsx:134:13",value:"deployments",className:"data-[state=active]:bg-slate-700",children:["Deployment (",x.length,")"]}),e.jsxs(E,{"coLine truncated
|
||||
kind: Config
|
||||
clusters:
|
||||
- cluster:
|
||||
server: https://10.0.0.1:6443
|
||||
...`,rows:10,className:"bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)] text-[var(--dg-text-primary)] placeholder:text-[var(--dg-text-muted)] font-mono text-xs"}),!b&&e.jsx("p",{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:244:17",className:"text-xs text-[var(--dg-text-muted)]",children:"粘贴 kubeconfig 内容后将自动解析 API Server 地址"})]})]}),e.jsxs(Ge,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:251:9",children:[e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:252:11",variant:"outline",onClick:()=>{p(!1)},className:"border-[var(--dg-border)] text-[var(--dg-text-secondary)] hover:text-[var(--dg-text-primary)] hover:bg-[var(--dg-bg-hover)]",children:"取消"}),e.jsx(T,{"code-path":"src/components/kubernetes/KubernetesClusterDialog.tsx:259:11",onClick:v,disabled:K,className:"bg-[var(--dg-blue)] hover:opacity-90 text-white",children:x?"保存中...":n?"保存":"添加"})]})]})})}function Rt({open:a,onOpenChange:p,clusterId:n,clusterName:g}){const s=r.useRef(null),l=r.useRef(null),x=r.useRef(null),j=r.useRef(null),[k,C]=r.useState(!1),[b,f]=r.useState(!1),[h,m]=r.useState("");return r.useEffect(()=>{a||f(!1)},[a]),r.useEffect(()=>{if(!a||!n)return;const d=new pt.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#38bdf8",selectionBackground:"#1e40af",black:"#1e293b",red:"#ef4444",green:"#10b981",yellow:"#f59e0b",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e2e8f0",brightBlack:"#475569",brightRed:"#f87171",brightGreen:"#34d399",brightYellow:"#fbbf24",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#f8fafc"}}),t=new mt.FitAddon;d.loadAddon(t),l.current=d,j.current=t;const v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,K=Le.getState().token||"",o=`${v.replace(/^http/,"ws").replace("/api/v1","")}/ws/kubectl?token=${encodeURIComponent(K)}&id=${n}`,i=new WebSocket(o);return x.current=i,d.onData(N=>{i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({status:0,data:N}))}),i.onmessage=N=>{try{const S=JSON.parse(N.data);S.status===0&&typeof S.data=="string"&&d.write(S.data)}catch{typeof N.data=="string"&&d.write(N.data)}},i.onopen=()=>{C(!0),m(""),s.current&&(d.open(s.current),requestAnimationFrame(()=>{try{t.fit()}catch{}}),setTimeout(()=>{try{d.focus()}catch{}},150))},i.onclose=()=>{C(!1),d.write(`\r
|
||||
\x1B[31m[连接已断开]\x1B[0m\r
|
||||
`)},i.onerror=()=>{m("WebSocket 连接失败"),d.write(`\r
|
||||
\x1B[31m[连接发生错误]\x1B[0m\r
|
||||
`)},()=>{try{(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING)&&i.close(),d.dispose()}catch{}l.current=null,x.current=null,C(!1)}},[a,n]),r.useEffect(()=>{if(!a)return;const d=s.current;if(!d)return;let t;const u=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{if(j.current&&l.current&&x.current)try{j.current.fit(),l.current.focus();const{cols:v,rows:K}=l.current;x.current.readyState===WebSocket.OPEN&&x.current.send(JSON.stringify({status:1,cols:v,rows:K}))}catch{}},60)});return u.observe(d),()=>{clearTimeout(t),u.disconnect()}},[a]),e.jsx(ue,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:161:5",open:a,onOpenChange:p,children:e.jsxs(de,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:162:7",showCloseButton:!1,onOpenAutoFocus:d=>d.preventDefault(),className:M("bg-[var(--dg-bg-secondary)] border-[var(--dg-border)] p-0 gap-0","!duration-0 !transition-none",b?"!max-w-none !w-screen !h-screen !rounded-none !translate-x-0 !translate-y-0 !left-0 !top-0":""),style:b?{maxWidth:"100vw",width:"100vw",height:"100vh"}:{maxWidth:"900px",width:"90vw"},children:[e.jsxs(ie,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:174:9",className:"sr-only",children:["kubectl — ",g]}),e.jsx(xe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:175:9",className:"sr-only",children:"Kubernetes 集群命令行终端"}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:178:9",className:"flex items-center justify-between px-4 py-2 border-b border-[var(--dg-border)]",children:[e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:179:11",className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:180:13",className:M("w-2 h-2 rounded-full",k?"bg-emerald-400":h?"bg-red-400":"bg-yellow-400")}),e.jsx(qe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:181:13",className:"h-4 w-4 text-blue-400"}),e.jsxs("span",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:182:13",className:"text-[var(--dg-text-primary)] font-medium",children:["kubectl — ",g]}),!k&&!h&&e.jsx(he,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:183:38",className:"h-3 w-3 animate-spin text-[var(--dg-text-muted)]"})]}),e.jsxs("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:185:11",className:"flex items-center gap-1",children:[e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:186:13",onClick:()=>f(!b),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:b?e.jsx(He,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:29",className:"h-4 w-4"}):e.jsx(Xe,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:190:65",className:"h-4 w-4"})}),e.jsx("button",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:192:13",onClick:()=>p(!1),className:"p-1.5 rounded hover:bg-[var(--dg-bg-hover)] text-[var(--dg-text-secondary)]",children:e.jsx(Ye,{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:196:15",className:"h-4 w-4"})})]})]}),e.jsx("div",{"code-path":"src/components/kubernetes/KubectlTerminal.tsx:202:9",ref:s,className:"bg-[#0f172a]",style:{height:b?"calc(100vh - 49px)":"480px"}})]})})}function Wt(){const[a,p]=r.useState([]),[n,g]=r.useState(!0),[s,l]=r.useState(null),[x,j]=r.useState(""),[k,C]=r.useState(!1),[b,f]=r.useState(null),[h,m]=r.useState(null),[d,t]=r.useState(!1),[u,v]=r.useState(null),[K,o]=r.useState(!1),i=async()=>{try{g(!0);const c=await w.getClusters();p(c?.list||[])}catch(c){console.error("加载集群列表失败:",c),p([])}finally{g(!1)}};r.useEffect(()=>{i()},[]);const[,N]=r.useState(null),S=()=>{i().then(()=>{b||setTimeout(async()=>{const D=(await w.getClusters())?.list||[];D.length>0&&B(D[D.length-1].id,!0)},500)})},O=async c=>{try{await w.deleteCluster(c),i()}catch(D){console.error("删除集群失败:",D)}},B=async(c,D)=>{try{D||I.info("正在同步集群资源...");const R=await w.syncCluster(c);D||I.success(R?.message||"同步完成"),i()}catch(R){D||I.error(R?.message||"同步失败")}},U=async()=>{if(!u)return;const c=u.code||String(u.id);try{o(!0),I.info(`正在导出 ${u.name} 所有命名空间的资源...`),await w.exportAllResources(c),I.success("导出完成,已开始下载"),v(null)}catch(D){I.error(D?.message||"导出失败")}finally{o(!1)}},Q=a.filter(c=>(c.name||"").toLowerCase().includes(x.toLowerCase())||(c.version||"").includes(x)),_e=c=>{switch(c){case"healthy":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:138:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[e.jsx(at,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:139:13",className:"h-3 w-3 mr-1"}),"健康"]});case"warning":return e.jsxs(y,{"code-path":"src/components/kubernetes/KubernetesClusters.tsx:145:11",variant:"outline",className:"border-amber-500/30 text-ambe
Line truncated
|
||||
Reference in new issue
Block a user